Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 2 additions & 42 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@ pyyaml = "^6.0.2"
sqlalchemy = "^2.0.36"

[tool.poetry.group.dev.dependencies]
isort = "*"
mypy = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-cov = "*"
pytest-mock = "*"
pytest-rerunfailures = "*"
ruff = "*"
types-setuptools = "*"
types-requests = "*"
types-pyyaml = "*"
types-pytz = "*"
types-pymysql = "*"
types-croniter = "*"

[tool.poetry.group.plugin-aws.dependencies]
Expand Down
10 changes: 5 additions & 5 deletions tests/components/executor/test_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ async def long_sleep() -> None:
async def test_run_timeout(caplog, monkeypatch, sample_monitor: Monitor):
"""'run' should execute all the reactions and the timeout should be independent for each
function"""
monkeypatch.setattr(configs, "executor_reaction_timeout", 0.2)
monkeypatch.setattr(configs, "executor_reaction_timeout", 0.1)

async def long_sleep(message_payload):
await asyncio.sleep(1)
await asyncio.sleep(0.5)

long_sleep_mock = AsyncMock(side_effect=long_sleep)

async def short_sleep(message_payload):
await asyncio.sleep(0.1)
await asyncio.sleep(0.01)

short_sleep_mock = AsyncMock(side_effect=short_sleep)

Expand All @@ -295,8 +295,8 @@ async def short_sleep(message_payload):
end_time = time.perf_counter()

total_time = end_time - start_time
assert total_time > 1 - 0.001
assert total_time < 1 + 0.03
assert total_time > 0.4 - 0.001
assert total_time < 0.4 + 0.03

assert long_sleep_mock.call_count == 4
assert_message_in_log(caplog, "Timed out executing reaction", count=4)
Expand Down
12 changes: 6 additions & 6 deletions tests/components/executor/test_monitor_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,18 +1114,18 @@ async def do_nothing(monitor): ...

async def test_heartbeat_routine(monkeypatch, sample_monitor: Monitor):
"""'_heartbeat_routine' should handle execution timeouts while running the monitor routines"""
monkeypatch.setattr(monitor_handler.configs, "executor_monitor_heartbeat_time", 0.5)
monkeypatch.setattr(monitor_handler.configs, "executor_monitor_heartbeat_time", 0.1)

await sample_monitor.refresh()
assert sample_monitor.last_heartbeat is None

heartbeat_task = asyncio.create_task(monitor_handler._heartbeat_routine(sample_monitor))

await asyncio.sleep(0)
for _ in range(4):
for _ in range(2):
await sample_monitor.refresh()
assert sample_monitor.last_heartbeat > now() - timedelta(seconds=0.1)
await asyncio.sleep(0.5)
await asyncio.sleep(0.1)

heartbeat_task.cancel()

Expand Down Expand Up @@ -1205,11 +1205,11 @@ async def test_run_monitor_heartbeat(monkeypatch, sample_monitor: Monitor):
"""'run' should handle execution timeouts while running the monitor routines"""

async def sleep(monitor, tasks):
await asyncio.sleep(2.1)
await asyncio.sleep(0.5)

monkeypatch.setattr(monitor_handler, "_run_routines", sleep)

monkeypatch.setattr(monitor_handler.configs, "executor_monitor_heartbeat_time", 0.5)
monkeypatch.setattr(monitor_handler.configs, "executor_monitor_heartbeat_time", 0.1)

await sample_monitor.refresh()
assert sample_monitor.last_heartbeat is None
Expand All @@ -1222,7 +1222,7 @@ async def sleep(monitor, tasks):
for _ in range(4):
await sample_monitor.refresh()
assert sample_monitor.last_heartbeat > now() - timedelta(seconds=0.1)
await asyncio.sleep(0.5)
await asyncio.sleep(0.1)

await run_task

Expand Down
4 changes: 2 additions & 2 deletions tests/components/executor/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ async def test_change_visibility_loop(mocker, monkeypatch, clear_queue):
monkeypatch.setattr(
message_queue.queue._config, # type: ignore[attr-defined]
"queue_wait_message_time",
0.2,
0.1,
)
change_visibility_spy: MagicMock = mocker.spy(message_queue, "change_visibility")

message = InternalMessage(json.dumps({"type": "type", "payload": "payload"}))

task = asyncio.create_task(runner._change_visibility_loop(message))
await asyncio.sleep(1.0)
await asyncio.sleep(0.5)
task.cancel()

await asyncio.sleep(0.1)
Expand Down
4 changes: 2 additions & 2 deletions tests/module_loader/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def test_load_module_from_file_reload_replace_variables():
module.v.append(10)
assert module.v == [10]

# As python checks for the timestamp to change to reload a module, sleep for 1 second
time.sleep(1)
# As python checks for the timestamp to change to reload a module, sleep until the next second
time.sleep(1 - time.time() % 1 + 0.01)

module = loader.load_module_from_file(module_path)

Expand Down
21 changes: 10 additions & 11 deletions tests/plugins/aws/queues/sqs/test_sqs_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ async def test_get_message_not_deleted():
"url": "http://motoserver:5000/123456789012/app",
"region": "us-east-1",
"create_queue": True,
"queue_wait_message_time": 2,
"queue_wait_message_time": 0,
"queue_visibility_time": 1,
}
)
Expand All @@ -281,7 +281,7 @@ async def test_get_message_not_deleted():
message = await queue.get_message()
assert message is None

await asyncio.sleep(1)
await asyncio.sleep(2)

message = await queue.get_message()
assert message is not None
Expand All @@ -298,7 +298,7 @@ async def test_change_visibility():
"url": "http://motoserver:5000/123456789012/app",
"region": "us-east-1",
"create_queue": True,
"queue_wait_message_time": 2,
"queue_wait_message_time": 0,
"queue_visibility_time": 1,
}
)
Expand All @@ -310,12 +310,11 @@ async def test_change_visibility():
assert message is not None
assert message.content == {"type": "test", "payload": {"a": 1}}

for _ in range(3):
await queue.change_visibility(message)
new_message = await queue.get_message()
assert new_message is None
await queue.change_visibility(message)
new_message = await queue.get_message()
assert new_message is None

await asyncio.sleep(1)
await asyncio.sleep(2)

message = await queue.get_message()
assert message is not None
Expand All @@ -331,8 +330,8 @@ async def test_delete_message():
"url": "http://motoserver:5000/123456789012/app",
"region": "us-east-1",
"create_queue": True,
"queue_wait_message_time": 2,
"queue_visibility_time": 15,
"queue_wait_message_time": 0,
"queue_visibility_time": 0,
}
)
await queue.init()
Expand All @@ -345,7 +344,7 @@ async def test_delete_message():

await queue.delete_message(message)

await asyncio.sleep(2)
await asyncio.sleep(0.5)

message = await queue.get_message()
assert message is None