summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2012-07-04 14:42:08 +1000
committerMichael Still <mikal@stillhq.com>2012-07-26 21:22:04 +1000
commitfc82c6dbbd0fa1cdc130cefea534967e273d5570 (patch)
treedb0df1ad88ae8eab2f6911de0e63ce13341d351d /nova/tests
parente238e07692c747ddcb0c70452578a812836cea67 (diff)
Convert fixed_ips to using instance_uuid.
This should be the second last blueprint finish-uuid-conversion change. Change-Id: Idd47c5ed3c30af24d60eb23b8e3881d61b4c7976
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_floating_ips.py4
-rw-r--r--nova/tests/compute/test_compute.py2
-rw-r--r--nova/tests/network/test_manager.py82
-rw-r--r--nova/tests/network/test_quantum.py6
-rw-r--r--nova/tests/test_db_api.py26
5 files changed, 61 insertions, 59 deletions
diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
index 8a3a2ece1..db1364c3b 100644
--- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
+++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py
@@ -36,7 +36,7 @@ FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
def network_api_get_fixed_ip(self, context, id):
if id is None:
return None
- return {'address': '10.0.0.1', 'id': id, 'instance_id': 1}
+ return {'address': '10.0.0.1', 'id': id, 'instance_uuid': 1}
def network_api_get_floating_ip(self, context, id):
@@ -214,7 +214,7 @@ class FloatingIpTest(test.TestCase):
'fixed_ip_id': 11}
def get_fixed_ip(self, context, id):
- return {'address': '10.0.0.1', 'instance_id': 1}
+ return {'address': '10.0.0.1', 'instance_uuid': 1}
self.stubs.Set(network.api.API, "get_floating_ip", get_floating_ip)
self.stubs.Set(network.api.API, "get_fixed_ip", get_fixed_ip)
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index e2c736c54..b6d0803f6 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1647,7 +1647,7 @@ class ComputeTestCase(BaseTestCase):
'power_state': power_state.PAUSED})
v_ref = db.volume_create(c, {'size': 1, 'instance_id': inst_id})
fix_addr = db.fixed_ip_create(c, {'address': '1.1.1.1',
- 'instance_id': inst_id})
+ 'instance_uuid': inst_ref['uuid']})
fix_ref = db.fixed_ip_get_by_address(c, fix_addr)
db.floating_ip_create(c, {'address': flo_addr,
'fixed_ip_id': fix_ref['id']})
diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py
index a5a6b9548..a183094af 100644
--- a/nova/tests/network/test_manager.py
+++ b/nova/tests/network/test_manager.py
@@ -38,10 +38,11 @@ LOG = logging.getLogger(__name__)
HOST = "testhost"
+FAKEUUID = "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
networks = [{'id': 0,
- 'uuid': "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
+ 'uuid': FAKEUUID,
'label': 'test0',
'injected': False,
'multi_host': False,
@@ -84,14 +85,14 @@ networks = [{'id': 0,
fixed_ips = [{'id': 0,
'network_id': 0,
'address': '192.168.0.100',
- 'instance_id': 0,
+ 'instance_uuid': 0,
'allocated': False,
'virtual_interface_id': 0,
'floating_ips': []},
{'id': 0,
'network_id': 1,
'address': '192.168.1.100',
- 'instance_id': 0,
+ 'instance_uuid': 0,
'allocated': False,
'virtual_interface_id': 0,
'floating_ips': []}]
@@ -197,19 +198,19 @@ class FlatNetworkTestCase(test.TestCase):
def test_validate_networks(self):
self.mox.StubOutWithMock(db, 'network_get')
self.mox.StubOutWithMock(db, 'network_get_all_by_uuids')
- self.mox.StubOutWithMock(db, "fixed_ip_get_by_address")
+ self.mox.StubOutWithMock(db, 'fixed_ip_get_by_address')
- requested_networks = [("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb",
- "192.168.1.100")]
+ requested_networks = [('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
+ '192.168.1.100')]
db.network_get_all_by_uuids(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn(networks)
+ mox.IgnoreArg()).AndReturn(networks)
db.network_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(networks[1])
ip = fixed_ips[1].copy()
- ip['instance_id'] = None
+ ip['instance_uuid'] = None
db.fixed_ip_get_by_address(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn(ip)
+ mox.IgnoreArg()).AndReturn(ip)
self.mox.ReplayAll()
self.network.validate_networks(self.context, requested_networks)
@@ -282,14 +283,12 @@ class FlatNetworkTestCase(test.TestCase):
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
- db.instance_get(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn({'security_groups':
- [{'id': 0}]})
db.instance_get(self.context,
1).AndReturn({'display_name': HOST,
'uuid': 'test-00001'})
db.instance_get(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn({'availability_zone': ''})
+ mox.IgnoreArg()).AndReturn({'security_groups':
+ [{'id': 0}]})
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn('192.168.0.101')
@@ -315,14 +314,12 @@ class FlatNetworkTestCase(test.TestCase):
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
- db.instance_get(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn({'security_groups':
- [{'id': 0}]})
db.instance_get(self.context,
1).AndReturn({'display_name': HOST,
'uuid': 'test-00001'})
db.instance_get(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn({'availability_zone': ''})
+ mox.IgnoreArg()).AndReturn({'security_groups':
+ [{'id': 0}]})
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn('192.168.0.101')
@@ -372,6 +369,7 @@ class FlatNetworkTestCase(test.TestCase):
self.mox.StubOutWithMock(db, 'network_update')
self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool')
self.mox.StubOutWithMock(db, 'instance_get')
+ self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
self.mox.StubOutWithMock(db,
'virtual_interface_get_by_instance_and_network')
self.mox.StubOutWithMock(db, 'fixed_ip_update')
@@ -382,15 +380,13 @@ class FlatNetworkTestCase(test.TestCase):
db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(),
mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0})
- db.instance_get(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn({'security_groups':
- [{'id': 0}]})
-
db.instance_get(self.context,
1).AndReturn({'display_name': HOST,
'uuid': 'test-00001'})
db.instance_get(mox.IgnoreArg(),
- mox.IgnoreArg()).AndReturn({'availability_zone': ''})
+ mox.IgnoreArg()).AndReturn({'security_groups':
+ [{'id': 0}]})
+
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(fixedip)
@@ -446,12 +442,13 @@ class VlanNetworkTestCase(test.TestCase):
network = dict(networks[0])
network['vpn_private_address'] = '192.168.0.2'
network['id'] = None
+ instance = db.instance_create(self.context, {})
context_admin = context.RequestContext('testuser', 'testproject',
is_admin=True)
self.assertRaises(exception.FixedIpNotFoundForNetwork,
self.network.allocate_fixed_ip,
context_admin,
- 0,
+ instance['uuid'],
network,
vpn=True)
@@ -463,6 +460,8 @@ class VlanNetworkTestCase(test.TestCase):
self.mox.StubOutWithMock(db, 'instance_get')
db.instance_get(mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn({'uuid': FAKEUUID})
+ db.instance_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn({'security_groups':
[{'id': 0}]})
db.fixed_ip_associate_pool(mox.IgnoreArg(),
@@ -503,7 +502,7 @@ class VlanNetworkTestCase(test.TestCase):
mox.IgnoreArg()).AndReturn(networks)
fixed_ips[1]['network_id'] = networks[1]['id']
- fixed_ips[1]['instance_id'] = None
+ fixed_ips[1]['instance_uuid'] = None
db.fixed_ip_get_by_address(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(fixed_ips[1])
@@ -841,6 +840,8 @@ class VlanNetworkTestCase(test.TestCase):
'virtual_interface_get_by_instance_and_network')
self.mox.StubOutWithMock(db, 'fixed_ip_update')
+ db.instance_get(mox.IgnoreArg(),
+ mox.IgnoreArg()).AndReturn({'uuid': FAKEUUID})
db.fixed_ip_update(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg())
@@ -850,7 +851,8 @@ class VlanNetworkTestCase(test.TestCase):
db.instance_get(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn({'security_groups':
[{'id': 0}],
- 'availability_zone': ''})
+ 'availability_zone': '',
+ 'uuid': FAKEUUID})
db.fixed_ip_associate_pool(mox.IgnoreArg(),
mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn('192.168.0.101')
@@ -874,14 +876,14 @@ class VlanNetworkTestCase(test.TestCase):
address = '1.2.3.4'
float_addr = db.floating_ip_create(context1.elevated(),
- {'address': address,
- 'project_id': context1.project_id})
+ {'address': address,
+ 'project_id': context1.project_id})
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': 'project1'})
fix_addr = db.fixed_ip_associate_pool(context1.elevated(),
- 1, instance['id'])
+ 1, instance['uuid'])
# Associate the IP with non-admin user context
self.assertRaises(exception.NotAuthorized,
@@ -932,7 +934,7 @@ class VlanNetworkTestCase(test.TestCase):
{'project_id': 'project1'})
elevated = context1.elevated()
- fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['id'])
+ fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
values = {'allocated': True,
'virtual_interface_id': 3}
db.fixed_ip_update(elevated, fix_addr, values)
@@ -967,13 +969,13 @@ class VlanNetworkTestCase(test.TestCase):
{'project_id': 'project1'})
elevated = context1.elevated()
- fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['id'])
+ fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
db.fixed_ip_update(elevated, fix_addr, {'deleted': 1})
elevated.read_deleted = 'yes'
delfixed = db.fixed_ip_get_by_address(elevated, fix_addr)
values = {'address': fix_addr,
'network_id': 0,
- 'instance_id': delfixed['instance_id']}
+ 'instance_uuid': delfixed['instance_uuid']}
db.fixed_ip_create(elevated, values)
elevated.read_deleted = 'no'
newfixed = db.fixed_ip_get_by_address(elevated, fix_addr)
@@ -1000,10 +1002,10 @@ class VlanNetworkTestCase(test.TestCase):
context1 = context.RequestContext('user', 'project1')
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': 'project1'})
elevated = context1.elevated()
- fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['id'])
+ fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
values = {'allocated': True,
'virtual_interface_id': 3}
db.fixed_ip_update(elevated, fix_addr, values)
@@ -1458,12 +1460,12 @@ class AllocateTestCase(test.TestCase):
{'host': self.network.host})
project_id = self.context.project_id
nw_info = self.network.allocate_for_instance(self.context,
- instance_id=inst['id'],
- instance_uuid='',
- host=inst['host'],
- vpn=None,
- rxtx_factor=3,
- project_id=project_id)
+ instance_id=inst['id'],
+ instance_uuid='',
+ host=inst['host'],
+ vpn=None,
+ rxtx_factor=3,
+ project_id=project_id)
self.assertEquals(1, len(nw_info))
fixed_ip = nw_info.fixed_ips()[0]['address']
self.assertTrue(utils.is_valid_ipv4(fixed_ip))
diff --git a/nova/tests/network/test_quantum.py b/nova/tests/network/test_quantum.py
index 5299bde93..b126994d0 100644
--- a/nova/tests/network/test_quantum.py
+++ b/nova/tests/network/test_quantum.py
@@ -542,7 +542,7 @@ class QuantumNovaMACGenerationTestCase(QuantumNovaTestCase):
class QuantumNovaPortSecurityTestCase(QuantumNovaTestCase):
- def test_port_securty(self):
+ def test_port_security(self):
self.flags(use_melange_mac_generation=True)
self.flags(quantum_use_port_security=True)
fake_mac = "ab:cd:ef:ab:cd:ef"
@@ -578,7 +578,7 @@ class QuantumNovaPortSecurityTestCase(QuantumNovaTestCase):
requested_networks=requested_networks)
self.assertEqual(nw_info[0]['address'], fake_mac)
- def test_port_securty_negative(self):
+ def test_port_security_negative(self):
self.flags(use_melange_mac_generation=True)
self.flags(quantum_use_port_security=False)
fake_mac = "ab:cd:ef:ab:cd:ef"
@@ -593,7 +593,7 @@ class QuantumNovaPortSecurityTestCase(QuantumNovaTestCase):
requested_networks = [(n[0], None) for n in all_valid_networks]
instance_ref = db.api.instance_create(ctx,
- {"project_id": project_id})
+ {"project_id": project_id})
oldfunc = self.net_man.q_conn.create_and_attach_port
# Make sure no pairs are passed in if port security is turned off
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index acf0b1873..44efc0950 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -334,14 +334,14 @@ class DbApiTestCase(test.TestCase):
values = {'address': 'baz',
'network_id': 1,
'allocated': True,
- 'instance_id': instance['id'],
+ 'instance_uuid': instance['uuid'],
'virtual_interface_id': vif['id']}
fixed_address = db.fixed_ip_create(ctxt, values)
data = db.network_get_associated_fixed_ips(ctxt, 1)
self.assertEqual(len(data), 1)
record = data[0]
self.assertEqual(record['address'], fixed_address)
- self.assertEqual(record['instance_id'], instance['id'])
+ self.assertEqual(record['instance_uuid'], instance['uuid'])
self.assertEqual(record['network_id'], 1)
self.assertEqual(record['instance_created'], instance['created_at'])
self.assertEqual(record['instance_updated'], instance['updated_at'])
@@ -360,25 +360,25 @@ class DbApiTestCase(test.TestCase):
new = time = timeout + datetime.timedelta(seconds=5)
# should deallocate
values = {'allocated': False,
- 'instance_id': instance['id'],
+ 'instance_uuid': instance['uuid'],
'network_id': net['id'],
'updated_at': old}
db.fixed_ip_create(ctxt, values)
# still allocated
values = {'allocated': True,
- 'instance_id': instance['id'],
+ 'instance_uuid': instance['uuid'],
'network_id': net['id'],
'updated_at': old}
db.fixed_ip_create(ctxt, values)
# wrong network
values = {'allocated': False,
- 'instance_id': instance['id'],
+ 'instance_uuid': instance['uuid'],
'network_id': None,
'updated_at': old}
db.fixed_ip_create(ctxt, values)
# too new
values = {'allocated': False,
- 'instance_id': instance['id'],
+ 'instance_uuid': instance['uuid'],
'network_id': None,
'updated_at': new}
db.fixed_ip_create(ctxt, values)
@@ -830,27 +830,27 @@ class TestIpAllocation(test.TestCase):
def test_fixed_ip_associate_fails_if_ip_not_in_network(self):
self.assertRaises(exception.FixedIpNotFoundForNetwork,
db.fixed_ip_associate,
- self.ctxt, None, None)
+ self.ctxt, None, self.instance.uuid)
def test_fixed_ip_associate_fails_if_ip_in_use(self):
- address = self.create_fixed_ip(instance_id=self.instance.id)
+ address = self.create_fixed_ip(instance_uuid=self.instance.uuid)
self.assertRaises(exception.FixedIpAlreadyInUse,
db.fixed_ip_associate,
- self.ctxt, address, self.instance.id)
+ self.ctxt, address, self.instance.uuid)
def test_fixed_ip_associate_succeeds(self):
address = self.create_fixed_ip(network_id=self.network.id)
- db.fixed_ip_associate(self.ctxt, address, self.instance.id,
+ db.fixed_ip_associate(self.ctxt, address, self.instance.uuid,
network_id=self.network.id)
fixed_ip = db.fixed_ip_get_by_address(self.ctxt, address)
- self.assertEqual(fixed_ip.instance_id, self.instance.id)
+ self.assertEqual(fixed_ip.instance_uuid, self.instance.uuid)
def test_fixed_ip_associate_succeeds_and_sets_network(self):
address = self.create_fixed_ip()
- db.fixed_ip_associate(self.ctxt, address, self.instance.id,
+ db.fixed_ip_associate(self.ctxt, address, self.instance.uuid,
network_id=self.network.id)
fixed_ip = db.fixed_ip_get_by_address(self.ctxt, address)
- self.assertEqual(fixed_ip.instance_id, self.instance.id)
+ self.assertEqual(fixed_ip.instance_uuid, self.instance.uuid)
self.assertEqual(fixed_ip.network_id, self.network.id)