Cancel waits up to 30 s for a run that is still starting (Dagster cannot terminate it then); still starting is a 409 with Retry-After
This commit is contained in:
@@ -255,3 +255,26 @@ def test_a_locked_run_storage_is_read_again(monkeypatch):
|
||||
with pytest.raises(HTTPException) as raised:
|
||||
runs.graphql("q", {})
|
||||
assert raised.value.status_code == 503
|
||||
|
||||
|
||||
def test_cancel_waits_for_a_starting_run(monkeypatch):
|
||||
"""Dagster refuses to terminate a run that is still STARTING: cancel waits for it to start."""
|
||||
from webapi import runs
|
||||
|
||||
statuses = iter(["STARTING", "STARTING", "STARTED", "CANCELING"])
|
||||
terminated = []
|
||||
|
||||
class Client:
|
||||
def get_run_status(self, run_id):
|
||||
class S:
|
||||
value = next(statuses)
|
||||
|
||||
return S()
|
||||
|
||||
def terminate_run(self, run_id):
|
||||
terminated.append(run_id)
|
||||
|
||||
monkeypatch.setattr(runs.time, "sleep", lambda s: None)
|
||||
answer = runs.cancel_run("r1", client=Client())
|
||||
assert terminated == ["r1"]
|
||||
assert answer.status == "CANCELING"
|
||||
|
||||
Reference in New Issue
Block a user