summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authormingyan bao <bao.mingyan@hp.com>2013-02-04 15:52:33 -0700
committermingyan bao <bao.mingyan@hp.com>2013-02-08 13:06:04 -0700
commit12c73ee65372fd1b0a3d3417cd91e548fd7afd2b (patch)
tree68ed86c079143dded015a5f447c5cc1a514ba851 /nova/tests
parent36fffe9bde1d353a418274a79e6f7abd0177d065 (diff)
l3.py,add_floating_ip: setup NAT before binding
fix for bug 1100435 Change-Id: Iad022f61297fe26edb230ba7b9e31d73df99b5a5
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/network/test_manager.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index 0dcd02f78..c0a434e6c 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -726,7 +726,7 @@ class VlanNetworkTestCase(test.TestCase):
'floating_ip_fixed_ip_associate',
fake1)
self.stubs.Set(self.network.db, 'floating_ip_disassociate', fake1)
- self.stubs.Set(self.network.driver, 'bind_floating_ip', fake8)
+ self.stubs.Set(self.network.driver, 'ensure_floating_forward', fake8)
self.assertRaises(exception.NoFloatingIpInterface,
self.network._associate_floating_ip,
ctxt,
@@ -776,6 +776,42 @@ class VlanNetworkTestCase(test.TestCase):
mox.IgnoreArg())
self.assertTrue(self.local)
+ def test_add_floating_ip_nat_before_bind(self):
+ # Tried to verify order with documented mox record/verify
+ # functionality, but it doesn't seem to work since I can't make it
+ # fail. I'm using stubs and a flag for now, but if this mox feature
+ # can be made to work, it would be a better way to test this.
+ #
+ # self.mox.StubOutWithMock(self.network.driver,
+ # 'ensure_floating_forward')
+ # self.mox.StubOutWithMock(self.network.driver, 'bind_floating_ip')
+ #
+ # self.network.driver.ensure_floating_forward(mox.IgnoreArg(),
+ # mox.IgnoreArg(),
+ # mox.IgnoreArg(),
+ # mox.IgnoreArg())
+ # self.network.driver.bind_floating_ip(mox.IgnoreArg(),
+ # mox.IgnoreArg())
+ # self.mox.ReplayAll()
+
+ nat_called = [False]
+
+ def fake_nat(*args, **kwargs):
+ nat_called[0] = True
+
+ def fake_bind(*args, **kwargs):
+ self.assertTrue(nat_called[0])
+
+ self.stubs.Set(self.network.driver,
+ 'ensure_floating_forward',
+ fake_nat)
+ self.stubs.Set(self.network.driver, 'bind_floating_ip', fake_bind)
+
+ self.network.l3driver.add_floating_ip('fakefloat',
+ 'fakefixed',
+ 'fakeiface',
+ 'fakenet')
+
def test_floating_ip_init_host(self):
def get_all_by_host(_context, _host):