diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-01-02 14:29:49 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-01-02 14:29:49 +0000 |
| commit | 4c5e2ef5e87d07945893f7e38d00a0325870549b (patch) | |
| tree | 4065b1b486b1e1ea972adfcdb439faeac2862dfd /nova/tests | |
| parent | 5f9641c979d8f9fe21440cbc7fa087b279bebd79 (diff) | |
| parent | e313c7dda326d8e6cb5b0e2ac77f53becc037a16 (diff) | |
Merge "Fix bug and remove update lock in db.instance_test_and_set()"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_db_api.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 29bce8bf5..ea6e9aea5 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -284,6 +284,27 @@ class DbApiTestCase(test.TestCase): self.assertRaises(exception.DuplicateVlan, db.network_create_safe, ctxt, values2) + def test_instance_test_and_set(self): + ctxt = context.get_admin_context() + states = [ + (None, [None, 'some'], 'building'), + (None, [None], 'building'), + ('building', ['building'], 'ready'), + ('building', [None, 'building'], 'ready')] + for st in states: + inst = db.instance_create(ctxt, {'vm_state': st[0]}) + uuid = inst['uuid'] + db.instance_test_and_set(ctxt, uuid, 'vm_state', st[1], st[2]) + inst = db.instance_get_by_uuid(ctxt, uuid) + self.assertEqual(inst["vm_state"], st[2]) + + def test_instance_test_and_set_exception(self): + ctxt = context.get_admin_context() + inst = db.instance_create(ctxt, {'vm_state': 'building'}) + self.assertRaises(exception.InstanceInvalidState, + db.instance_test_and_set, ctxt, + inst['uuid'], 'vm_state', [None, 'disable'], 'run') + def test_instance_update_with_instance_uuid(self): """ test instance_update() works when an instance UUID is passed """ ctxt = context.get_admin_context() |
