From 0360e4c93d8d1c25b61a49b4cb1b94602b61975e Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Tue, 18 Oct 2016 11:41:59 +0200 Subject: [PATCH] Cleanup before removal of conductor local apis Some old cruft from the when conductor proxying was being used to make db calls are left in various places in unit tests. None of this is of use anymore and needs to be removed before the conductor local apis and related 'use_local' flag can be removed. Change-Id: Id5fe30f4124396ac59ef3d008972db4dd930855d --- nova/tests/unit/compute/test_compute.py | 12 ++------- nova/tests/unit/compute/test_compute_mgr.py | 2 -- nova/tests/unit/compute/test_compute_utils.py | 1 - .../tests/unit/compute/test_multiple_nodes.py | 3 --- nova/tests/unit/network/test_manager.py | 1 - .../unit/servicegroup/test_db_servicegroup.py | 27 ++----------------- nova/tests/unit/test_metadata.py | 8 ------ nova/tests/unit/test_service.py | 1 - nova/tests/unit/test_test.py | 1 - .../unit/virt/libvirt/test_imagecache.py | 3 --- nova/tests/unit/virt/xenapi/test_xenapi.py | 2 -- 11 files changed, 4 insertions(+), 57 deletions(-) diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index 19bfb83b85ad..babd882fd6a5 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -150,7 +150,6 @@ class BaseTestCase(test.TestCase): super(BaseTestCase, self).setUp() self.flags(network_manager='nova.network.manager.FlatManager') fake.set_nodes([NODENAME]) - self.flags(use_local=True, group='conductor') fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) @@ -331,13 +330,6 @@ class BaseTestCase(test.TestCase): 'project_id': self.project_id} return db.security_group_create(self.context, values) - def _stub_migrate_server(self): - def _fake_migrate_server(*args, **kwargs): - pass - - self.stub_out('nova.conductor.manager.ComputeTaskManager' - '.migrate_server', _fake_migrate_server) - def _init_aggregate_with_host(self, aggr, aggr_name, zone, host): if not aggr: aggr = self.api.create_aggregate(self.context, aggr_name, zone) @@ -10974,8 +10966,8 @@ class DisabledInstanceTypesTestCase(BaseTestCase): self.stub_out('nova.compute.flavors.get_flavor_by_flavor_id', fake_get_flavor_by_flavor_id) - self._stub_migrate_server() - self.compute_api.resize(self.context, instance, '4') + with mock.patch('nova.conductor.api.ComputeTaskAPI.resize_instance'): + self.compute_api.resize(self.context, instance, '4') def test_cannot_resize_to_disabled_instance_type(self): instance = self._create_fake_instance_obj() diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 307c18b2cb0e..7ae12f156ff2 100755 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -73,7 +73,6 @@ CONF = nova.conf.CONF class ComputeManagerUnitTestCase(test.NoDBTestCase): def setUp(self): super(ComputeManagerUnitTestCase, self).setUp() - self.flags(use_local=True, group='conductor') self.compute = importutils.import_object(CONF.compute_manager) self.context = context.RequestContext(fakes.FAKE_USER_ID, fakes.FAKE_PROJECT_ID) @@ -5246,7 +5245,6 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase): class ComputeManagerInstanceUsageAuditTestCase(test.TestCase): def setUp(self): super(ComputeManagerInstanceUsageAuditTestCase, self).setUp() - self.flags(use_local=True, group='conductor') self.flags(group='glance', api_servers=['http://localhost:9292']) self.flags(instance_usage_audit=True) diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py index 88bc747f0851..0c3c92a5bcd1 100644 --- a/nova/tests/unit/compute/test_compute_utils.py +++ b/nova/tests/unit/compute/test_compute_utils.py @@ -398,7 +398,6 @@ class UsageInfoTestCase(test.TestCase): fake_notifier.stub_notifier(self) self.addCleanup(fake_notifier.reset) - self.flags(use_local=True, group='conductor') self.flags(compute_driver='fake.FakeDriver', network_manager='nova.network.manager.FlatManager') self.compute = importutils.import_object(CONF.compute_manager) diff --git a/nova/tests/unit/compute/test_multiple_nodes.py b/nova/tests/unit/compute/test_multiple_nodes.py index 2907e9438a38..2593991b279d 100644 --- a/nova/tests/unit/compute/test_multiple_nodes.py +++ b/nova/tests/unit/compute/test_multiple_nodes.py @@ -66,9 +66,6 @@ class MultiNodeComputeTestCase(BaseTestCase): super(MultiNodeComputeTestCase, self).setUp() self.flags(compute_driver='fake.FakeDriver') self.compute = importutils.import_object(CONF.compute_manager) - self.flags(use_local=True, group='conductor') - self.conductor = self.start_service('conductor', - manager=CONF.conductor.manager) def fake_get_compute_nodes_in_db(context, use_slave=False): fake_compute_nodes = [{'local_gb': 259, diff --git a/nova/tests/unit/network/test_manager.py b/nova/tests/unit/network/test_manager.py index ff8707bb6166..fd20a25e60d8 100644 --- a/nova/tests/unit/network/test_manager.py +++ b/nova/tests/unit/network/test_manager.py @@ -818,7 +818,6 @@ class FlatDHCPNetworkTestCase(test.TestCase): def setUp(self): super(FlatDHCPNetworkTestCase, self).setUp() self.useFixture(test.SampleNetworks()) - self.flags(use_local=True, group='conductor') self.network = network_manager.FlatDHCPManager(host=HOST) self.network.db = db self.context = context.RequestContext('testuser', diff --git a/nova/tests/unit/servicegroup/test_db_servicegroup.py b/nova/tests/unit/servicegroup/test_db_servicegroup.py index d7f857a37b29..f2bc7d4b1c68 100644 --- a/nova/tests/unit/servicegroup/test_db_servicegroup.py +++ b/nova/tests/unit/servicegroup/test_db_servicegroup.py @@ -13,7 +13,6 @@ # under the License. import mock -from oslo_db import exception as db_exception import oslo_messaging as messaging from oslo_utils import fixture as utils_fixture from oslo_utils import timeutils @@ -95,30 +94,8 @@ class DBServiceGroupTestCase(test.NoDBTestCase): fn(service) # fail if exception not caught self.assertTrue(service.model_disconnected) - def test_report_state_remote_error_handling(self): - # test error handling using remote conductor - self.flags(use_local=False, group='conductor') - self._test_report_state_error(messaging.RemoteError) - - def test_report_state_remote_error_handling_timeout(self): - # test error handling using remote conductor - self.flags(use_local=False, group='conductor') + def test_report_state_error_handling_timeout(self): self._test_report_state_error(messaging.MessagingTimeout) - def test_report_state_remote_unexpected_error(self): - # unexpected errors must be handled, but disconnected flag not touched - self.flags(use_local=False, group='conductor') - self._test_report_state_error(RuntimeError) - - def test_report_state_local_error_handling(self): - # if using local conductor, the db driver must handle DB errors - self.flags(use_local=True, group='conductor') - - # mock an oslo.db DBError as it's an exception base class for - # oslo.db DB errors (eg DBConnectionError) - self._test_report_state_error(db_exception.DBError) - - def test_report_state_local_unexpected_error(self): - # unexpected errors must be handled, but disconnected flag not touched - self.flags(use_local=True, group='conductor') + def test_report_state_unexpected_error(self): self._test_report_state_error(RuntimeError) diff --git a/nova/tests/unit/test_metadata.py b/nova/tests/unit/test_metadata.py index 27a675f7751a..ee0ae91e09eb 100644 --- a/nova/tests/unit/test_metadata.py +++ b/nova/tests/unit/test_metadata.py @@ -42,7 +42,6 @@ from nova.api.metadata import vendordata from nova.api.metadata import vendordata_dynamic from nova import block_device from nova.compute import flavors -from nova.conductor import api as conductor_api from nova import context from nova import exception from nova.network import api as network_api @@ -252,7 +251,6 @@ class MetadataTestCase(test.TestCase): super(MetadataTestCase, self).setUp() self.context = context.RequestContext('fake', 'fake') self.instance = fake_inst_obj(self.context) - self.flags(use_local=True, group='conductor') self.keypair = fake_keypair_obj(self.instance.key_name, self.instance.key_data) fake_network.stub_out_nw_api_get_instance_nw_info(self) @@ -351,8 +349,6 @@ class MetadataTestCase(test.TestCase): 'swap': '/dev/sdc', 'ebs0': '/dev/sdh'} - conductor_api.LocalAPI() - self.assertEqual(base._format_instance_mapping(self.context, instance_ref0), block_device._DEFAULT_MAPPINGS) self.assertEqual(base._format_instance_mapping(self.context, @@ -581,7 +577,6 @@ class OpenStackMetadataTestCase(test.TestCase): super(OpenStackMetadataTestCase, self).setUp() self.context = context.RequestContext('fake', 'fake') self.instance = fake_inst_obj(self.context) - self.flags(use_local=True, group='conductor') fake_network.stub_out_nw_api_get_instance_nw_info(self) def test_empty_device_metadata(self): @@ -1005,7 +1000,6 @@ class MetadataHandlerTestCase(test.TestCase): fake_network.stub_out_nw_api_get_instance_nw_info(self) self.context = context.RequestContext('fake', 'fake') self.instance = fake_inst_obj(self.context) - self.flags(use_local=True, group='conductor') self.mdinst = fake_InstanceMetadata(self, self.instance, address=None, sgroups=None) @@ -1527,10 +1521,8 @@ class MetadataPasswordTestCase(test.TestCase): fake_network.stub_out_nw_api_get_instance_nw_info(self) self.context = context.RequestContext('fake', 'fake') self.instance = fake_inst_obj(self.context) - self.flags(use_local=True, group='conductor') self.mdinst = fake_InstanceMetadata(self, self.instance, address=None, sgroups=None) - self.flags(use_local=True, group='conductor') def test_get_password(self): request = webob.Request.blank('') diff --git a/nova/tests/unit/test_service.py b/nova/tests/unit/test_service.py index e8b5727ac004..d45bd94b0ca0 100644 --- a/nova/tests/unit/test_service.py +++ b/nova/tests/unit/test_service.py @@ -98,7 +98,6 @@ class ServiceTestCase(test.NoDBTestCase): self.host = 'foo' self.binary = 'nova-fake' self.topic = 'fake' - self.flags(use_local=True, group='conductor') def test_create(self): diff --git a/nova/tests/unit/test_test.py b/nova/tests/unit/test_test.py index 3ebfff84f0cb..bce44bb9bd98 100644 --- a/nova/tests/unit/test_test.py +++ b/nova/tests/unit/test_test.py @@ -38,7 +38,6 @@ class IsolationTestCase(test.TestCase): """ def test_service_isolation(self): - self.flags(use_local=True, group='conductor') self.useFixture(fixtures.ServiceFixture('compute')) def test_rpc_consumer_isolation(self): diff --git a/nova/tests/unit/virt/libvirt/test_imagecache.py b/nova/tests/unit/virt/libvirt/test_imagecache.py index 13f3de2c0f29..c9812d13a969 100644 --- a/nova/tests/unit/virt/libvirt/test_imagecache.py +++ b/nova/tests/unit/virt/libvirt/test_imagecache.py @@ -26,7 +26,6 @@ from oslo_log import log as logging from oslo_utils import importutils from six.moves import cStringIO -from nova import conductor import nova.conf from nova import context from nova import objects @@ -718,8 +717,6 @@ class ImageCacheManagerTestCase(test.NoDBTestCase): ctxt = context.get_admin_context() mock_instance_list.return_value = fake_instances(ctxt) compute = importutils.import_object(CONF.compute_manager) - self.flags(use_local=True, group='conductor') - compute.conductor_api = conductor.API() compute._run_image_cache_manager_pass(ctxt) filters = { 'host': ['fake-mini'], diff --git a/nova/tests/unit/virt/xenapi/test_xenapi.py b/nova/tests/unit/virt/xenapi/test_xenapi.py index de92ae4887e9..6abbc20e19b3 100644 --- a/nova/tests/unit/virt/xenapi/test_xenapi.py +++ b/nova/tests/unit/virt/xenapi/test_xenapi.py @@ -2108,7 +2108,6 @@ class XenAPIHostTestCase(stubs.XenAPITestBase): group='xenserver') stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) self.context = context.get_admin_context() - self.flags(use_local=True, group='conductor') self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False) self.instance = fake_instance.fake_db_instance(name='foo') @@ -2968,7 +2967,6 @@ class XenAPIAggregateTestCase(stubs.XenAPITestBase): host='host', compute_driver='xenapi.XenAPIDriver', default_availability_zone='avail_zone1') - self.flags(use_local=True, group='conductor') host_ref = xenapi_fake.get_all('host')[0] stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests) self.context = context.get_admin_context()