Пример #1
0
 def test_reboot_booting_server(self, mock_sleep):
     """
     Reboot a server that has status 'booting'
     """
     server = BootingOpenStackServerFactory()
     server.reboot()
     self.assertEqual(server.status, ServerStatus.Booting)
     server.os_server.reboot.assert_not_called()
     mock_sleep.assert_not_called()
Пример #2
0
 def test_reboot_booting_server(self, mock_sleep):
     """
     Reboot a server that has status 'booting'
     """
     server = BootingOpenStackServerFactory()
     server.reboot()
     self.assertEqual(server.status, ServerStatus.Booting)
     server.os_server.reboot.assert_not_called()
     mock_sleep.assert_not_called()
Пример #3
0
 def test_update_status_booting_to_ready(self, mock_is_port_open):
     """
     Update status while the server is booting, when the VM becomes ready
     """
     server = BootingOpenStackServerFactory(os_server_fixture='openstack/api_server_2_active.json')
     self.assertEqual(server.status, ServerStatus.Booting)
     mock_is_port_open.return_value = False
     self.assertIsInstance(server.update_status(), ServerStatus.Booting)
     self.assertEqual(server.status, ServerStatus.Booting)
     mock_is_port_open.return_value = True
     self.assertIsInstance(server.update_status(), ServerStatus.Ready)
     self.assertEqual(server.status, ServerStatus.Ready)
Пример #4
0
 def test_update_status_booting_to_ready(self, mock_is_port_open):
     """
     Update status while the server is booting, when the VM becomes ready
     """
     server = BootingOpenStackServerFactory(os_server_fixture='openstack/api_server_2_active.json')
     self.assertEqual(server.status, ServerStatus.Booting)
     mock_is_port_open.return_value = False
     self.assertIsInstance(server.update_status(), ServerStatus.Booting)
     self.assertEqual(server.status, ServerStatus.Booting)
     mock_is_port_open.return_value = True
     self.assertIsInstance(server.update_status(), ServerStatus.Ready)
     self.assertEqual(server.status, ServerStatus.Ready)
Пример #5
0
    def test_not_mark_active_if_pending(self):
        """
        Test that we when mark_active_on_success=True, the spawn_appserver task will not mark the
        newly provisioned AppServer as active if the OpenStack server is not ready.
        """
        instance = OpenEdXInstanceFactory()
        appserver = make_test_appserver(instance=instance)
        appserver.server = BootingOpenStackServerFactory()
        appserver.save()

        self.mock_spawn_appserver.return_value = appserver.pk
        self.make_appserver_active_patcher.stop()
        self.addCleanup(self.make_appserver_active_patcher.start)

        tasks.spawn_appserver(instance.ref.pk, mark_active_on_success=True)
        self.assertEqual(appserver.is_active, False)