summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMate Lakat <mate.lakat@citrix.com>2012-12-18 14:22:40 +0000
committerMate Lakat <mate.lakat@citrix.com>2013-01-04 09:41:50 +0000
commitd65801ca0718a5ca417d5b134ae9b7d87730f83f (patch)
treee0d09ef9c4c791d95a91218ec6012e21bc05047d /nova/tests
parentb6843ad968ca03797d968625e8bec814caa42aa0 (diff)
fix floating-ip in multihost case
Fixes bug 1091698. _disassociate_floating_ip and _associate_floating_ip got an extra parameter since this change: https://github.com/openstack/nova/commit/b93e851c0d90c17868a0e68a3b54e136bb5cd54d However, the multi-host codepath was not amended, thus multihost case is broken since that. This fix adds the extra parameters for those rpc calls. Change-Id: I93a5f96ef87c0f8a14c912d7812c001d0c682afa
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/network/test_manager.py111
-rw-r--r--nova/tests/network/test_rpcapi.py5
2 files changed, 114 insertions, 2 deletions
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index e80ea3936..524cf17a3 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -689,6 +689,7 @@ class VlanNetworkTestCase(test.TestCase):
def fake4(*args, **kwargs):
return {'address': '10.0.0.1',
'pool': 'nova',
+ 'instance_uuid': FAKEUUID,
'interface': 'eth0',
'network_id': 'blah'}
@@ -840,6 +841,7 @@ class VlanNetworkTestCase(test.TestCase):
def fake4(*args, **kwargs):
return {'address': '10.0.0.1',
'pool': 'nova',
+ 'instance_uuid': FAKEUUID,
'interface': 'eth0',
'network_id': 'blah'}
@@ -1633,6 +1635,115 @@ class FloatingIPTestCase(test.TestCase):
shutil.rmtree(self.tempdir)
super(FloatingIPTestCase, self).tearDown()
+ def test_disassociate_floating_ip_multi_host_calls(self):
+ floating_ip = {
+ 'fixed_ip_id': 12
+ }
+
+ fixed_ip = {
+ 'network_id': None,
+ 'instance_uuid': 'instance-uuid'
+ }
+
+ network = {
+ 'multi_host': True
+ }
+
+ instance = {
+ 'host': 'some-other-host'
+ }
+
+ ctxt = context.RequestContext('testuser', 'testproject',
+ is_admin=False)
+
+ self.stubs.Set(self.network.db,
+ 'floating_ip_get_by_address',
+ lambda _x, _y: floating_ip)
+
+ self.stubs.Set(self.network,
+ '_floating_ip_owned_by_project',
+ lambda _x, _y: True)
+
+ self.stubs.Set(self.network.db,
+ 'fixed_ip_get',
+ lambda _x, _y: fixed_ip)
+
+ self.stubs.Set(self.network,
+ '_get_network_by_id',
+ lambda _x, _y: network)
+
+ self.stubs.Set(self.network.db,
+ 'instance_get_by_uuid',
+ lambda _x, _y: instance)
+
+ self.stubs.Set(self.network.db,
+ 'service_get_by_host_and_topic',
+ lambda _x, _y, _z: 'service')
+
+ self.stubs.Set(self.network.servicegroup_api,
+ 'service_is_up',
+ lambda _x: True)
+
+ self.mox.StubOutWithMock(
+ self.network.network_rpcapi, '_disassociate_floating_ip')
+
+ self.network.network_rpcapi._disassociate_floating_ip(
+ ctxt, 'fl_ip', mox.IgnoreArg(), 'some-other-host', 'instance-uuid')
+ self.mox.ReplayAll()
+
+ self.network.disassociate_floating_ip(ctxt, 'fl_ip', True)
+
+ def test_associate_floating_ip_multi_host_calls(self):
+ floating_ip = {
+ 'fixed_ip_id': None
+ }
+
+ fixed_ip = {
+ 'network_id': None,
+ 'instance_uuid': 'instance-uuid'
+ }
+
+ network = {
+ 'multi_host': True
+ }
+
+ instance = {
+ 'host': 'some-other-host'
+ }
+
+ ctxt = context.RequestContext('testuser', 'testproject',
+ is_admin=False)
+
+ self.stubs.Set(self.network.db,
+ 'floating_ip_get_by_address',
+ lambda _x, _y: floating_ip)
+
+ self.stubs.Set(self.network,
+ '_floating_ip_owned_by_project',
+ lambda _x, _y: True)
+
+ self.stubs.Set(self.network.db,
+ 'fixed_ip_get_by_address',
+ lambda _x, _y: fixed_ip)
+
+ self.stubs.Set(self.network,
+ '_get_network_by_id',
+ lambda _x, _y: network)
+
+ self.stubs.Set(self.network.db,
+ 'instance_get_by_uuid',
+ lambda _x, _y: instance)
+
+ self.mox.StubOutWithMock(
+ self.network.network_rpcapi, '_associate_floating_ip')
+
+ self.network.network_rpcapi._associate_floating_ip(
+ ctxt, 'fl_ip', 'fix_ip', mox.IgnoreArg(), 'some-other-host',
+ 'instance-uuid')
+ self.mox.ReplayAll()
+
+ self.network.associate_floating_ip(ctxt, 'fl_ip', 'fix_ip', True)
+
def test_double_deallocation(self):
instance_ref = db.api.instance_create(self.context,
{"project_id": self.project_id})
diff --git a/nova/tests/network/test_rpcapi.py b/nova/tests/network/test_rpcapi.py
index 77a936b63..032996209 100644
--- a/nova/tests/network/test_rpcapi.py
+++ b/nova/tests/network/test_rpcapi.py
@@ -265,12 +265,13 @@ class NetworkRpcAPITestCase(test.TestCase):
def test__associate_floating_ip(self):
self._test_network_api('_associate_floating_ip', rpc_method='call',
floating_address='fake_addr', fixed_address='fixed_address',
- interface='fake_interface', host='fake_host')
+ interface='fake_interface', host='fake_host',
+ instance_uuid='fake_uuid', version='1.6')
def test__disassociate_floating_ip(self):
self._test_network_api('_disassociate_floating_ip', rpc_method='call',
address='fake_addr', interface='fake_interface',
- host='fake_host')
+ host='fake_host', instance_uuid='fake_uuid', version='1.6')
def test_migrate_instance_start(self):
self._test_network_api('migrate_instance_start', rpc_method='call',