diff --git a/nova/tests/functional/api_sample_tests/api_sample_base.py b/nova/tests/functional/api_sample_tests/api_sample_base.py index d9ac77f1ae..4325ba4c52 100644 --- a/nova/tests/functional/api_sample_tests/api_sample_base.py +++ b/nova/tests/functional/api_sample_tests/api_sample_base.py @@ -53,7 +53,7 @@ CONF = nova.conf.CONF class ApiSampleTestBaseV21(testscenarios.WithScenarios, - api_samples_test_base.ApiSampleTestBase): + api_samples_test_base.ApiSampleTestBase): SUPPORTS_CELLS = False api_major_version = 'v2' diff --git a/nova/tests/functional/api_sample_tests/test_instance_actions.py b/nova/tests/functional/api_sample_tests/test_instance_actions.py index 785575fde8..cd82528d61 100644 --- a/nova/tests/functional/api_sample_tests/test_instance_actions.py +++ b/nova/tests/functional/api_sample_tests/test_instance_actions.py @@ -15,11 +15,10 @@ from nova.tests.functional.api_sample_tests import test_servers from nova.tests.functional import api_samples_test_base -from nova.tests.functional import integrated_helpers -class ServerActionsSampleJsonTest(test_servers.ServersSampleBase, - integrated_helpers.InstanceHelperMixin): +class ServerActionsSampleJsonTest(test_servers.ServersSampleBase): + microversion = None ADMIN_API = True sample_dir = 'os-instance-actions' diff --git a/nova/tests/functional/api_sample_tests/test_multinic.py b/nova/tests/functional/api_sample_tests/test_multinic.py index 526e4dc6b5..c66f1d5c1f 100644 --- a/nova/tests/functional/api_sample_tests/test_multinic.py +++ b/nova/tests/functional/api_sample_tests/test_multinic.py @@ -15,11 +15,9 @@ from nova.tests import fixtures from nova.tests.functional.api_sample_tests import api_sample_base -from nova.tests.functional import integrated_helpers -class MultinicSampleJsonTest(integrated_helpers.InstanceHelperMixin, - api_sample_base.ApiSampleTestBaseV21): +class MultinicSampleJsonTest(api_sample_base.ApiSampleTestBaseV21): ADMIN_API = True sample_dir = "os-multinic" diff --git a/nova/tests/functional/compute/test_live_migration.py b/nova/tests/functional/compute/test_live_migration.py index 1966b3d13d..083dadf774 100644 --- a/nova/tests/functional/compute/test_live_migration.py +++ b/nova/tests/functional/compute/test_live_migration.py @@ -38,8 +38,7 @@ class FakeCinderError(object): raise exception.CinderConnectionFailed(reason='Fake Cinder error') -class LiveMigrationCinderFailure(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class LiveMigrationCinderFailure(integrated_helpers._IntegratedTestBase): api_major_version = 'v2.1' microversion = 'latest' @@ -47,7 +46,7 @@ class LiveMigrationCinderFailure(integrated_helpers._IntegratedTestBase, super(LiveMigrationCinderFailure, self).setUp() fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) - # Start a second compte node (the first one was started for us by + # Start a second compute node (the first one was started for us by # _IntegratedTestBase. set_nodes() is needed to avoid duplicate # nodenames. See comments in test_bug_1702454.py. self.compute2 = self.start_service('compute', host='host2') diff --git a/nova/tests/functional/db/test_virtual_interface.py b/nova/tests/functional/db/test_virtual_interface.py index 3ce618e1c0..9ab2dd1445 100644 --- a/nova/tests/functional/db/test_virtual_interface.py +++ b/nova/tests/functional/db/test_virtual_interface.py @@ -55,8 +55,7 @@ def _verify_list_fulfillment(context, instance_uuid): class VirtualInterfaceListMigrationTestCase( - integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): + integrated_helpers._IntegratedTestBase): ADMIN_API = True api_major_version = 'v2.1' diff --git a/nova/tests/functional/integrated_helpers.py b/nova/tests/functional/integrated_helpers.py index 7b01d547dd..57eca61606 100644 --- a/nova/tests/functional/integrated_helpers.py +++ b/nova/tests/functional/integrated_helpers.py @@ -242,7 +242,7 @@ class InstanceHelperMixin(object): return api.post_aggregate(body)['id'] -class _IntegratedTestBase(test.TestCase): +class _IntegratedTestBase(test.TestCase, InstanceHelperMixin): REQUIRES_LOCKING = True ADMIN_API = False # This indicates whether to include the project ID in the URL for API @@ -320,37 +320,6 @@ class _IntegratedTestBase(test.TestCase): return (generate_new_element(flavor_names, 'flavor'), int(generate_new_element(flavor_ids, '', True))) - def _build_minimal_create_server_request(self, name=None, image_uuid=None, - flavor_id=None, networks=None, - az=None, host=None): - server = {} - - if not image_uuid: - # NOTE(takashin): In API version 2.36, image APIs were deprecated. - # In API version 2.36 or greater, self.api.get_images() returns - # a 404 error. In that case, 'image_uuid' should be specified. - image_uuid = self.api.get_images()[0]['id'] - server['imageRef'] = image_uuid - - if not name: - name = ''.join( - random.choice(string.ascii_lowercase) for i in range(10)) - server['name'] = name - - if not flavor_id: - # Set a valid flavorId - flavor_id = self.api.get_flavors()[0]['id'] - server['flavorRef'] = 'http://fake.server/%s' % flavor_id - - if networks is not None: - server['networks'] = networks - if az is not None: - server['availability_zone'] = az - # This requires at least microversion 2.74 to work - if host is not None: - server['host'] = host - return server - def _create_flavor_body(self, name, ram, vcpus, disk, ephemeral, id, swap, rxtx_factor, is_public): return { diff --git a/nova/tests/functional/regressions/test_bug_1404867.py b/nova/tests/functional/regressions/test_bug_1404867.py index fa15dc9006..4581e1f0e4 100644 --- a/nova/tests/functional/regressions/test_bug_1404867.py +++ b/nova/tests/functional/regressions/test_bug_1404867.py @@ -16,8 +16,7 @@ from nova.tests import fixtures as nova_fixtures from nova.tests.functional import integrated_helpers -class DeleteWithReservedVolumes(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class DeleteWithReservedVolumes(integrated_helpers._IntegratedTestBase): """Test deleting of an instance in error state that has a reserved volume. This test boots a server from volume which will fail to be scheduled, diff --git a/nova/tests/functional/regressions/test_bug_1669054.py b/nova/tests/functional/regressions/test_bug_1669054.py index 1054ae9dbd..99e1d728f1 100644 --- a/nova/tests/functional/regressions/test_bug_1669054.py +++ b/nova/tests/functional/regressions/test_bug_1669054.py @@ -15,8 +15,7 @@ from nova import objects from nova.tests.functional import integrated_helpers -class ResizeEvacuateTestCase(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class ResizeEvacuateTestCase(integrated_helpers._IntegratedTestBase): """Regression test for bug 1669054 introduced in Newton. When resizing a server, if CONF.allow_resize_to_same_host is False, diff --git a/nova/tests/functional/regressions/test_bug_1732947.py b/nova/tests/functional/regressions/test_bug_1732947.py index 97f207f442..a373c62c4c 100644 --- a/nova/tests/functional/regressions/test_bug_1732947.py +++ b/nova/tests/functional/regressions/test_bug_1732947.py @@ -19,8 +19,7 @@ from nova.tests.functional import integrated_helpers CONF = nova.conf.CONF -class RebuildVolumeBackedSameImage(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class RebuildVolumeBackedSameImage(integrated_helpers._IntegratedTestBase): """Tests the regression in bug 1732947 where rebuilding a volume-backed instance with the original image still results in conductor calling the scheduler to validate the image. This is because the instance.image_ref diff --git a/nova/tests/functional/regressions/test_bug_1823370.py b/nova/tests/functional/regressions/test_bug_1823370.py index 9edf756bc9..6e8c912165 100644 --- a/nova/tests/functional/regressions/test_bug_1823370.py +++ b/nova/tests/functional/regressions/test_bug_1823370.py @@ -14,8 +14,7 @@ from nova.tests import fixtures as nova_fixtures from nova.tests.functional import integrated_helpers -class MultiCellEvacuateTestCase(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class MultiCellEvacuateTestCase(integrated_helpers._IntegratedTestBase): """Recreate test for bug 1823370 which was introduced in Pike. When evacuating a server, the request to the scheduler should be restricted diff --git a/nova/tests/functional/test_aggregates.py b/nova/tests/functional/test_aggregates.py index b0d277012a..be314cfea5 100644 --- a/nova/tests/functional/test_aggregates.py +++ b/nova/tests/functional/test_aggregates.py @@ -838,7 +838,7 @@ class TestAggregateFiltersTogether(AggregateRequestFiltersTest): class TestAggregateMultiTenancyIsolationFilter( - test.TestCase, integrated_helpers.InstanceHelperMixin): + test.TestCase, integrated_helpers.InstanceHelperMixin): def _start_compute(self, host): self.start_service('compute', host=host) diff --git a/nova/tests/functional/test_boot_from_volume.py b/nova/tests/functional/test_boot_from_volume.py index 3bed083181..d6b9220c63 100644 --- a/nova/tests/functional/test_boot_from_volume.py +++ b/nova/tests/functional/test_boot_from_volume.py @@ -25,8 +25,7 @@ from nova.tests.unit.image import fake as fake_image from nova.tests.unit import policy_fixture -class BootFromVolumeTest(integrated_helpers.InstanceHelperMixin, - test_servers.ServersTestBase): +class BootFromVolumeTest(test_servers.ServersTestBase): def _get_hypervisor_stats(self): response = self.admin_api.api_get('/os-hypervisors/statistics') @@ -118,8 +117,7 @@ class BootFromVolumeTest(integrated_helpers.InstanceHelperMixin, # Shelve post_data = {'shelve': None} self.api.post_server_action(server_id, post_data) - self._wait_for_state_change(created_server, - 'SHELVED_OFFLOADED') + self._wait_for_state_change(created_server, 'SHELVED_OFFLOADED') # Check that hypervisor local disk reporting is still 0 self._verify_zero_local_gb_used() diff --git a/nova/tests/functional/test_conf_max_attach_disk_devices.py b/nova/tests/functional/test_conf_max_attach_disk_devices.py index a6dcb0c228..538c008c0f 100644 --- a/nova/tests/functional/test_conf_max_attach_disk_devices.py +++ b/nova/tests/functional/test_conf_max_attach_disk_devices.py @@ -16,12 +16,10 @@ import six from nova.tests import fixtures as nova_fixtures from nova.tests.functional.api import client -from nova.tests.functional import integrated_helpers from nova.tests.functional import test_servers -class ConfigurableMaxDiskDevicesTest(integrated_helpers.InstanceHelperMixin, - test_servers.ServersTestBase): +class ConfigurableMaxDiskDevicesTest(test_servers.ServersTestBase): def setUp(self): super(ConfigurableMaxDiskDevicesTest, self).setUp() self.cinder = self.useFixture( diff --git a/nova/tests/functional/test_multiattach.py b/nova/tests/functional/test_multiattach.py index 42193c2f23..589677a2ae 100644 --- a/nova/tests/functional/test_multiattach.py +++ b/nova/tests/functional/test_multiattach.py @@ -15,8 +15,7 @@ from nova.tests import fixtures as nova_fixtures from nova.tests.functional import integrated_helpers -class TestMultiattachVolumes(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class TestMultiattachVolumes(integrated_helpers._IntegratedTestBase): """Functional tests for creating a server from a multiattach volume and attaching a multiattach volume to a server. diff --git a/nova/tests/functional/test_nova_manage.py b/nova/tests/functional/test_nova_manage.py index 43beae0baf..0bc9ef938f 100644 --- a/nova/tests/functional/test_nova_manage.py +++ b/nova/tests/functional/test_nova_manage.py @@ -1430,9 +1430,7 @@ class TestDBArchiveDeletedRows(integrated_helpers._IntegratedTestBase): # Now delete one server and then we can archive. server = self.api.get_server(server['id']) self.api.delete_server(server['id']) - helper = integrated_helpers.InstanceHelperMixin() - helper.api = self.api - helper._wait_until_deleted(server) + self._wait_until_deleted(server) # Now archive. self.cli.archive_deleted_rows(verbose=True) # Assert only one instance_group_member record was deleted. diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 8c4dd6ebdb..0a60b54ab2 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -75,43 +75,6 @@ class ServersTestBase(integrated_helpers._IntegratedTestBase): self.computes = {} super(ServersTestBase, self).setUp() - def _wait_for_server_parameter(self, server, expected_params, - max_retries=10): - api = getattr(self, 'admin_api', self.api) - retry_count = 0 - while True: - server = api.get_server(server['id']) - if all([server[attr] == expected_params[attr] - for attr in expected_params]): - break - retry_count += 1 - if retry_count == max_retries: - self.fail('Wait for state change failed, ' - 'expected_params=%s, server=%s' % ( - expected_params, server)) - time.sleep(0.5) - - return server - - def _wait_for_state_change(self, server, expected_status, max_retries=10): - return self._wait_for_server_parameter( - server, {'status': expected_status}, max_retries) - - # TODO(stephenfin): Remove this once we subclass 'InstanceHelperMixin' - def _wait_until_deleted(self, server): - initially_in_error = server.get('status') == 'ERROR' - try: - for i in range(40): - server = self.api.get_server(server['id']) - if not initially_in_error and server['status'] == 'ERROR': - self.fail('Server went to error state instead of' - 'disappearing.') - time.sleep(0.5) - - self.fail('Server failed to delete.') - except client.OpenStackApiNotFoundException: - return - def _delete_server(self, server): # Delete the server self.api.delete_server(server['id']) @@ -1366,8 +1329,7 @@ class ServerTestV269(ServersTestBase): self.assertIn('image', server) -class ServerRebuildTestCase(integrated_helpers._IntegratedTestBase, - integrated_helpers.InstanceHelperMixin): +class ServerRebuildTestCase(integrated_helpers._IntegratedTestBase): api_major_version = 'v2.1' # We have to cap the microversion at 2.38 because that's the max we # can use to update image metadata via our compute images proxy API.