sched: truthful executing marks in capacity test shortcuts; format wave files
This commit is contained in:
@@ -559,9 +559,7 @@ async def test_store_deployment_directory_contract(tmp_path: Path) -> None:
|
||||
directory.required_inputs("missing.deployment")
|
||||
|
||||
|
||||
async def _poll_two(
|
||||
service: SchedulerService, intended: datetime
|
||||
) -> tuple[str, str]:
|
||||
async def _poll_two(service: SchedulerService, intended: datetime) -> tuple[str, str]:
|
||||
service.schedule_store.create_schedule(_sched_model("a", intended))
|
||||
service.schedule_store.create_schedule(_sched_model("b", intended))
|
||||
result = await service.poll_once(intended + timedelta(seconds=1))
|
||||
@@ -644,9 +642,7 @@ async def test_live_settlement_failure_spares_healthy_sibling(
|
||||
|
||||
def _flaky_settle(self: Any, run_id: str, state: Any, now: datetime) -> None:
|
||||
try:
|
||||
owned_by_b = (
|
||||
self.run_store.get_admission(run_id).schedule_id == "b"
|
||||
)
|
||||
owned_by_b = self.run_store.get_admission(run_id).schedule_id == "b"
|
||||
except KeyError:
|
||||
owned_by_b = False
|
||||
if owned_by_b and not fired["done"]:
|
||||
@@ -707,11 +703,7 @@ async def test_live_torn_settlement_reconciles_genuine_result(
|
||||
)
|
||||
except KeyError:
|
||||
owned_by_b = False
|
||||
if (
|
||||
kwargs.get("kind") == "completed"
|
||||
and owned_by_b
|
||||
and not fired["done"]
|
||||
):
|
||||
if kwargs.get("kind") == "completed" and owned_by_b and not fired["done"]:
|
||||
fired["done"] = True
|
||||
raise RuntimeError("injected history failure")
|
||||
original(self, **kwargs)
|
||||
|
||||
@@ -193,7 +193,11 @@ def test_parallel_limits_and_interrupted_slots() -> None:
|
||||
sched.poll(t0)
|
||||
assert sched._task_load() == 1
|
||||
first = runs.list_runs()[0]
|
||||
# A waiting interruption holds no task slot: production dispatch
|
||||
# clears the executing mark when persisting the stopped result, so
|
||||
# the simulated interruption clears it too.
|
||||
runs.save_run(first.model_copy(update={"status": StoredRunStatus.INTERRUPTED}))
|
||||
runs.clear_executing(first.id)
|
||||
assert sched._task_load() == 0
|
||||
sched.poll(t0 + timedelta(minutes=5))
|
||||
assert len(runs.list_runs()) == 2
|
||||
@@ -205,6 +209,7 @@ def test_parallel_limits_and_interrupted_slots() -> None:
|
||||
store.save_schedule(sched_model)
|
||||
second = [r for r in runs.list_runs() if r.id != first.id][0]
|
||||
runs.save_run(second.model_copy(update={"status": StoredRunStatus.INTERRUPTED}))
|
||||
runs.clear_executing(second.id)
|
||||
sched.poll(t0 + timedelta(minutes=15))
|
||||
assert any(
|
||||
r["kind"] == "skipped-overlap" and "12:15" in str(r["resolved_at"])
|
||||
@@ -287,6 +292,7 @@ def test_fairness_slow_schedule_not_starved(tmp_path: Path) -> None:
|
||||
)
|
||||
for run in runs.list_runs():
|
||||
runs.save_run(run.model_copy(update={"status": StoredRunStatus.COMPLETED}))
|
||||
runs.clear_executing(run.id)
|
||||
sched.poll(t0 + timedelta(seconds=30))
|
||||
assert any(r["kind"] == "admitted" for r in _history(store, "slow"))
|
||||
sched.ownership.release()
|
||||
@@ -390,9 +396,8 @@ def test_record_resumed_stopped_result_is_idempotent_and_attributed(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Live resumed results record exactly once with schedule attribution (B3)."""
|
||||
from wf_api.run_lifecycle import persist_admission
|
||||
|
||||
from tests.scheduling.controlled import fixture_environment
|
||||
from wf_api.run_lifecycle import persist_admission
|
||||
|
||||
sched, store, runs, sources = _harness(tmp_path, script={"*": "interrupt"})
|
||||
t0 = ts(2026, 9, 8, 12, 0)
|
||||
|
||||
@@ -168,7 +168,9 @@ def test_history_pagination_over_resolved_utc(tmp_path: Path) -> None:
|
||||
assert "|" in str(page["next_cursor"])
|
||||
assert len(page["occurrences"]) == 2 # type: ignore[arg-type]
|
||||
second = store.list_occurrences(
|
||||
"a", cursor=page["next_cursor"], limit=2 # type: ignore[arg-type]
|
||||
"a",
|
||||
cursor=page["next_cursor"],
|
||||
limit=2, # type: ignore[arg-type]
|
||||
)
|
||||
assert second["next_cursor"] is None
|
||||
assert len(second["occurrences"]) == 1 # type: ignore[arg-type]
|
||||
|
||||
Reference in New Issue
Block a user