From bda4ae3884cb11d0cc9b510e5cf7c46b46d6d727 Mon Sep 17 00:00:00 2001 From: Takashi NATSUME Date: Fri, 15 Feb 2019 00:27:42 +0900 Subject: [PATCH] Remove duplicate cleanup in functional tests It is not necessary to call the following statement multiple times in some functional tests. self.addCleanup(fake.restore_nodes) So remove duplicate calls in the tests. TrivalFix Change-Id: Iaae6fc4a66145576f4a4fc1cea452ef6acbadb15 --- nova/tests/functional/regressions/test_bug_1671648.py | 1 - nova/tests/functional/regressions/test_bug_1702454.py | 2 -- nova/tests/functional/regressions/test_bug_1718455.py | 1 - nova/tests/functional/regressions/test_bug_1718512.py | 2 +- nova/tests/functional/regressions/test_bug_1719730.py | 1 - nova/tests/functional/regressions/test_bug_1735407.py | 2 -- nova/tests/functional/regressions/test_bug_1741307.py | 2 +- nova/tests/functional/regressions/test_bug_1746483.py | 2 +- nova/tests/functional/regressions/test_bug_1764883.py | 1 - nova/tests/functional/regressions/test_bug_1781710.py | 1 - nova/tests/functional/regressions/test_bug_1784353.py | 1 - nova/tests/functional/regressions/test_bug_1797580.py | 2 +- nova/tests/functional/test_server_group.py | 6 ++---- nova/tests/functional/test_servers.py | 4 ++-- 14 files changed, 8 insertions(+), 20 deletions(-) diff --git a/nova/tests/functional/regressions/test_bug_1671648.py b/nova/tests/functional/regressions/test_bug_1671648.py index a09b2b4168..ce1ffb500a 100644 --- a/nova/tests/functional/regressions/test_bug_1671648.py +++ b/nova/tests/functional/regressions/test_bug_1671648.py @@ -77,7 +77,6 @@ class TestRetryBetweenComputeNodeBuilds(test.TestCase): self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host2') self.scheduler_service = self.start_service('scheduler') diff --git a/nova/tests/functional/regressions/test_bug_1702454.py b/nova/tests/functional/regressions/test_bug_1702454.py index c4d048a498..6724a9a4a6 100644 --- a/nova/tests/functional/regressions/test_bug_1702454.py +++ b/nova/tests/functional/regressions/test_bug_1702454.py @@ -110,10 +110,8 @@ class SchedulerOnlyChecksTargetTest(test.TestCase, self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host2') fake.set_nodes(['host3']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host3') self.useFixture(cast_as_call.CastAsCall(self)) diff --git a/nova/tests/functional/regressions/test_bug_1718455.py b/nova/tests/functional/regressions/test_bug_1718455.py index 51306bd3d9..2f5310ecc2 100644 --- a/nova/tests/functional/regressions/test_bug_1718455.py +++ b/nova/tests/functional/regressions/test_bug_1718455.py @@ -71,7 +71,6 @@ class TestLiveMigrateOneOfConcurrentlyCreatedInstances( self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host2') fake_network.set_stub_network_methods(self) diff --git a/nova/tests/functional/regressions/test_bug_1718512.py b/nova/tests/functional/regressions/test_bug_1718512.py index 8c1799151b..9786f1b71c 100644 --- a/nova/tests/functional/regressions/test_bug_1718512.py +++ b/nova/tests/functional/regressions/test_bug_1718512.py @@ -86,9 +86,9 @@ class TestRequestSpecRetryReschedule(test.TestCase, self.start_service('scheduler') # Let's now start three compute nodes as we said above. + self.addCleanup(fake.restore_nodes) for host in ['host1', 'host2', 'host3']: fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host) def _stub_resize_failure(self, failed_host): diff --git a/nova/tests/functional/regressions/test_bug_1719730.py b/nova/tests/functional/regressions/test_bug_1719730.py index 188e952f78..46e05c8466 100644 --- a/nova/tests/functional/regressions/test_bug_1719730.py +++ b/nova/tests/functional/regressions/test_bug_1719730.py @@ -69,7 +69,6 @@ class TestRescheduleWithServerGroup(test.TestCase, self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host2') self.image_id = self.api.get_images()[0]['id'] diff --git a/nova/tests/functional/regressions/test_bug_1735407.py b/nova/tests/functional/regressions/test_bug_1735407.py index 446254fa36..657c0a8f1f 100644 --- a/nova/tests/functional/regressions/test_bug_1735407.py +++ b/nova/tests/functional/regressions/test_bug_1735407.py @@ -65,7 +65,6 @@ class TestParallelEvacuationWithServerGroup( self.addCleanup(fake.restore_nodes) self.compute1 = self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.compute2 = self.start_service('compute', host='host2') self.image_id = self.api.get_images()[0]['id'] @@ -126,7 +125,6 @@ class TestParallelEvacuationWithServerGroup( # start a third compute to have place for one of the instances fake.set_nodes(['host3']) - self.addCleanup(fake.restore_nodes) self.compute3 = self.start_service('compute', host='host3') # evacuate both instances diff --git a/nova/tests/functional/regressions/test_bug_1741307.py b/nova/tests/functional/regressions/test_bug_1741307.py index c8824f2317..2c8c1cc178 100644 --- a/nova/tests/functional/regressions/test_bug_1741307.py +++ b/nova/tests/functional/regressions/test_bug_1741307.py @@ -63,9 +63,9 @@ class TestResizeWithNoAllocationScheduler( self.start_service('conductor') # Create two compute nodes/services. + self.addCleanup(fake.restore_nodes) for host in ('host1', 'host2'): fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host) scheduler_service = self.start_service('scheduler') diff --git a/nova/tests/functional/regressions/test_bug_1746483.py b/nova/tests/functional/regressions/test_bug_1746483.py index 939ee773bf..34936d6e3f 100644 --- a/nova/tests/functional/regressions/test_bug_1746483.py +++ b/nova/tests/functional/regressions/test_bug_1746483.py @@ -67,9 +67,9 @@ class TestBootFromVolumeIsolatedHostsFilter( # Create two compute nodes/services so we can restrict the image # we'll use to one of the hosts. + self.addCleanup(fake.restore_nodes) for host in ('host1', 'host2'): fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host) def test_boot_from_volume_with_isolated_image(self): diff --git a/nova/tests/functional/regressions/test_bug_1764883.py b/nova/tests/functional/regressions/test_bug_1764883.py index 1bbf58776f..d3eab3f257 100644 --- a/nova/tests/functional/regressions/test_bug_1764883.py +++ b/nova/tests/functional/regressions/test_bug_1764883.py @@ -68,7 +68,6 @@ class TestEvacuationWithSourceReturningDuringRebuild( self.computes['host1'] = self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.computes['host2'] = self.start_service('compute', host='host2') self.image_id = self.api.get_images()[0]['id'] diff --git a/nova/tests/functional/regressions/test_bug_1781710.py b/nova/tests/functional/regressions/test_bug_1781710.py index 595eb9e544..e29e88d856 100644 --- a/nova/tests/functional/regressions/test_bug_1781710.py +++ b/nova/tests/functional/regressions/test_bug_1781710.py @@ -81,7 +81,6 @@ class AntiAffinityMultiCreateRequest(test.TestCase, self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host2') def test_anti_affinity_multi_create(self): diff --git a/nova/tests/functional/regressions/test_bug_1784353.py b/nova/tests/functional/regressions/test_bug_1784353.py index 3bcb6e3b2c..04c1cf0a83 100644 --- a/nova/tests/functional/regressions/test_bug_1784353.py +++ b/nova/tests/functional/regressions/test_bug_1784353.py @@ -60,7 +60,6 @@ class TestRescheduleWithVolumesAttached( self.host1 = self.start_service('compute', host='host1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.host2 = self.start_service('compute', host='host2') self.image_id = self.api.get_images()[0]['id'] diff --git a/nova/tests/functional/regressions/test_bug_1797580.py b/nova/tests/functional/regressions/test_bug_1797580.py index 8a6cf173e1..bbe3bb8183 100644 --- a/nova/tests/functional/regressions/test_bug_1797580.py +++ b/nova/tests/functional/regressions/test_bug_1797580.py @@ -60,9 +60,9 @@ class ColdMigrateTargetHostThenLiveMigrateTest( self.start_service('conductor') self.start_service('scheduler') + self.addCleanup(fake.restore_nodes) for host in ('host1', 'host2'): fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host) def test_cold_migrate_target_host_then_live_migrate(self): diff --git a/nova/tests/functional/test_server_group.py b/nova/tests/functional/test_server_group.py index b8dadcb8d0..5ae8f6ee26 100644 --- a/nova/tests/functional/test_server_group.py +++ b/nova/tests/functional/test_server_group.py @@ -145,13 +145,13 @@ class ServerGroupTestV21(ServerGroupTestBase): self.stub_out('nova.virt.driver.load_compute_driver', _fake_load_compute_driver) fake.set_nodes(['compute']) + self.addCleanup(fake.restore_nodes) self.compute = self.start_service('compute', host='compute') # NOTE(gibi): start a second compute host to be able to test affinity # NOTE(sbauza): Make sure the FakeDriver returns a different nodename # for the second compute node. fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.compute2 = self.start_service('compute', host='host2') def test_get_no_groups(self): @@ -911,7 +911,6 @@ class ServerGroupTestMultiCell(ServerGroupTestBase): self.compute1 = self.start_service('compute', host='host1', cell='cell1') fake.set_nodes(['host2']) - self.addCleanup(fake.restore_nodes) self.compute2 = self.start_service('compute', host='host2', cell='cell2') # This is needed to find a server that is still booting with multiple @@ -995,9 +994,9 @@ class TestAntiAffinityLiveMigration(test.TestCase, # Start conductor, scheduler and two computes. self.start_service('conductor') self.start_service('scheduler') + self.addCleanup(fake.restore_nodes) for host in ('host1', 'host2'): fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host) def test_serial_no_valid_host_then_pass_with_third_host(self): @@ -1060,7 +1059,6 @@ class TestAntiAffinityLiveMigration(test.TestCase, # Now start up a 3rd compute service and retry the live migration which # should work this time. fake.set_nodes(['host3']) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host='host3') self.admin_api.post_server_action(server['id'], body) server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE') diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 9e2d5d5178..f53da5360b 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -4854,9 +4854,9 @@ class ServerTestV256Common(ServersTestBase): def _setup_compute_service(self): # Set up 3 compute services in the same cell + self.addCleanup(fake.restore_nodes) for host in ('host1', 'host2', 'host3'): fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host) def _create_server(self, target_host=None): @@ -4888,9 +4888,9 @@ class ServerTestV256MultiCellTestCase(ServerTestV256Common): host_to_cell_mappings = { 'host1': 'cell1', 'host2': 'cell2'} + self.addCleanup(fake.restore_nodes) for host in sorted(host_to_cell_mappings): fake.set_nodes([host]) - self.addCleanup(fake.restore_nodes) self.start_service('compute', host=host, cell=host_to_cell_mappings[host])