summaryrefslogtreecommitdiffstats
path: root/nova/tests/conductor
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2013-03-11 00:20:23 -0700
committerChris Behrens <cbehrens@codestud.com>2013-03-11 19:26:49 -0700
commit652a487ed9daba9ae97f7df77ae35720322d1af3 (patch)
treed21de2ac493af0334aa7f4942e2893e141861006 /nova/tests/conductor
parentf543f347c84e7f5de2c584ca55363e4dee5b0a3d (diff)
downloadnova-652a487ed9daba9ae97f7df77ae35720322d1af3.tar.gz
nova-652a487ed9daba9ae97f7df77ae35720322d1af3.tar.xz
nova-652a487ed9daba9ae97f7df77ae35720322d1af3.zip
Fix quota issues with instance deletes.
In order to keep quotas in sync as much as possible, only commit quota changes for delete when: 1) An instance's vm_state is updated to be SOFT_DELETED. 2) The DB record is marked as deleted (and the instance's vm_state is not SOFT_DELETED) If a host is down and we delete the instance in the API, this means quotas are committed within the API. Otherwise, quotas are committed on the manager side. Fixes bug 1098380 Also needed for proper testing: Fixed compute cells tests so that pseudo child cells use NoopQuotaDriver. This uncovered inconsistencies in the NoopQuotaDriver wrt the DBQuotaDriver. Those issues were fixed as well. Change-Id: Ib72de1a457f0c5056d55a5c7dd4d8d7c69708996
Diffstat (limited to 'nova/tests/conductor')
-rw-r--r--nova/tests/conductor/test_conductor.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py
index 72c04e427..00f7faac5 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -990,6 +990,40 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
self.conductor.security_groups_trigger_handler(self.context,
'event', 'arg')
+ def test_quota_commit_with_project_id(self):
+ diff_proj_id = 'diff_fake_proj_id'
+ self.assertNotEqual(self.context.project_id, diff_proj_id)
+ call_info = {}
+
+ def mgr_quota_commit(ctxt, reservations):
+ call_info['resvs'] = reservations
+ call_info['project_id'] = ctxt.project_id
+
+ self.stubs.Set(self.conductor_manager, 'quota_commit',
+ mgr_quota_commit)
+
+ self.conductor.quota_commit(self.context, 'fake_resvs',
+ project_id=diff_proj_id)
+ self.assertEqual(diff_proj_id, call_info['project_id'])
+ self.assertEqual('fake_resvs', call_info['resvs'])
+
+ def test_quota_rollback_with_project_id(self):
+ diff_proj_id = 'diff_fake_proj_id'
+ self.assertNotEqual(self.context.project_id, diff_proj_id)
+ call_info = {}
+
+ def mgr_quota_rollback(ctxt, reservations):
+ call_info['resvs'] = reservations
+ call_info['project_id'] = ctxt.project_id
+
+ self.stubs.Set(self.conductor_manager, 'quota_rollback',
+ mgr_quota_rollback)
+
+ self.conductor.quota_rollback(self.context, 'fake_resvs',
+ project_id=diff_proj_id)
+ self.assertEqual(diff_proj_id, call_info['project_id'])
+ self.assertEqual('fake_resvs', call_info['resvs'])
+
class ConductorLocalAPITestCase(ConductorAPITestCase):
"""Conductor LocalAPI Tests."""