Release: dev → main (first public release) #258
@@ -89,22 +89,47 @@ async def test_the_other_lanes_ship_at_one(client, no_live_workers):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_cap_is_stored_even_when_it_cannot_be_pushed(
|
||||
async def test_raising_a_cap_stores_it_and_pushes_nothing(
|
||||
client, db, no_live_workers,
|
||||
):
|
||||
"""Nothing is answering, so the live push fails. That is NOT a failed
|
||||
setting: the value is saved and the sizing pass carries it within a
|
||||
minute (lesson #4202 — a live change that does not survive, with nothing
|
||||
saying so)."""
|
||||
"""A cap is PERMISSION, not a request. Raising it must not grow the pool
|
||||
here — that would put workers on a lane with nothing to do — so there is
|
||||
nothing to push and `applied` is vacuously true.
|
||||
|
||||
This asserted `applied is False` until run 7367, carried over from when
|
||||
the number meant "run this many". The code was right and the test was
|
||||
describing the control it replaced.
|
||||
"""
|
||||
resp = await client.post("/api/system/workers/worker", json={"slots_cap": 3})
|
||||
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
assert body["slots_cap"] == 3
|
||||
assert body["applied"] is True
|
||||
assert (await _lane_row(db, "worker")).slots_cap == 3
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_turning_a_lane_off_is_stored_even_when_it_cannot_be_pushed(
|
||||
client, db, no_live_workers,
|
||||
):
|
||||
"""The direction that DOES push. Consumers follow the cap immediately in
|
||||
both directions — off must take effect when it is asked for — so with
|
||||
nothing answering, the push fails.
|
||||
|
||||
That is NOT a failed setting: the value is saved and the sizing pass
|
||||
carries it within a minute (lesson #4202 — a live change that does not
|
||||
survive, with nothing saying so). The UI says "saved, not yet live"
|
||||
rather than "that didn't work", which is the distinction `applied`
|
||||
exists to carry.
|
||||
"""
|
||||
resp = await client.post("/api/system/workers/worker", json={"slots_cap": 0})
|
||||
|
||||
assert resp.status_code == 200
|
||||
body = await resp.get_json()
|
||||
assert body["applied"] is False
|
||||
assert "not running" in body["apply_error"]
|
||||
|
||||
assert (await _lane_row(db, "worker")).slots_cap == 3
|
||||
assert (await _lane_row(db, "worker")).slots_cap == 0
|
||||
|
||||
|
||||
# --- the cap is the switch ---------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user