diff options
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 22 | ||||
| -rw-r--r-- | nova/tests/conductor/test_conductor.py | 42 |
2 files changed, 20 insertions, 44 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 3fdd79731..aa58e7999 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -2065,25 +2065,31 @@ class ComputeTestCase(BaseTestCase): for operation in actions: self._test_state_revert(instance, *operation) - def _ensure_quota_reservations_committed(self): + def _ensure_quota_reservations_committed(self, expect_project=False): """Mock up commit of quota reservations.""" reservations = list('fake_res') self.mox.StubOutWithMock(nova.quota.QUOTAS, 'commit') - nova.quota.QUOTAS.commit(mox.IgnoreArg(), reservations) + nova.quota.QUOTAS.commit(mox.IgnoreArg(), reservations, + project_id=(expect_project and + self.context.project_id or + None)) self.mox.ReplayAll() return reservations - def _ensure_quota_reservations_rolledback(self): + def _ensure_quota_reservations_rolledback(self, expect_project=False): """Mock up rollback of quota reservations.""" reservations = list('fake_res') self.mox.StubOutWithMock(nova.quota.QUOTAS, 'rollback') - nova.quota.QUOTAS.rollback(mox.IgnoreArg(), reservations) + nova.quota.QUOTAS.rollback(mox.IgnoreArg(), reservations, + project_id=(expect_project and + self.context.project_id or + None)) self.mox.ReplayAll() return reservations def test_quotas_succesful_delete(self): instance = jsonutils.to_primitive(self._create_fake_instance()) - resvs = self._ensure_quota_reservations_committed() + resvs = self._ensure_quota_reservations_committed(True) self.compute.terminate_instance(self.context, instance, bdms=None, reservations=resvs) @@ -2096,7 +2102,7 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(self.compute, '_shutdown_instance', fake_shutdown_instance) - resvs = self._ensure_quota_reservations_rolledback() + resvs = self._ensure_quota_reservations_rolledback(True) self.assertRaises(test.TestingException, self.compute.terminate_instance, self.context, instance, @@ -2105,7 +2111,7 @@ class ComputeTestCase(BaseTestCase): def test_quotas_succesful_soft_delete(self): instance = jsonutils.to_primitive(self._create_fake_instance( params=dict(task_state=task_states.SOFT_DELETING))) - resvs = self._ensure_quota_reservations_committed() + resvs = self._ensure_quota_reservations_committed(True) self.compute.soft_delete_instance(self.context, instance, reservations=resvs) @@ -2119,7 +2125,7 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(self.compute.driver, 'soft_delete', fake_soft_delete) - resvs = self._ensure_quota_reservations_rolledback() + resvs = self._ensure_quota_reservations_rolledback(True) self.assertRaises(test.TestingException, self.compute.soft_delete_instance, self.context, instance, diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index dd779c778..df0f5e73b 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -546,15 +546,19 @@ class _BaseTestCase(object): def test_quota_commit(self): self.mox.StubOutWithMock(quota.QUOTAS, 'commit') - quota.QUOTAS.commit(self.context, 'reservations') + quota.QUOTAS.commit(self.context, 'reservations', project_id=None) + quota.QUOTAS.commit(self.context, 'reservations', project_id='proj') self.mox.ReplayAll() self.conductor.quota_commit(self.context, 'reservations') + self.conductor.quota_commit(self.context, 'reservations', 'proj') def test_quota_rollback(self): self.mox.StubOutWithMock(quota.QUOTAS, 'rollback') - quota.QUOTAS.rollback(self.context, 'reservations') + quota.QUOTAS.rollback(self.context, 'reservations', project_id=None) + quota.QUOTAS.rollback(self.context, 'reservations', project_id='proj') self.mox.ReplayAll() self.conductor.quota_rollback(self.context, 'reservations') + self.conductor.quota_rollback(self.context, 'reservations', 'proj') def test_get_ec2_ids(self): expected = { @@ -1067,40 +1071,6 @@ 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.""" |
