@@ -158,7 +158,7 @@ def test_filter_for_launchable_flows(db, flow_weights, flow_hosts):
158158 running_count , planned_count , weight_planned , weight_running = count_flows .fn (db , flow_weights , flow_hosts )
159159 max_weight_running = 30
160160 ready_to_launch_weight , max_flows_to_launch = determine_launchable_flow_count (
161- weight_planned , weight_running , max_weight_running , math .inf , 10 )
161+ weight_planned , weight_running , max_weight_running , math .inf , 10 , 100 , running_count )
162162 assert ready_to_launch_weight == 5
163163 assert max_flows_to_launch == 10
164164
@@ -168,7 +168,7 @@ def test_filter_for_launchable_flows_with_max_of_1(db, flow_weights, flow_batch_
168168 running_count , planned_count , weight_planned , weight_running = count_flows .fn (db , flow_weights , flow_hosts )
169169 max_weight_running = 1
170170 ready_to_launch_weight , max_flows_to_launch = determine_launchable_flow_count (
171- weight_planned , weight_running , max_weight_running , math .inf , 10 )
171+ weight_planned , weight_running , max_weight_running , math .inf , 10 , 100 , running_count )
172172 assert ready_to_launch_weight == 1
173173 assert max_flows_to_launch == 10
174174 flows , tags_by_flow , selected_weight , number_of_flows , count_per_type = gather_planned_flows .fn (
@@ -184,16 +184,26 @@ def test_filter_for_launchable_flows_with_max_of_0(db, flow_weights, flow_hosts)
184184 running_count , planned_count , weight_planned , weight_running = count_flows .fn (db , flow_weights , flow_hosts )
185185 max_weight_running = 0
186186 ready_to_launch_weight , max_flows_to_launch = determine_launchable_flow_count (
187- weight_planned , weight_running , max_weight_running , math .inf , 0 )
187+ weight_planned , weight_running , max_weight_running , math .inf , 0 , 100 , running_count )
188188 assert ready_to_launch_weight == 0
189189 assert max_flows_to_launch == 0
190190
191191
192+ def test_filter_for_launchable_flows_cap_by_number (db , flow_weights , flow_hosts ):
193+ with prefect_test_harness (), disable_run_logger ():
194+ running_count , planned_count , weight_planned , weight_running = count_flows .fn (db , flow_weights , flow_hosts )
195+ max_weight_running = 100
196+ ready_to_launch_weight , max_flows_to_launch = determine_launchable_flow_count (
197+ weight_planned , weight_running , max_weight_running , math .inf , 100 , 1 , running_count )
198+ assert ready_to_launch_weight > 0
199+ assert max_flows_to_launch == 1
200+
201+
192202def test_filter_for_launchable_flows_with_empty_db (db_empty , flow_weights , flow_hosts ):
193203 with prefect_test_harness (), disable_run_logger ():
194204 running_count , planned_count , weight_planned , weight_running = count_flows .fn (db_empty , flow_weights , flow_hosts )
195205 max_weight_running = 30
196206 ready_to_launch_weight , max_flows_to_launch = determine_launchable_flow_count (
197- weight_planned , weight_running , max_weight_running , math .inf , 20 )
207+ weight_planned , weight_running , max_weight_running , math .inf , 20 , 100 , running_count )
198208 assert ready_to_launch_weight == 0
199209 assert max_flows_to_launch == 20
0 commit comments