@@ -1314,14 +1314,13 @@ def test_maintain_nodes(
13141314 # Run test
13151315 cluster_manager ._maintain_nodes (partitions , {})
13161316 # Check function calls
1317- active_nodes_sorted = sorted (active_nodes , key = str )
1318- mock_update_replacement .assert_called_with (active_nodes_sorted )
1317+ mock_update_replacement .assert_called_with (active_nodes )
13191318 mock_handle_dynamic .assert_called_with (expected_unhealthy_dynamic_nodes )
13201319 mock_handle_static .assert_called_with (expected_unhealthy_static_nodes )
1321- mock_handle_powering_down_nodes .assert_called_with (active_nodes_sorted )
1322- mock_handle_failed_health_check_nodes_in_replacement .assert_called_with (active_nodes_sorted )
1320+ mock_handle_powering_down_nodes .assert_called_with (active_nodes )
1321+ mock_handle_failed_health_check_nodes_in_replacement .assert_called_with (active_nodes )
13231322 if _is_protected_mode_enabled :
1324- mock_handle_protected_mode_process .assert_called_with (active_nodes_sorted , partitions )
1323+ mock_handle_protected_mode_process .assert_called_with (active_nodes , partitions )
13251324 else :
13261325 mock_handle_protected_mode_process .assert_not_called ()
13271326
@@ -3795,21 +3794,6 @@ def test_find_unhealthy_slurm_nodes(
37953794 ],
37963795)
37973796def test_find_active_nodes (partitions_name_map , expected_nodelist ):
3798- """
3799- Unit test for the `ClusterManager._find_active_nodes()` method.
3800-
3801- Some context about the way this test is implemented:
3802- - `ClusterManager._find_active_nodes()` may be implemented to return different types of iterables.
3803- This test was implemented together with a fix that changed the return type from a list to a set,
3804- and it was desirable to have the test compatible with both return types.
3805- - The implementation that returned a list caused a duplication of node entities in the returned iterable
3806- in case the same node belonged to multiple Slurm partitions (via a customization of the Slurm configuration).
3807- - Due to the way we implement the `__hash__()` dunder method for the SlurmNode class, two different
3808- SlurmNode objects with the same node name are squashed into the same entity in a set. Therefore
3809- we cannot use `set(expected_nodelist)` when trying to test the duplication of the node entities
3810- in the iterable returned by `ClusterManager._find_active_nodes()`.
3811- - Sets are unordered, so when transforming them into lists we have to sort them to make them comparable with
3812- the `expected_nodelist`.
3813- """
3814- result_nodelist = sorted (list (ClusterManager ._find_active_nodes (partitions_name_map )), key = str )
3815- assert_that (result_nodelist ).is_equal_to (sorted (expected_nodelist , key = str ))
3797+ """Unit test for the `ClusterManager._find_active_nodes()` method."""
3798+ result_nodelist = ClusterManager ._find_active_nodes (partitions_name_map )
3799+ assert_that (result_nodelist ).is_equal_to (expected_nodelist )
0 commit comments