Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(tests): observe background workers instead of sampling them

Alexander Eichhorne16643ae385e
diff --git a/tests/app/services/image_moves/test_image_moves_default.py b/tests/app/services/image_moves/test_image_moves_default.py
index e0d29dd4c8..bbeea1cbf6 100644
--- a/tests/app/services/image_moves/test_image_moves_default.py
+++ b/tests/app/services/image_moves/test_image_moves_default.py
@@ -479,7 +479,9 @@ def test_background_recovery_can_start_when_journal_job_is_active(tmp_path: Path
job_id = service.create_move_job(service.plan_batch(last_image_name="", limit=100))
status = service.start_background_recovery()
- assert status.is_running is True
+ # Not `is_running`: that samples whether the worker happens to still be going, and on a loaded
+ # machine the recovery can finish before the status is read. What the active journal job must
+ # not do is prevent recovery from being started at all, which the rest of this test observes.
assert status.operation == "recovery"
assert service._future is not None
diff --git a/tests/backend/model_manager/load/model_cache/test_model_cache_ram_budget.py b/tests/backend/model_manager/load/model_cache/test_model_cache_ram_budget.py
index 145065bf17..6e328ea16a 100644
--- a/tests/backend/model_manager/load/model_cache/test_model_cache_ram_budget.py
+++ b/tests/backend/model_manager/load/model_cache/test_model_cache_ram_budget.py
@@ -3728,7 +3728,9 @@ def test_dropped_cache_is_collectable_and_its_worker_exits(mock_logger):
cache = _make_cache(store, budget, mock_logger)
module = DummyModule()
cache.put("model", module)
- assert worker_count() == before + 1
+ # The worker starts asynchronously, and a worker from an earlier test may still be winding
+ # down, so the count is converged on rather than sampled at one instant.
+ assert _wait_until(lambda: worker_count() == before + 1), "the cache never started its worker"
cache_ref = weakref.ref(cache)
module_ref = weakref.ref(module)