Skip to content

test(emr_provisioner): replace ThreadedMotoServer with @mock_aws() fixture - #15784

Merged
dimakr merged 1 commit into
scylladb:masterfrom
pehala:pr-emr-mock-aws
Aug 17, 2026
Merged

test(emr_provisioner): replace ThreadedMotoServer with @mock_aws() fixture#15784
dimakr merged 1 commit into
scylladb:masterfrom
pehala:pr-emr-mock-aws

Conversation

@pehala

@pehala pehala commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • test_emr_provisioner.py ran a real moto.server.ThreadedMotoServer (module-scoped, real socket/thread) instead of moto's in-process @mock_aws() used elsewhere in the repo (test_spark_migrator.py, test_keystore.py).
  • Only emr and iam clients are exercised by sdcm/provision/aws/emr_provisioner.py — neither depends on a live endpoint (no endpoint_url=/AWS_ENDPOINT_URL usage in production code), so the switch is a pure test-infrastructure change with no production code touched.
  • Replaced the module-scoped moto_server fixture with a function-scoped, autoused aws_mock fixture wrapping mock_aws().

Memray high-watermark before/after (13 of 19 tests):

  • most EMR-cluster tests: ~9.7-10.1MiB -> 45.6KiB-2.6MiB
  • test_list_emr_clusters_by_tags: 10.1MiB -> 1.2MiB
  • test_ensure_emr_roles_idempotent: 9.9MiB -> 1.5MiB
  • file total across all 19 tests: ~256.6MiB -> ~130.5MiB

Note: test_create_emr_cluster itself barely moves (128.8 -> 109.3MiB) since that cost is a one-time botocore/moto JSON model decode paid by whichever test runs first in the process, not something the server-vs-decorator choice affects. Wall-clock is essentially unchanged (~1.6-2.4s either way) — this is a memory-only fix.

Test plan

  • uv run pytest unit_tests/unit/test_emr_provisioner.py -v — all 19 tests pass
  • uv run pytest unit_tests/unit/test_emr_provisioner.py --memray --most-allocations=0 -n0 — confirmed memory drop above
  • uv run sct.py pre-commit passes

🤖 Generated with Claude Code

…xture

Drops the real-HTTP moto server (module-scoped socket/thread) in favor of
moto's in-process mock_aws(), function-scoped and autoused. Only sdcm's
emr/iam clients are exercised, neither of which depends on a live endpoint.

Per-test memray high-watermark before/after (13 of 19 tests):
- most EMR-cluster tests: ~9.7-10.1MiB -> 45.6KiB-2.6MiB
- test_list_emr_clusters_by_tags: 10.1MiB -> 1.2MiB
- test_ensure_emr_roles_idempotent: 9.9MiB -> 1.5MiB
- file total across all 19 tests: ~256.6MiB -> ~130.5MiB

test_create_emr_cluster itself barely moves (128.8 -> 109.3MiB) since that
cost is a one-time botocore/moto JSON model decode paid by whichever test
runs first in the process, not something server-vs-decorator affects.
Wall-clock is unaffected (~1.6-2.4s either way) - this is a memory-only fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@scylladb-promoter

Copy link
Copy Markdown
Collaborator

✅ Test Summary: PASSED

✅ Precommit: PASSED

Total Passed Failed Skipped
28 16 0 12

✅ Tests: PASSED

Total Passed Failed Errors Skipped
4782 4751 0 0 31

Full build log

@pehala
pehala requested a review from a team August 14, 2026 08:28
@pehala pehala added the P3 Medium Priority label Aug 14, 2026
@dimakr
dimakr merged commit d126e9d into scylladb:master Aug 17, 2026
40 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants