def test_reservation_rollback(self): reservations = _quota_reserve(self.ctxt, 'project1') expected = { 'project_id': 'project1', 'volumes': { 'reserved': 1, 'in_use': 0 }, 'gigabytes': { 'reserved': 2, 'in_use': 0 }, } self.assertEqual( expected, db.quota_usage_get_all_by_project(self.ctxt, 'project1')) db.reservation_get(self.ctxt, reservations[0]) db.reservation_rollback(self.ctxt, reservations, 'project1') self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, reservations[0]) expected = { 'project_id': 'project1', 'volumes': { 'reserved': 0, 'in_use': 0 }, 'gigabytes': { 'reserved': 0, 'in_use': 0 }, } self.assertEqual( expected, db.quota_usage_get_all_by_project(self.ctxt, 'project1'))
def test_reservation_get_all_by_project(self): reservations = _quota_reserve(self.ctxt, 'project1') r1 = db.reservation_get(self.ctxt, reservations[0]) r2 = db.reservation_get(self.ctxt, reservations[1]) expected = {'project_id': 'project1', r1['resource']: {r1['uuid']: r1['delta']}, r2['resource']: {r2['uuid']: r2['delta']}} self.assertEqual(expected, db.reservation_get_all_by_project( self.ctxt, 'project1'))
def test_reservation_get_all_by_project(self): reservations = _quota_reserve(self.ctxt, "project1") r1 = db.reservation_get(self.ctxt, reservations[0]) r2 = db.reservation_get(self.ctxt, reservations[1]) expected = { "project_id": "project1", r1["resource"]: {r1["uuid"]: r1["delta"]}, r2["resource"]: {r2["uuid"]: r2["delta"]}, } self.assertEqual(expected, db.reservation_get_all_by_project(self.ctxt, "project1"))
def test_reservation_get_all_by_project(self): reservations = _quota_reserve(self.ctxt, 'project1') r1 = db.reservation_get(self.ctxt, reservations[0]) r2 = db.reservation_get(self.ctxt, reservations[1]) expected = { 'project_id': 'project1', r1['resource']: { r1['uuid']: r1['delta'] }, r2['resource']: { r2['uuid']: r2['delta'] } } self.assertEqual( expected, db.reservation_get_all_by_project(self.ctxt, 'project1'))
def test_quota_reserve(self): reservations = _quota_reserve(self.ctxt, 'project1') self.assertEqual(len(reservations), 2) res_names = ['gigabytes', 'volumes'] for uuid in reservations: reservation = db.reservation_get(self.ctxt, uuid) self.assertIn(reservation.resource, res_names) res_names.remove(reservation.resource)
def test_quota_reserve(self): reservations = _quota_reserve(self.ctxt, 'project1') self.assertEqual(len(reservations), 2) res_names = ['gigabytes', 'volumes'] for uuid in reservations: reservation = db.reservation_get(self.ctxt, uuid) self.assertTrue(reservation.resource in res_names) res_names.remove(reservation.resource)
def test_quota_reserve(self): reservations = _quota_reserve(self.ctxt, 'project1') self.assertEqual(len(reservations), 3) res_names = ['res0', 'res1', 'res2'] for uuid in reservations: reservation = db.reservation_get(self.ctxt, uuid) self.assertTrue(reservation.resource in res_names) res_names.remove(reservation.resource)
def test_quota_reserve(self): reservations = _quota_reserve(self.ctxt, "project1") self.assertEqual(len(reservations), 2) res_names = ["gigabytes", "volumes"] for uuid in reservations: reservation = db.reservation_get(self.ctxt, uuid) self.assertIn(reservation.resource, res_names) res_names.remove(reservation.resource)
def test_reservation_rollback(self): reservations = _quota_reserve(self.ctxt, "project1") expected = { "project_id": "project1", "volumes": {"reserved": 1, "in_use": 0}, "gigabytes": {"reserved": 2, "in_use": 0}, } self.assertEqual(expected, db.quota_usage_get_all_by_project(self.ctxt, "project1")) db.reservation_get(self.ctxt, reservations[0]) db.reservation_rollback(self.ctxt, reservations, "project1") self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, reservations[0]) expected = { "project_id": "project1", "volumes": {"reserved": 0, "in_use": 0}, "gigabytes": {"reserved": 0, "in_use": 0}, } self.assertEqual(expected, db.quota_usage_get_all_by_project(self.ctxt, "project1"))
def test_reservation_commit(self): reservations = _quota_reserve(self.ctxt, 'project1') expected = { 'project_id': 'project1', 'res0': { 'reserved': 0, 'in_use': 0 }, 'res1': { 'reserved': 1, 'in_use': 1 }, 'res2': { 'reserved': 2, 'in_use': 2 } } self.assertEqual( expected, db.quota_usage_get_all_by_project(self.ctxt, 'project1')) db.reservation_get(self.ctxt, reservations[0]) db.reservation_commit(self.ctxt, reservations, 'project1') self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, reservations[0]) expected = { 'project_id': 'project1', 'res0': { 'reserved': 0, 'in_use': 0 }, 'res1': { 'reserved': 0, 'in_use': 2 }, 'res2': { 'reserved': 0, 'in_use': 4 } } self.assertEqual( expected, db.quota_usage_get_all_by_project(self.ctxt, 'project1'))
def test_reservation_commit(self): reservations = _quota_reserve(self.ctxt, 'project1') expected = {'project_id': 'project1', 'volumes': {'reserved': 1, 'in_use': 0}, 'gigabytes': {'reserved': 2, 'in_use': 0}, } self.assertEqual(expected, db.quota_usage_get_all_by_project( self.ctxt, 'project1')) db.reservation_get(self.ctxt, reservations[0]) db.reservation_commit(self.ctxt, reservations, 'project1') self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, reservations[0]) expected = {'project_id': 'project1', 'volumes': {'reserved': 0, 'in_use': 1}, 'gigabytes': {'reserved': 0, 'in_use': 2}, } self.assertEqual(expected, db.quota_usage_get_all_by_project( self.ctxt, 'project1'))
def test_reservation_rollback(self): reservations = _quota_reserve(self.ctxt, 'project1') expected = {'project_id': 'project1', 'res0': {'reserved': 0, 'in_use': 0}, 'res1': {'reserved': 1, 'in_use': 1}, 'res2': {'reserved': 2, 'in_use': 2}} self.assertEqual(expected, db.quota_usage_get_all_by_project( self.ctxt, 'project1')) db.reservation_get(self.ctxt, reservations[0]) db.reservation_rollback(self.ctxt, reservations, 'project1') self.assertRaises(exception.ReservationNotFound, db.reservation_get, self.ctxt, reservations[0]) expected = {'project_id': 'project1', 'res0': {'reserved': 0, 'in_use': 0}, 'res1': {'reserved': 0, 'in_use': 1}, 'res2': {'reserved': 0, 'in_use': 2}} self.assertEqual(expected, db.quota_usage_get_all_by_project( self.ctxt, 'project1'))
def test_reservation_get(self): reservation = db.reservation_create(self.ctxt, **self.values) reservation_db = db.reservation_get(self.ctxt, self.values['uuid']) self._assertEqualObjects(reservation, reservation_db)