summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-11-17 16:08:10 -0500
committerAlex Meade <alex.meade@rackspace.com>2011-11-18 10:35:20 -0500
commit265d77e16774f37775c6befbf34837d165ca844e (patch)
treece03311371baf25ef2be46e3b2e643b3c53226c6 /nova/tests
parent15937a41609a0216020aa23a8debbd10c1f74de6 (diff)
snapshot/backup in compute manager to use uuids
Related to blueprint internal-uuids. Changes shapshot in the computer manager to expect uuids instead of ids. Also updates some compute api fakes. Change-Id: I525754ea065c7df9dfe1d093e4c94c02bebf4c02
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/fakes.py13
-rw-r--r--nova/tests/test_compute.py22
2 files changed, 18 insertions, 17 deletions
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py
index c12ae5eab..9f5383944 100644
--- a/nova/tests/api/openstack/fakes.py
+++ b/nova/tests/api/openstack/fakes.py
@@ -168,11 +168,10 @@ class stub_out_compute_api_snapshot(object):
self.extra_props_last_call = None
stubs.Set(nova.compute.API, 'snapshot', self.snapshot)
- def snapshot(self, context, instance_id, name, extra_properties=None):
+ def snapshot(self, context, instance, name, extra_properties=None):
self.extra_props_last_call = extra_properties
- props = dict(instance_id=instance_id, instance_ref=instance_id)
- props.update(extra_properties or {})
- return dict(id='123', status='ACTIVE', name=name, properties=props)
+ return dict(id='123', status='ACTIVE', name=name,
+ properties=extra_properties)
class stub_out_compute_api_backup(object):
@@ -182,11 +181,11 @@ class stub_out_compute_api_backup(object):
self.extra_props_last_call = None
stubs.Set(nova.compute.API, 'backup', self.backup)
- def backup(self, context, instance_id, name, backup_type, rotation,
+ def backup(self, context, instance, name, backup_type, rotation,
extra_properties=None):
self.extra_props_last_call = extra_properties
- props = dict(instance_id=instance_id, instance_ref=instance_id,
- backup_type=backup_type, rotation=rotation)
+ props = dict(backup_type=backup_type,
+ rotation=rotation)
props.update(extra_properties or {})
return dict(id='123', status='ACTIVE', name=name, properties=props)
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index 397b5e268..93cf1a935 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -333,10 +333,12 @@ class ComputeTestCase(BaseTestCase):
def test_snapshot(self):
"""Ensure instance can be snapshotted"""
- instance_id = self._create_instance()
+ instance = self._create_fake_instance()
+ instance_id = instance['id']
+ instance_uuid = instance['uuid']
name = "myfakesnapshot"
self.compute.run_instance(self.context, instance_id)
- self.compute.snapshot_instance(self.context, instance_id, name)
+ self.compute.snapshot_instance(self.context, instance_uuid, name)
self.compute.terminate_instance(self.context, instance_id)
def test_console_output(self):
@@ -1316,21 +1318,20 @@ class ComputeAPITestCase(BaseTestCase):
def test_snapshot(self):
"""Can't backup an instance which is already being backed up."""
- instance_id = self._create_instance()
- instance = self.compute_api.get(self.context, instance_id)
+ instance = self._create_fake_instance()
self.compute_api.snapshot(self.context, instance, None, None)
- db.instance_destroy(self.context, instance_id)
+ db.instance_destroy(self.context, instance['id'])
def test_backup(self):
"""Can't backup an instance which is already being backed up."""
- instance_id = self._create_instance()
- instance = self.compute_api.get(self.context, instance_id)
+ instance = self._create_fake_instance()
self.compute_api.backup(self.context, instance, None, None, None)
- db.instance_destroy(self.context, instance_id)
+ db.instance_destroy(self.context, instance['id'])
def test_backup_conflict(self):
"""Can't backup an instance which is already being backed up."""
- instance_id = self._create_instance()
+ instance = self._create_fake_instance()
+ instance_id = instance['id']
instance_values = {'task_state': task_states.IMAGE_BACKUP}
db.instance_update(self.context, instance_id, instance_values)
instance = self.compute_api.get(self.context, instance_id)
@@ -1347,7 +1348,8 @@ class ComputeAPITestCase(BaseTestCase):
def test_snapshot_conflict(self):
"""Can't snapshot an instance which is already being snapshotted."""
- instance_id = self._create_instance()
+ instance = self._create_fake_instance()
+ instance_id = instance['id']
instance_values = {'task_state': task_states.IMAGE_SNAPSHOT}
db.instance_update(self.context, instance_id, instance_values)
instance = self.compute_api.get(self.context, instance_id)