diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-07-13 03:16:17 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-07-13 03:16:17 +0000 |
| commit | 29ef49c205bf5d042e52a44dda8f16aca043b31c (patch) | |
| tree | 058af98265224cb901dd2d7803678bcf5bf301ce /nova/tests | |
| parent | 11611716e30f368df77816b40c4c77de0e0e047f (diff) | |
| parent | 10a3b6c4e2ad1722ae4566f6ace997fe54769a36 (diff) | |
Starting part of multi-nic support in the guest. Adds the remove_fixed_ip code, but is incomplete as it needs the API extension that Vek is working on.
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/contrib/test_multinic_xs.py | 10 | ||||
| -rw-r--r-- | nova/tests/test_network.py | 33 |
2 files changed, 37 insertions, 6 deletions
diff --git a/nova/tests/api/openstack/contrib/test_multinic_xs.py b/nova/tests/api/openstack/contrib/test_multinic_xs.py index 484cd1c17..b0a9f7676 100644 --- a/nova/tests/api/openstack/contrib/test_multinic_xs.py +++ b/nova/tests/api/openstack/contrib/test_multinic_xs.py @@ -50,9 +50,8 @@ class FixedIpTest(test.TestCase): fakes.stub_out_auth(self.stubs) self.stubs.Set(compute.api.API, "add_fixed_ip", compute_api_add_fixed_ip) - # TODO(Vek): Fails until remove_fixed_ip() added - # self.stubs.Set(compute.api.API, "remove_fixed_ip", - # compute_api_remove_fixed_ip) + self.stubs.Set(compute.api.API, "remove_fixed_ip", + compute_api_remove_fixed_ip) self.context = context.get_admin_context() def tearDown(self): @@ -98,9 +97,8 @@ class FixedIpTest(test.TestCase): req.headers['content-type'] = 'application/json' resp = req.get_response(fakes.wsgi_app()) - # TODO(Vek): Fails until remove_fixed_ip() added - # self.assertEqual(resp.status_int, 202) - # self.assertEqual(last_remove_fixed_ip, ('test_inst', '10.10.10.1')) + self.assertEqual(resp.status_int, 202) + self.assertEqual(last_remove_fixed_ip, ('test_inst', '10.10.10.1')) def test_remove_fixed_ip_no_address(self): global last_remove_fixed_ip diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 6d5166019..b09021e13 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -16,6 +16,7 @@ # under the License. from nova import db +from nova import exception from nova import flags from nova import log as logging from nova import test @@ -238,3 +239,35 @@ class VlanNetworkTestCase(test.TestCase): self.assertRaises(ValueError, self.network.create_networks, None, num_networks=100, vlan_start=1, cidr='192.168.0.1/24', network_size=100) + + +class CommonNetworkTestCase(test.TestCase): + + class FakeNetworkManager(network_manager.NetworkManager): + """This NetworkManager doesn't call the base class so we can bypass all + inherited service cruft and just perform unit tests. + """ + + class FakeDB: + def fixed_ip_get_by_instance(self, context, instance_id): + return [dict(address='10.0.0.0'), dict(address='10.0.0.1'), + dict(address='10.0.0.2')] + + def __init__(self): + self.db = self.FakeDB() + self.deallocate_called = None + + def deallocate_fixed_ip(self, context, address): + self.deallocate_called = address + + def test_remove_fixed_ip_from_instance(self): + manager = self.FakeNetworkManager() + manager.remove_fixed_ip_from_instance(None, 99, '10.0.0.1') + + self.assertEquals(manager.deallocate_called, '10.0.0.1') + + def test_remove_fixed_ip_from_instance_bad_input(self): + manager = self.FakeNetworkManager() + self.assertRaises(exception.FixedIpNotFoundForSpecificInstance, + manager.remove_fixed_ip_from_instance, + None, 99, 'bad input') |
