@@ -264,3 +264,32 @@ def test_unavailable_explicit_target_is_never_rerouted(tmp_path) -> None:
|
||||
task = pool.store.get_task(task_id)
|
||||
assert task is not None
|
||||
assert task.status == "queued"
|
||||
|
||||
|
||||
def test_host_active_task_policy_keeps_excess_tasks_queued(tmp_path) -> None:
|
||||
from datetime import UTC, datetime
|
||||
|
||||
pool = _pool_with_devices(
|
||||
tmp_path,
|
||||
_device("device-a"),
|
||||
_device("device-b"),
|
||||
host_id="host-a",
|
||||
)
|
||||
pool.store.upsert_host_governance_policy(
|
||||
host_id="host-a",
|
||||
self_submission_enabled=True,
|
||||
max_active_tasks=1,
|
||||
daily_token_budget=None,
|
||||
updated_at=datetime.now(UTC),
|
||||
)
|
||||
scheduler = TaskScheduler(pool, pool.store, _config())
|
||||
first_id = scheduler.submit(goal="first")
|
||||
second_id = scheduler.submit(goal="second")
|
||||
|
||||
assignments = scheduler.assign()
|
||||
|
||||
assert [assignment.task_id for assignment in assignments] == [first_id]
|
||||
assert pool.store.count_active_tasks_for_host("host-a") == 1
|
||||
second = pool.store.get_task(second_id)
|
||||
assert second is not None
|
||||
assert second.status == "queued"
|
||||
|
||||
Reference in New Issue
Block a user