From 454dce8271cb34f187ea680e50366cecc3bbfde7 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Fri, 16 Aug 2013 22:28:44 +0100 Subject: [PATCH] Fix remove_fixed_ip test with CastAsCall If you enable CastAsCall, a bunch of issues with the remove_fixed_ip API sample integration test crops up. Firstly, the sample network is getting created with 'fake-mini' from CONF.host as the network host rather than the host UUID generated for the network service in start_service(). This results in allocate_fixed_ip() attempting to invoke an RPC on a non-existant host. Secondly, the test is attempting to remove a fixed IP which was never allocated. Use the add_fixed_ip() test to allocate a fixed IP and then remove that one, which is 10.0.0.3 rather than 10.0.0.2 which is the IP reserved for VPN. Lastly, disable the instance DNS manager because it seems this isn't compatible with multinic. I was getting FloatingIpDNSExists raised. blueprint: oslo-messaging Related-Bug: #1213251 Change-Id: I9854863bbec8834c638c55832411f63da570f82d --- nova/test.py | 5 ++++- nova/tests/integrated/test_api_samples.py | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/nova/test.py b/nova/test.py index ae0728dcfc..f7c68e7b9f 100644 --- a/nova/test.py +++ b/nova/test.py @@ -116,10 +116,13 @@ class SampleNetworks(fixtures.Fixture): """Create sample networks in the database.""" + def __init__(self, host=None): + self.host = host + def setUp(self): super(SampleNetworks, self).setUp() ctxt = context.get_admin_context() - network = network_manager.VlanManager() + network = network_manager.VlanManager(host=self.host) bridge_interface = CONF.flat_interface or CONF.vlan_interface network.create_networks(ctxt, label='test', diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 5936120e38..229a914f4b 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -387,7 +387,7 @@ class ApiSampleTestBaseV2(ApiSampleTestBase): ext = [self.extension_name] if self.extension_name else [] self.flags(osapi_compute_extension=ext + extends) super(ApiSampleTestBaseV2, self).setUp() - self.useFixture(test.SampleNetworks()) + self.useFixture(test.SampleNetworks(host=self.network.host)) fake_network.stub_compute_with_ips(self.stubs) fake_utils.stub_out_utils_spawn_n(self.stubs) self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None @@ -3182,18 +3182,31 @@ class FloatingIPPoolsSampleXmlTests(FloatingIPPoolsSampleJsonTests): class MultinicSampleJsonTest(ServersSampleBase): extension_name = "nova.api.openstack.compute.contrib.multinic.Multinic" + def _disable_instance_dns_manager(self): + # NOTE(markmc): it looks like multinic and instance_dns_manager are + # incompatible. See: + # https://bugs.launchpad.net/nova/+bug/1213251 + self.flags( + instance_dns_manager='nova.network.noop_dns_driver.NoopDNSDriver') + def setUp(self): + self._disable_instance_dns_manager() super(MultinicSampleJsonTest, self).setUp() self.uuid = self._post_server() - def test_add_fixed_ip(self): + def _add_fixed_ip(self): subs = {"networkId": 1} response = self._do_post('servers/%s/action' % (self.uuid), 'multinic-add-fixed-ip-req', subs) self.assertEqual(response.status, 202) + def test_add_fixed_ip(self): + self._add_fixed_ip() + def test_remove_fixed_ip(self): - subs = {"ip": "10.0.0.2"} + self._add_fixed_ip() + + subs = {"ip": "10.0.0.4"} response = self._do_post('servers/%s/action' % (self.uuid), 'multinic-remove-fixed-ip-req', subs) self.assertEqual(response.status, 202)