diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index ca56d0aee9b2..14c79ff1edd4 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -2248,7 +2248,7 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self._delete_and_check_allocations(server) - def test_evacuate(self): + def _test_evacuate(self, keep_hypervisor_state): source_hostname = self.compute1.host dest_hostname = self.compute2.host server = self._boot_and_check_allocations( @@ -2284,7 +2284,8 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self.flavor1, server['id'], source_rp_uuid, dest_rp_uuid) # restart the source compute - self.compute1 = self.restart_compute_service(self.compute1) + self.compute1 = self.restart_compute_service( + self.compute1, keep_hypervisor_state=keep_hypervisor_state) self.admin_api.put_service( source_compute_id, {'forced_down': 'false'}) @@ -2302,7 +2303,13 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self._delete_and_check_allocations(server) - def test_evacuate_forced_host(self): + def test_evacuate_instance_kept_on_the_hypervisor(self): + self._test_evacuate(keep_hypervisor_state=True) + + def test_evacuate_clean_hypervisor(self): + self._test_evacuate(keep_hypervisor_state=False) + + def _test_evacuate_forced_host(self, keep_hypervisor_state): """Evacuating a server with a forced host bypasses the scheduler which means conductor has to create the allocations against the destination node. This test recreates the scenarios and asserts @@ -2355,7 +2362,8 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self.flavor1, server['id'], source_rp_uuid, dest_rp_uuid) # restart the source compute - self.compute1 = self.restart_compute_service(self.compute1) + self.compute1 = self.restart_compute_service( + self.compute1, keep_hypervisor_state=keep_hypervisor_state) self.admin_api.put_service( source_compute_id, {'forced_down': 'false'}) @@ -2377,6 +2385,12 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self._delete_and_check_allocations(server) + def test_evacuate_forced_host_instance_kept_on_the_hypervisor(self): + self._test_evacuate_forced_host(keep_hypervisor_state=True) + + def test_evacuate_forced_host_clean_hypervisor(self): + self._test_evacuate_forced_host(keep_hypervisor_state=False) + def test_evacuate_forced_host_v268(self): """Evacuating a server with a forced host was removed in API microversion 2.68. This test ensures that the request is rejected. @@ -2475,7 +2489,7 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self._delete_and_check_allocations(server) - def test_evacuate_claim_on_dest_fails(self): + def _test_evacuate_claim_on_dest_fails(self, keep_hypervisor_state): """Tests that the allocations on the destination node are cleaned up when the rebuild move claim fails due to insufficient resources. """ @@ -2533,7 +2547,8 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): source_rp_uuid) # restart the source compute - self.compute1 = self.restart_compute_service(self.compute1) + self.compute1 = self.restart_compute_service( + self.compute1, keep_hypervisor_state=keep_hypervisor_state) self.admin_api.put_service( source_compute_id, {'forced_down': 'false'}) @@ -2547,7 +2562,14 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self.assertFlavorMatchesAllocation(self.flavor1, server['id'], source_rp_uuid) - def test_evacuate_rebuild_on_dest_fails(self): + def test_evacuate_claim_on_dest_fails_instance_kept_on_the_hypervisor( + self): + self._test_evacuate_claim_on_dest_fails(keep_hypervisor_state=True) + + def test_evacuate_claim_on_dest_fails_clean_hypervisor(self): + self._test_evacuate_claim_on_dest_fails(keep_hypervisor_state=False) + + def _test_evacuate_rebuild_on_dest_fails(self, keep_hypervisor_state): """Tests that the allocations on the destination node are cleaned up automatically when the claim is made but the actual rebuild via the driver fails. @@ -2600,7 +2622,8 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): source_rp_uuid) # restart the source compute - self.compute1 = self.restart_compute_service(self.compute1) + self.compute1 = self.restart_compute_service( + self.compute1, keep_hypervisor_state=keep_hypervisor_state) self.admin_api.put_service( source_compute_id, {'forced_down': 'false'}) @@ -2614,6 +2637,13 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self.assertFlavorMatchesAllocation(self.flavor1, server['id'], source_rp_uuid) + def test_evacuate_rebuild_on_dest_fails_instance_kept_on_the_hypervisor( + self): + self._test_evacuate_rebuild_on_dest_fails(keep_hypervisor_state=True) + + def test_evacuate_rebuild_on_dest_fails_clean_hypervisor(self): + self._test_evacuate_rebuild_on_dest_fails(keep_hypervisor_state=False) + def _boot_then_shelve_and_check_allocations(self, hostname, rp_uuid): # avoid automatic shelve offloading self.flags(shelved_offload_time=-1) @@ -5138,7 +5168,7 @@ class ServerMovingTestsWithNestedResourceRequests( self._delete_and_check_allocations(server) - def test_evacuate_forced_host(self): + def _test_evacuate_forced_host(self, keep_hypervisor_state): # Nova intentionally does not support force evacuating server # with nested allocations. @@ -5196,7 +5226,8 @@ class ServerMovingTestsWithNestedResourceRequests( source_rp_uuid) # restart the source compute - self.compute1 = self.restart_compute_service(self.compute1) + self.compute1 = self.restart_compute_service( + self.compute1, keep_hypervisor_state=keep_hypervisor_state) self.admin_api.put_service( source_compute_id, {'forced_down': 'false'})