def restart_compute_service(self, compute): """Restart a compute service in a realistic way. :param:compute: the nova-compute service to be restarted """ # NOTE(gibi): The service interface cannot be used to simulate a real # service restart as the manager object will not be recreated after a # service.stop() and service.start() therefore the manager state will # survive. For example the resource tracker will not be recreated after # a stop start. The service.kill() call cannot help as it deletes # the service from the DB which is unrealistic and causes that some # operation that refers to the killed host (e.g. evacuate) fails. # So this helper method tries to simulate a better compute service # restart by cleaning up some of the internal state of the compute # manager. host, driver = compute.manager.host, compute.manager.driver compute.stop() compute.manager.rt = resource_tracker.ResourceTracker(host, driver) compute.start()
def setUp(self): super(IronicResourceTrackerTest, self).setUp() self.flags(auth_strategy='noauth2', group='api') self.flags( reserved_host_memory_mb=0, cpu_allocation_ratio=1.0, ram_allocation_ratio=1.0, disk_allocation_ratio=1.0, ) self.ctx = context.RequestContext('user', 'project') self.app = lambda: deploy.loadapp(CONF) self.report_client = test_report_client.NoAuthReportClient() driver = mock.MagicMock(autospec='nova.virt.driver.ComputeDriver') driver.node_is_available.return_value = True self.driver_mock = driver self.rt = resource_tracker.ResourceTracker(COMPUTE_HOST, driver) self.rt.scheduler_client.reportclient = self.report_client self.url = 'http://localhost/placement' self.create_fixtures()