Skip to content

Commit 15e8359

Browse files
Add unit test to cover max_count > 0 in _is_node_in_replacement_valid
1 parent ecaffb8 commit 15e8359

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

tests/slurm_plugin/test_clustermgtd.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,43 +2648,61 @@ def initialize_console_logger_mock(mocker):
26482648

26492649

26502650
@pytest.mark.parametrize(
2651-
"current_replacing_nodes, node, instance, current_time, expected_result",
2651+
"current_replacing_nodes, node, instance, current_time, max_count, expected_result",
26522652
[
26532653
(
26542654
set(),
26552655
StaticNode("queue1-st-c5xlarge-1", "ip-1", "hostname", "IDLE+CLOUD", "queue1"),
26562656
EC2Instance("id-1", "ip-1", "hostname", {"ip-1"}, datetime(2020, 1, 1, 0, 0, 0)),
26572657
datetime(2020, 1, 1, 0, 0, 29),
2658+
0,
26582659
False,
26592660
),
26602661
(
26612662
{"queue1-st-c5xlarge-1"},
26622663
StaticNode("queue1-st-c5xlarge-1", "ip-1", "hostname", "IDLE+CLOUD", "queue1"),
26632664
None,
26642665
datetime(2020, 1, 1, 0, 0, 29),
2666+
0,
26652667
False,
26662668
),
26672669
(
26682670
{"queue1-st-c5xlarge-1"},
26692671
StaticNode("queue1-st-c5xlarge-1", "ip-1", "hostname", "DOWN+CLOUD", "queue1"),
26702672
EC2Instance("id-1", "ip-1", "hostname", {"ip-1"}, datetime(2020, 1, 1, 0, 0, 0)),
26712673
datetime(2020, 1, 1, 0, 0, 29),
2674+
0,
26722675
True,
26732676
),
26742677
(
26752678
{"queue1-st-c5xlarge-1"},
26762679
StaticNode("queue1-st-c5xlarge-1", "ip-1", "hostname", "IDLE+CLOUD", "queue1"),
26772680
EC2Instance("id-1", "ip-1", "hostname", {"ip-1"}, datetime(2020, 1, 1, 0, 0, 0)),
26782681
datetime(2020, 1, 1, 0, 0, 30),
2682+
0,
26792683
False,
26802684
),
2685+
(
2686+
{"queue1-st-c5xlarge-1"},
2687+
StaticNode("queue1-st-c5xlarge-1", "ip-1", "hostname", "IDLE+CLOUD", "queue1"),
2688+
None,
2689+
datetime(2020, 1, 1, 0, 0, 30),
2690+
1,
2691+
True,
2692+
),
2693+
],
2694+
ids=[
2695+
"not_in_replacement",
2696+
"no-backing-instance",
2697+
"in_replacement",
2698+
"timeout",
2699+
"no-backing-instance-with-max-count",
26812700
],
2682-
ids=["not_in_replacement", "no-backing-instance", "in_replacement", "timeout"],
26832701
)
26842702
@pytest.mark.usefixtures(
26852703
"initialize_instance_manager_mock", "initialize_executor_mock", "initialize_console_logger_mock"
26862704
)
2687-
def test_is_node_being_replaced(current_replacing_nodes, node, instance, current_time, expected_result):
2705+
def test_is_node_being_replaced(current_replacing_nodes, node, instance, current_time, max_count, expected_result):
26882706
mock_sync_config = SimpleNamespace(
26892707
node_replacement_timeout=30,
26902708
insufficient_capacity_timeout=3,
@@ -2693,7 +2711,7 @@ def test_is_node_being_replaced(current_replacing_nodes, node, instance, current
26932711
region="region",
26942712
boto3_config=None,
26952713
fleet_config={},
2696-
ec2_instance_missing_max_count=0,
2714+
ec2_instance_missing_max_count=max_count,
26972715
)
26982716
cluster_manager = ClusterManager(mock_sync_config)
26992717
cluster_manager._current_time = current_time

0 commit comments

Comments
 (0)