diff options
author | melanie witt <melwittt@gmail.com> | 2017-05-28 01:36:07 +0000 |
---|---|---|
committer | melanie witt <melwittt@gmail.com> | 2017-06-15 18:23:37 +0000 |
commit | a909673682cdd8f02ef0ae5e8c6f061640e320ff (patch) | |
tree | 11e829f7782c30a007f1f471e936265a877be364 /nova/tests/functional/db | |
parent | df5b135053558714c67be1fb5673e20b5fbfe01b (diff) | |
download | nova-a909673682cdd8f02ef0ae5e8c6f061640e320ff.tar.gz |
placement project_id, user_id in PUT /allocations
This adds project_id and user_id required request parameters as part of
a new microversion 1.8 of the placement API.
Two new fields, for project and user ID, have been added to the
AllocationList object, and the method AllocationList.create_all() has
been changed to ensure that records are written to the consumers,
projects, and users tables when project_id and user_id are not None.
After an upgrade, new allocations will write consumer records and
existing allocations will have corresponding consumer records written
when they are updated as part of the resource tracker periodic task for
updating available resources.
Part of blueprint placement-project-user
Co-Authored-By: Jay Pipes <jaypipes@gmail.com>
Change-Id: I3c3b0cfdd33da87160255ead51a0d9ff73667655
Diffstat (limited to 'nova/tests/functional/db')
-rw-r--r-- | nova/tests/functional/db/test_resource_provider.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/nova/tests/functional/db/test_resource_provider.py b/nova/tests/functional/db/test_resource_provider.py index c95bc88cf7..9fd9bd2995 100644 --- a/nova/tests/functional/db/test_resource_provider.py +++ b/nova/tests/functional/db/test_resource_provider.py @@ -1213,6 +1213,51 @@ class TestAllocationListCreateDelete(ResourceProviderBaseCase): self._check_create_allocations(inventory_kwargs, bad_used, good_used) + def test_create_all_with_project_user(self): + consumer_uuid = uuidsentinel.consumer + rp_class = fields.ResourceClass.DISK_GB + rp = self._make_rp_and_inventory(resource_class=rp_class, + max_unit=500) + allocation1 = objects.Allocation(resource_provider=rp, + consumer_id=consumer_uuid, + resource_class=rp_class, + used=100) + allocation2 = objects.Allocation(resource_provider=rp, + consumer_id=consumer_uuid, + resource_class=rp_class, + used=200) + allocation_list = objects.AllocationList( + self.context, + objects=[allocation1, allocation2], + project_id=self.context.project_id, + user_id=self.context.user_id, + ) + allocation_list.create_all() + + # Verify that we have records in the consumers, projects, and users + # table for the information used in the above allocation creation + with self.api_db.get_engine().connect() as conn: + tbl = rp_obj._PROJECT_TBL + sel = sa.select([tbl.c.id]).where( + tbl.c.external_id == self.context.project_id, + ) + res = conn.execute(sel).fetchall() + self.assertEqual(1, len(res), "project lookup not created.") + + tbl = rp_obj._USER_TBL + sel = sa.select([tbl.c.id]).where( + tbl.c.external_id == self.context.user_id, + ) + res = conn.execute(sel).fetchall() + self.assertEqual(1, len(res), "user lookup not created.") + + tbl = rp_obj._CONSUMER_TBL + sel = sa.select([tbl.c.id]).where( + tbl.c.uuid == consumer_uuid, + ) + res = conn.execute(sel).fetchall() + self.assertEqual(1, len(res), "consumer lookup not created.") + class UsageListTestCase(ResourceProviderBaseCase): |