summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-12-12 22:43:02 +0000
committerGerrit Code Review <review@openstack.org>2012-12-12 22:43:02 +0000
commitd5b91dd39bd89eed98742cd02ea604a842a45447 (patch)
tree977ef001c7bd8df53e65f66d6ac1dea4333d379b /nova/tests
parent7b5ce8f8cc7cffb4b3be2fefb4878a6a6d23b838 (diff)
parent40fcbcb8852cad03eec345106772292fa08b25dc (diff)
Merge "Remove unused bridge interfaces"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/network/test_linux_net.py27
-rw-r--r--nova/tests/test_db_api.py17
2 files changed, 44 insertions, 0 deletions
diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py
index 55a9c7777..68aaa6251 100644
--- a/nova/tests/network/test_linux_net.py
+++ b/nova/tests/network/test_linux_net.py
@@ -494,6 +494,33 @@ class LinuxNetworkTestCase(test.TestCase):
for inp in expected_inputs:
self.assertTrue(inp in inputs[0])
+ executes = []
+ inputs = []
+
+ @classmethod
+ def fake_remove(_self, bridge, gateway):
+ return
+
+ self.stubs.Set(linux_net.LinuxBridgeInterfaceDriver,
+ 'remove_bridge', fake_remove)
+
+ driver.unplug(network)
+ expected = [
+ ('ebtables', '-D', 'INPUT', '-p', 'ARP', '-i', iface,
+ '--arp-ip-dst', dhcp, '-j', 'DROP'),
+ ('ebtables', '-D', 'OUTPUT', '-p', 'ARP', '-o', iface,
+ '--arp-ip-src', dhcp, '-j', 'DROP'),
+ ('iptables-save', '-c', '-t', 'filter'),
+ ('iptables-restore', '-c'),
+ ('iptables-save', '-c', '-t', 'nat'),
+ ('iptables-restore', '-c'),
+ ('ip6tables-save', '-c', '-t', 'filter'),
+ ('ip6tables-restore', '-c'),
+ ]
+ self.assertEqual(executes, expected)
+ for inp in expected_inputs:
+ self.assertFalse(inp in inputs[0])
+
def _test_initialize_gateway(self, existing, expected, routes=''):
self.flags(fake_network=False)
executes = []
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index f2124c021..29bce8bf5 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -582,6 +582,23 @@ class DbApiTestCase(test.TestCase):
data = db.network_get_all_by_host(ctxt, 'foo')
self.assertEqual(len(data), 3)
+ def test_network_in_use_on_host(self):
+ ctxt = context.get_admin_context()
+
+ values = {'host': 'foo', 'hostname': 'myname'}
+ instance = db.instance_create(ctxt, values)
+ values = {'address': 'bar', 'instance_uuid': instance['uuid']}
+ vif = db.virtual_interface_create(ctxt, values)
+ values = {'address': 'baz',
+ 'network_id': 1,
+ 'allocated': True,
+ 'instance_uuid': instance['uuid'],
+ 'virtual_interface_id': vif['id']}
+ db.fixed_ip_create(ctxt, values)
+
+ self.assertEqual(db.network_in_use_on_host(ctxt, 1, 'foo'), True)
+ self.assertEqual(db.network_in_use_on_host(ctxt, 1, 'bar'), False)
+
def _timeout_test(self, ctxt, timeout, multi_host):
values = {'host': 'foo'}
instance = db.instance_create(ctxt, values)