X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f16505d89d60d3bd5abc04762712f4ddf78e39fe..19ae770973482257117fe8ded5619c3018c4b60f:/services/nodemanager/tests/test_daemon.py diff --git a/services/nodemanager/tests/test_daemon.py b/services/nodemanager/tests/test_daemon.py index 2510c79470..554fb88b47 100644 --- a/services/nodemanager/tests/test_daemon.py +++ b/services/nodemanager/tests/test_daemon.py @@ -26,6 +26,7 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, cloud_size=get_cloud_size, actor_ref=mock_actor) mock_actor.proxy.return_value = mock_proxy + mock_actor.tell_proxy.return_value = mock_proxy self.last_setup = mock_proxy return mock_actor @@ -208,6 +209,7 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, mock_shutdown = self.node_shutdown.start(node_monitor=mock_node_monitor) self.daemon.shutdowns.get()[cloud_nodes[1].id] = mock_shutdown.proxy() + self.daemon.sizes_booting_shutdown.get()[cloud_nodes[1].id] = size self.assertEqual(2, self.alive_monitor_count()) for mon_ref in self.monitor_list(): @@ -613,6 +615,9 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, (testutil.MockSize(2), {"cores":2})] self.make_daemon(want_sizes=[small, small, small, big], avail_sizes=avail_sizes, max_nodes=4) + + # the daemon runs in another thread, so we need to wait and see + # if it does all the work we're expecting it to do before stopping it. self.busywait(lambda: self.node_setup.start.call_count == 4) booting = self.daemon.booting.get(self.TIMEOUT) self.stop_proxy(self.daemon) @@ -630,13 +635,15 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, (testutil.MockSize(2), {"cores":2})] self.make_daemon(want_sizes=[small, small, small, big], avail_sizes=avail_sizes, max_nodes=3) + + # the daemon runs in another thread, so we need to wait and see + # if it does all the work we're expecting it to do before stopping it. self.busywait(lambda: self.node_setup.start.call_count == 3) booting = self.daemon.booting.get(self.TIMEOUT) self.stop_proxy(self.daemon) sizecounts = {a[0].id: 0 for a in avail_sizes} for b in booting.itervalues(): sizecounts[b.cloud_size.get().id] += 1 - logging.info(sizecounts) self.assertEqual(2, sizecounts[small.id]) self.assertEqual(1, sizecounts[big.id]) @@ -692,15 +699,21 @@ class NodeManagerDaemonActorTestCase(testutil.ActorTestMixin, avail_sizes=avail_sizes, max_nodes=4, max_total_price=4) + # the daemon runs in another thread, so we need to wait and see + # if it does all the work we're expecting it to do before stopping it. self.busywait(lambda: self.node_setup.start.call_count == 3) booting = self.daemon.booting.get() self.stop_proxy(self.daemon) - self.assertEqual(3, self.node_setup.start.call_count) + sizecounts = {a[0].id: 0 for a in avail_sizes} for b in booting.itervalues(): sizecounts[b.cloud_size.get().id] += 1 logging.info(sizecounts) - # The way the update_server_wishlist() works effectively results in a - # round-robin creation of one node of each size in the wishlist + + # Booting 3 small nodes and not booting a big node would also partially + # satisfy the wishlist and come in under the price cap, however the way + # the update_server_wishlist() currently works effectively results in a + # round-robin creation of one node of each size in the wishlist, so + # test for that. self.assertEqual(2, sizecounts[small.id]) self.assertEqual(1, sizecounts[big.id])