예제 #1
0
    def test_instance_failover(self):
        """Test masakari managed guest migration."""
        # Launch guest
        self.assertTrue(
            zaza.openstack.configure.hacluster.check_all_nodes_online(
                'masakari'))
        vm_name = 'zaza-test-instance-failover'
        self.ensure_guest(vm_name)

        # Locate hypervisor hosting guest and shut it down
        current_hypervisor, unit_name = self.get_guests_compute_info(vm_name)
        zaza.openstack.configure.masakari.simulate_compute_host_failure(
            unit_name, model_name=self.model_name)

        # Wait for instance move
        logging.info('Waiting for guest to move away from {}'.format(
            current_hypervisor))
        # wait_for_server_migration will throw an exception if migration fails
        openstack_utils.wait_for_server_migration(self.nova_client, vm_name,
                                                  current_hypervisor)

        # Bring things back
        zaza.openstack.configure.masakari.simulate_compute_host_recovery(
            unit_name, model_name=self.model_name)
        openstack_utils.enable_all_nova_services(self.nova_client)
        zaza.openstack.configure.masakari.enable_hosts()
예제 #2
0
 def tearDown(cls):
     """Bring hypervisors and services back up."""
     logging.info('Running teardown')
     for unit in zaza.model.get_units('nova-compute',
                                      model_name=cls.model_name):
         zaza.openstack.configure.masakari.simulate_compute_host_recovery(
             unit.entity_id, model_name=cls.model_name)
     openstack_utils.enable_all_nova_services(cls.nova_client)
     zaza.openstack.configure.masakari.enable_hosts()
예제 #3
0
 def test_enable_all_nova_services(self):
     novaclient = mock.MagicMock()
     svc_mock1 = mock.MagicMock()
     svc_mock1.status = 'disabled'
     svc_mock1.binary = 'nova-compute'
     svc_mock1.host = 'juju-bb659c-zaza-ad7c662d7f1d-13'
     svc_mock2 = mock.MagicMock()
     svc_mock2.status = 'enabled'
     svc_mock2.binary = 'nova-compute'
     svc_mock2.host = 'juju-bb659c-zaza-ad7c662d7f1d-14'
     svc_mock3 = mock.MagicMock()
     svc_mock3.status = 'disabled'
     svc_mock3.binary = 'nova-compute'
     svc_mock3.host = 'juju-bb659c-zaza-ad7c662d7f1d-15'
     novaclient.services.list.return_value = [
         svc_mock1, svc_mock2, svc_mock3
     ]
     openstack_utils.enable_all_nova_services(novaclient)
     expected_calls = [
         mock.call('juju-bb659c-zaza-ad7c662d7f1d-13', 'nova-compute'),
         mock.call('juju-bb659c-zaza-ad7c662d7f1d-15', 'nova-compute')
     ]
     novaclient.services.enable.assert_has_calls(expected_calls)