account for in-flight capacity in launch scheduling
This commit is contained in:
parent
57b4df2a17
commit
d8afde8b18
2 changed files with 64 additions and 3 deletions
|
|
@ -173,6 +173,39 @@ def test_launch_respects_max_slots():
|
|||
assert len(launching) == 0
|
||||
|
||||
|
||||
def test_launch_does_not_overprovision_when_in_flight_capacity_exists():
|
||||
db, runtime, config, clock, metrics = _make_env(slot_count=4, max_slots=4)
|
||||
|
||||
db.create_reservation("x86_64-linux", "test1", None, 1200)
|
||||
db.create_reservation("x86_64-linux", "test2", None, 1200)
|
||||
|
||||
# Tick 1 launches two slots for two pending reservations.
|
||||
scheduling_tick(db, runtime, config, clock, metrics)
|
||||
launching_after_first_tick = db.list_slots(SlotState.LAUNCHING)
|
||||
assert len(launching_after_first_tick) == 2
|
||||
|
||||
# Tick 2 sees in-flight capacity and should not launch more.
|
||||
scheduling_tick(db, runtime, config, clock, metrics)
|
||||
launching_after_second_tick = db.list_slots(SlotState.LAUNCHING)
|
||||
assert len(launching_after_second_tick) == 2
|
||||
assert len(runtime.list_managed_instances()) == 2
|
||||
|
||||
|
||||
def test_in_flight_capacity_uses_max_leases_per_slot():
|
||||
db, runtime, config, clock, metrics = _make_env(slot_count=3, max_slots=3, max_leases=2)
|
||||
db.create_reservation("x86_64-linux", "test1", None, 1200)
|
||||
db.create_reservation("x86_64-linux", "test2", None, 1200)
|
||||
|
||||
# One in-flight slot should represent capacity for two reservations.
|
||||
db.update_slot_state("slot001", SlotState.LAUNCHING, instance_id="i-launching")
|
||||
|
||||
scheduling_tick(db, runtime, config, clock, metrics)
|
||||
|
||||
launching = db.list_slots(SlotState.LAUNCHING)
|
||||
assert len(launching) == 1
|
||||
assert len(runtime.list_managed_instances()) == 0
|
||||
|
||||
|
||||
def test_min_slots_maintained():
|
||||
db, runtime, config, clock, metrics = _make_env(min_slots=1)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue