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:
+9
-1
@@ -1,5 +1,6 @@
|
|||||||
"""Run shaping and the API's Dagster-backed run and execution routes."""
|
"""Run shaping and the API's Dagster-backed run and execution routes."""
|
||||||
|
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -209,10 +210,17 @@ def test_run_requests_validate_the_execution_choice(api_with_dagster_address):
|
|||||||
def test_execution_options_and_health(api):
|
def test_execution_options_and_health(api):
|
||||||
options = _ok(api.get("/execution/options"))
|
options = _ok(api.get("/execution/options"))
|
||||||
assert options["default_mode"] == "sync"
|
assert options["default_mode"] == "sync"
|
||||||
assert options["schedulers"] == []
|
configured = [s for s in os.environ.get("DASK_SCHEDULERS", "").split(",") if s]
|
||||||
|
assert options["schedulers"] == configured # compose and CI name the test scheduler
|
||||||
health = _ok(api.get("/execution/health", params={"mode": "local"}))
|
health = _ok(api.get("/execution/health", params={"mode": "local"}))
|
||||||
assert health["reachable"] is True
|
assert health["reachable"] is True
|
||||||
assert health["workers"] >= 1
|
assert health["workers"] >= 1
|
||||||
|
if configured:
|
||||||
|
remote = {"mode": "remote", "scheduler": configured[0]}
|
||||||
|
health = _ok(api.get("/execution/health", params=remote))
|
||||||
|
assert health["reachable"] is True
|
||||||
|
assert health["workers"] == int(os.environ.get("DASK_EXPECTED_WORKERS", "1"))
|
||||||
|
else:
|
||||||
assert api.get("/execution/health", params={"mode": "remote"}).status_code == 422
|
assert api.get("/execution/health", params={"mode": "remote"}).status_code == 422
|
||||||
assert api.get("/execution/health?mode=sync&reference=..%2Fx").status_code == 422
|
assert api.get("/execution/health?mode=sync&reference=..%2Fx").status_code == 422
|
||||||
|
|
||||||
|
|||||||
@@ -91,12 +91,24 @@ def test_cancelling_an_ingest_run_leaves_no_silver_or_gold(api, platform):
|
|||||||
@pytest.mark.parametrize("platform", ["sqlite"], indirect=True)
|
@pytest.mark.parametrize("platform", ["sqlite"], indirect=True)
|
||||||
def test_cancelling_a_queued_run_never_starts_it(api, platform):
|
def test_cancelling_a_queued_run_never_starts_it(api, platform):
|
||||||
load(api, "cacu")
|
load(api, "cacu")
|
||||||
first, second = _submit(api), _submit(api)
|
runs = [_submit(api), _submit(api)]
|
||||||
if _get_run(api, second)["state"] != "queued":
|
# Dagster launches one of the two (its queue sorts by priority, not by submission order);
|
||||||
pytest.skip("the second run was not queued")
|
# the other waits behind the `writes` limit: cancel that one, whichever it is.
|
||||||
ok(api.post(f"/runs/{second}/cancel"))
|
deadline = time.monotonic() + 120
|
||||||
assert _wait_cancelled(api, second)["started"] is None
|
while True:
|
||||||
wait_for(api, first, 300)
|
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")
|
@pytest.mark.skip(reason="needs killing the run worker; checked by hand")
|
||||||
|
|||||||
Reference in New Issue
Block a user