Skip to content

test: fix two flaky serverless tests#513

Open
deanq wants to merge 1 commit into
mainfrom
deanquinanola/sls-268-fix-flaky-tests
Open

test: fix two flaky serverless tests#513
deanq wants to merge 1 commit into
mainfrom
deanquinanola/sls-268-fix-flaky-tests

Conversation

@deanq

@deanq deanq commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Two tests fail intermittently regardless of source changes, blocking make quality-check and CI.

1. TestRunWorker (test_worker.py) — real memory probe

run_worker() calls asyncio.run(run_fitness_checks()) (runpod/serverless/worker.py:40). The _memory_check probe reads real host memory and sys.exit(1)s when <4GB. No TestRunWorker test mocked it, so the class failed whenever the host was under memory pressure (RuntimeError: Insufficient memory: 3.66GB available, 4.0GB required).

Fix: stub run_fitness_checks in asyncSetUp. Fitness checks keep dedicated coverage in tests/test_serverless/test_modules/test_fitness/.

2. test_download_files_from_urls — parallel call ordering

download_files_from_urls downloads via ThreadPoolExecutor.map. The test asserted mock_get.call_args_list[index] matched urls[index] positionally, but call order across threads is non-deterministic (executor.map preserves result order, not call order).

Fix: assert the set of requested URLs equals the input set. Result-order checks (extension, open() call) are unchanged since executor.map preserves result order.

Test plan

Verified deterministic across repeated runs before fixing intent:

  • test_download_files_from_urls: 10/10 passed (was ~4/5)
  • TestRunWorker: 9/9 passed across 10 runs
  • make quality-check: 478 passed, coverage 94.08% (gate 90%)

Both tests fail intermittently regardless of source changes, blocking
make quality-check and CI.

- TestRunWorker invoked run_worker -> run_fitness_checks, whose
  _memory_check probes real host memory and exits when <4GB. Stub
  run_fitness_checks in asyncSetUp; fitness checks are covered by
  tests/test_serverless/test_modules/test_fitness/.
- test_download_files_from_urls asserted get() call order, but downloads
  run in parallel threads (executor.map preserves result order, not call
  order). Assert the set of requested URLs instead.

Refs SLS-268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant