Run tests: execution options follow the configured schedulers; the queued-cancel test cancels whichever run Dagster left queued and checks none of its steps ran

This commit is contained in:
2026-11-29 07:43:49 -06:00
parent c7caf56f83
commit f830003abd
2 changed files with 28 additions and 8 deletions
+18 -6
View File
@@ -91,12 +91,24 @@ def test_cancelling_an_ingest_run_leaves_no_silver_or_gold(api, platform):
@pytest.mark.parametrize("platform", ["sqlite"], indirect=True)
def test_cancelling_a_queued_run_never_starts_it(api, platform):
load(api, "cacu")
first, second = _submit(api), _submit(api)
if _get_run(api, second)["state"] != "queued":
pytest.skip("the second run was not queued")
ok(api.post(f"/runs/{second}/cancel"))
assert _wait_cancelled(api, second)["started"] is None
wait_for(api, first, 300)
runs = [_submit(api), _submit(api)]
# Dagster launches one of the two (its queue sorts by priority, not by submission order);
# the other waits behind the `writes` limit: cancel that one, whichever it is.
deadline = time.monotonic() + 120
while True:
states = {run_id: _get_run(api, run_id)["state"] for run_id in runs}
running = [r for r, state in states.items() if state == "running"]
queued = [r for r, state in states.items() if state == "queued"]
if len(running) == 1 and len(queued) == 1:
break
if any(state in TERMINAL for state in states.values()):
pytest.skip(f"a run ended before the other was seen queued: {states}")
assert time.monotonic() < deadline, states
time.sleep(0.5)
ok(api.post(f"/runs/{queued[0]}/cancel"))
# Dagster stamps a start time on a queued run it cancels; what matters is that nothing ran
assert _wait_cancelled(api, queued[0])["steps"] == []
wait_for(api, running[0], 300)
@pytest.mark.skip(reason="needs killing the run worker; checked by hand")