test(emr_provisioner): replace ThreadedMotoServer with @mock_aws() fixture - #15784
Merged
Conversation
…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>
Collaborator
✅ Test Summary: PASSED✅ Precommit: PASSED
✅ Tests: PASSED
|
dimakr
approved these changes
Aug 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_emr_provisioner.pyran a realmoto.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).emrandiamclients are exercised bysdcm/provision/aws/emr_provisioner.py— neither depends on a live endpoint (noendpoint_url=/AWS_ENDPOINT_URLusage in production code), so the switch is a pure test-infrastructure change with no production code touched.moto_serverfixture with a function-scoped, autousedaws_mockfixture wrappingmock_aws().Memray high-watermark before/after (13 of 19 tests):
test_list_emr_clusters_by_tags: 10.1MiB -> 1.2MiBtest_ensure_emr_roles_idempotent: 9.9MiB -> 1.5MiBNote:
test_create_emr_clusteritself 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 passuv run pytest unit_tests/unit/test_emr_provisioner.py --memray --most-allocations=0 -n0— confirmed memory drop aboveuv run sct.py pre-commitpasses🤖 Generated with Claude Code