Snapshots/backups can no longer happen simultaneously. Tests included.
Implemented exception.InstanceBusy when attempting to snapshot/backup an instance which is already snapshotting or being currently backed up. Fixes bug 727502. (Patch Set 2) 3 new exceptions: InstanceBusy, InstanceSnapshotting, and InstanceBackingUp (Patch Set 3) Oops. New exceptions now inherit from InstanceBusy (Patch Set 4) Tests now tear down created instances Change-Id: I9614740bba26c04e64b0e27c24fbace12334f4d1
This commit is contained in:
@@ -36,6 +36,7 @@ from nova import utils
|
||||
from nova.compute import instance_types
|
||||
from nova.compute import manager as compute_manager
|
||||
from nova.compute import power_state
|
||||
from nova.compute import task_states
|
||||
from nova.compute import vm_states
|
||||
from nova.db.sqlalchemy import models
|
||||
from nova.image import fake as fake_image
|
||||
@@ -401,6 +402,36 @@ class ComputeTestCase(test.TestCase):
|
||||
self.compute.snapshot_instance(self.context, instance_id, name)
|
||||
self.compute.terminate_instance(self.context, instance_id)
|
||||
|
||||
def test_snapshot_conflict_backup(self):
|
||||
"""Can't backup an instance which is already being backed up."""
|
||||
instance_id = self._create_instance()
|
||||
instance_values = {'task_state': task_states.IMAGE_BACKUP}
|
||||
db.instance_update(self.context, instance_id, instance_values)
|
||||
|
||||
self.assertRaises(exception.InstanceBackingUp,
|
||||
self.compute_api.backup,
|
||||
self.context,
|
||||
instance_id,
|
||||
None,
|
||||
None,
|
||||
None)
|
||||
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
|
||||
def test_snapshot_conflict_snapshot(self):
|
||||
"""Can't snapshot an instance which is already being snapshotted."""
|
||||
instance_id = self._create_instance()
|
||||
instance_values = {'task_state': task_states.IMAGE_SNAPSHOT}
|
||||
db.instance_update(self.context, instance_id, instance_values)
|
||||
|
||||
self.assertRaises(exception.InstanceSnapshotting,
|
||||
self.compute_api.snapshot,
|
||||
self.context,
|
||||
instance_id,
|
||||
None)
|
||||
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
|
||||
def test_console_output(self):
|
||||
"""Make sure we can get console output from instance"""
|
||||
instance_id = self._create_instance()
|
||||
|
Reference in New Issue
Block a user