X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4c5455bc957b4de90eac9df0c29e9874ec6bd143..b25f2bdceae4750c8c803853874227dc2d175767:/services/nodemanager/tests/test_daemon.py diff --git a/services/nodemanager/tests/test_daemon.py b/services/nodemanager/tests/test_daemon.py index d6820803a6..ebe7408e70 100644 --- a/services/nodemanager/tests/test_daemon.py +++ b/services/nodemanager/tests/test_daemon.py @@ -193,6 +193,39 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, want_sizes=[testutil.MockSize(1)]) self.busywait(lambda: not self.node_setup.start.called) + def test_select_stale_node_records_with_slot_numbers_first(self): + """ + Stale node records with slot_number assigned can exist when + clean_arvados_node() isn't executed after a node shutdown, for + various reasons. + NodeManagerDaemonActor should use these stale node records first, so + that they don't accumulate unused, reducing the slots available. + """ + size = testutil.MockSize(1) + a_long_time_ago = '1970-01-01T01:02:03.04050607Z' + arvados_nodes = [] + for n in range(9): + # Add several stale node records without slot_number assigned + arvados_nodes.append( + testutil.arvados_node_mock( + n+1, + slot_number=None, + modified_at=a_long_time_ago)) + # Add one record with stale_node assigned, it should be the + # first one selected + arv_node = testutil.arvados_node_mock( + 123, + modified_at=a_long_time_ago) + arvados_nodes.append(arv_node) + cloud_node = testutil.cloud_node_mock(125, size=size) + self.make_daemon(cloud_nodes=[cloud_node], + arvados_nodes=arvados_nodes) + arvados_nodes_tracker = self.daemon.arvados_nodes.get() + # Here, find_stale_node() should return the node record with + # the slot_number assigned. + self.assertEqual(arv_node, + arvados_nodes_tracker.find_stale_node(3601)) + def test_dont_count_missing_as_busy(self): size = testutil.MockSize(1) self.make_daemon(cloud_nodes=[testutil.cloud_node_mock(1, size=size),