Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(tests): make two parallel-shard races deterministic (#1368)
iot-rocket1c9029194674
diff --git a/tests/test_cfn.py b/tests/test_cfn.pyindex 11d8fc9a..67944fb0 100644--- a/tests/test_cfn.py+++ b/tests/test_cfn.py@@ -697,8 +697,13 @@ def test_cfn_unnamed_dynamodb_table_survives_unrelated_update(cfn, ddb, ssm):tables_after = set(ddb.list_tables()["TableNames"])table_name_after = ssm.get_parameter(Name="/cfn-t02f/table-name")["Parameter"]["Value"]- assert tables_after == tables_before- assert table_name_after == table_name_before+ # Assert on this stack's table only. `list_tables()` is global and all xdist+ # workers share one server, so any comparison of the whole set against a+ # snapshot taken before the update is racy in both directions: a concurrent+ # test creating a table breaks equality, and one deleting its own table+ # breaks a subset check. Neither says anything about the behaviour here.+ assert table_name_after == table_name_before, "the table was re-created under a new name"+ assert table_name_after in tables_after, "the stack's table did not survive the update"def test_cfn_ssm_parameter_value_type_resolves_stored_value(cfn, ssm, sqs):"""A `AWS::SSM::Parameter::Value<String>` template parameter's Default/diff --git a/tests/test_glue.py b/tests/test_glue.pyindex 07c09fff..f57f2915 100644--- a/tests/test_glue.py+++ b/tests/test_glue.py@@ -1108,8 +1108,22 @@ def test_glue_batch_stop_job_run(glue):)run1 = glue.start_job_run(JobName=name)["JobRunId"]run2 = glue.start_job_run(JobName=name)["JobRunId"]- # Ministack auto-completes runs (SUCCEEDED), so batch stop returns errors- # for completed runs + not-found run+ # `StartJobRun` hands execution to a background thread and returns while the+ # run is still STARTING, so the state BatchStopJobRun sees depends on when+ # that thread is scheduled. Wait for both runs to settle: a run still+ # STARTING/RUNNING is legitimately *stopped* (a successful submission), and+ # this test is about the already-completed case.+ for run_id in (run1, run2):+ for _ in range(40):+ state = glue.get_job_run(JobName=name, RunId=run_id)["JobRun"]["JobRunState"]+ if state in ("SUCCEEDED", "FAILED", "STOPPED", "TIMEOUT"):+ break+ time.sleep(0.25)+ else:+ raise AssertionError(f"run {run_id} never reached a terminal state (last: {state})")++ # Both runs are terminal now, so batch stop returns errors for the two+ # completed runs plus the not-found one.resp = glue.batch_stop_job_run(JobName=name, JobRunIds=[run1, run2, "no-such-run"])assert "SuccessfulSubmissions" in respassert "Errors" in resp