+ self.assertEqual(1, self.alive_monitor_count())
+
+ def test_no_duplication_when_booted_node_listed(self):
+ cloud_node = testutil.cloud_node_mock(2)
+ setup = self.start_node_boot(cloud_node, id_num=2)
+ self.daemon.node_up(setup)
+ self.daemon.update_cloud_nodes([cloud_node]).get(self.TIMEOUT)
+ self.assertEqual(1, self.alive_monitor_count())
+
+ def test_node_counted_after_boot_with_slow_listing(self):
+ # Test that, after we boot a compute node, we assume it exists
+ # even it doesn't appear in the listing (e.g., because of delays
+ # propagating tags).
+ setup = self.start_node_boot()
+ self.daemon.node_up(setup).get(self.TIMEOUT)
+ self.assertEqual(1, self.alive_monitor_count())
+ self.daemon.update_cloud_nodes([]).get(self.TIMEOUT)
+ self.assertEqual(1, self.alive_monitor_count())
+
+ def test_booted_unlisted_node_counted(self):
+ setup = self.start_node_boot(id_num=1)
+ self.daemon.node_up(setup)
+ self.daemon.update_server_wishlist(
+ [testutil.MockSize(1)]).get(self.TIMEOUT)
+ self.stop_proxy(self.daemon)
+ self.assertFalse(self.node_setup.start.called,
+ "daemon did not count booted node toward wishlist")
+
+ def test_booted_node_can_shutdown(self):
+ setup = self.start_node_boot()
+ self.daemon.node_up(setup).get(self.TIMEOUT)
+ self.assertEqual(1, self.alive_monitor_count())
+ monitor = self.monitor_list()[0].proxy()
+ self.daemon.update_server_wishlist([])
+ self.daemon.node_can_shutdown(monitor).get(self.TIMEOUT)
+ self.stop_proxy(self.daemon)
+ self.assertTrue(self.node_shutdown.start.called,
+ "daemon did not shut down booted node on offer")
+
+ def test_booted_node_lifecycle(self):
+ cloud_node = testutil.cloud_node_mock(6)
+ setup = self.start_node_boot(cloud_node, id_num=6)
+ self.daemon.node_up(setup).get(self.TIMEOUT)
+ self.assertEqual(1, self.alive_monitor_count())
+ monitor = self.monitor_list()[0].proxy()
+ self.daemon.update_server_wishlist([])
+ self.daemon.node_can_shutdown(monitor).get(self.TIMEOUT)
+ self.assertTrue(self.node_shutdown.start.called,
+ "daemon did not shut down booted node on offer")
+ shutdown = self.node_shutdown.start().proxy()
+ shutdown.cloud_node.get.return_value = cloud_node
+ self.daemon.node_finished_shutdown(shutdown).get(self.TIMEOUT)
+ self.assertTrue(shutdown.stop.called,
+ "shutdown actor not stopped after finishing")
+ self.assertTrue(monitor.actor_ref.actor_stopped.wait(self.TIMEOUT),
+ "monitor for booted node not stopped after shutdown")
+ self.daemon.update_server_wishlist(
+ [testutil.MockSize(2)]).get(self.TIMEOUT)
+ self.stop_proxy(self.daemon)
+ self.assertTrue(self.node_setup.start.called,
+ "second node not started after booted node stopped")