Esempio n. 1
0
 def test_reboot_ready_server(self, mock_sleep):
     """
     Reboot a server that has status 'ready'
     """
     server = ReadyOpenStackServerFactory()
     server.reboot()
     self.assertEqual(server.status, ServerStatus.Booting)
     server.os_server.reboot.assert_called_once_with(reboot_type='SOFT')
     mock_sleep.assert_called_once_with(30)
Esempio n. 2
0
 def test_reboot_ready_server(self, mock_sleep):
     """
     Reboot a server that has status 'ready'
     """
     server = ReadyOpenStackServerFactory()
     server.reboot()
     self.assertEqual(server.status, ServerStatus.Booting)
     server.os_server.reboot.assert_called_once_with(reboot_type='SOFT')
     mock_sleep.assert_called_once_with(30)
Esempio n. 3
0
 def test_update_status_ready_to_booting(self, _mock_sleep, mock_is_port_open):
     """
     Update status when the server is rebooted
     """
     server = ReadyOpenStackServerFactory(os_server_fixture='openstack/api_server_2_active.json')
     # If server is in Status.Booting, update_status calls is_port_open
     # to determine if server should transition to Status.Ready.
     # When using a fixture for server.os_server, is_port_open will eventually return False,
     # but only after a delay of about two minutes.
     # So we mock out is_port_open here to speed up testing:
     mock_is_port_open.return_value = False
     self.assertEqual(server.status, ServerStatus.Ready)
     self.assertIsInstance(server.update_status(), ServerStatus.Ready)
     server.reboot()
     self.assertEqual(server.status, ServerStatus.Booting)
     self.assertIsInstance(server.update_status(), ServerStatus.Booting)
     self.assertEqual(server.status, ServerStatus.Booting)
Esempio n. 4
0
 def test_update_status_ready_to_booting(self, _mock_sleep, mock_is_port_open):
     """
     Update status when the server is rebooted
     """
     server = ReadyOpenStackServerFactory(os_server_fixture='openstack/api_server_2_active.json')
     # If server is in Status.Booting, update_status calls is_port_open
     # to determine if server should transition to Status.Ready.
     # When using a fixture for server.os_server, is_port_open will eventually return False,
     # but only after a delay of about two minutes.
     # So we mock out is_port_open here to speed up testing:
     mock_is_port_open.return_value = False
     self.assertEqual(server.status, ServerStatus.Ready)
     self.assertIsInstance(server.update_status(), ServerStatus.Ready)
     server.reboot()
     self.assertEqual(server.status, ServerStatus.Booting)
     self.assertIsInstance(server.update_status(), ServerStatus.Booting)
     self.assertEqual(server.status, ServerStatus.Booting)