diff options
| author | Boris Pavlovic <boris@pavlovic.me> | 2012-12-23 07:03:55 +0400 |
|---|---|---|
| committer | Boris Pavlovic <boris@pavlovic.me> | 2012-12-28 22:39:02 +0400 |
| commit | e313c7dda326d8e6cb5b0e2ac77f53becc037a16 (patch) | |
| tree | 7be2d9b554b51a733b4248a8d4632ea43293b820 /nova/tests | |
| parent | 8a1843a91a98cf5b945ed97adb82c2f820438949 (diff) | |
Fix bug and remove update lock in db.instance_test_and_set()
Remove session from arguments.
Instance update works through one query, so we don't need to use update lock.
Add tests for instance_test_and_set().
blueprint db-session-cleanup
Change-Id: I143877f427f5eba4a7c7aa985bb70c79a9513822
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() |
