[placement] cover deleting a custom resource class in use

If there is inventory or allocations of a custom resource class we
shouldn't be able to delete. This added gabbi file create a resource
provider and a resource class, sets some inventory, adds an allocation
and then tries to delete the resource class. When there is any inventory
the response should 409.

Change-Id: Iee3095cd23a4559d3c6a2f2202fe76e29bf7e9d9
This commit is contained in:
Chris Dent 2017-07-15 17:55:59 +01:00
parent 4b73b3bca9
commit 36408b56e7
1 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,78 @@
# A sequence of tests that confirms that a resource class in use
# cannot be deleted.
fixtures:
- APIFixture
defaults:
request_headers:
x-auth-token: admin
accept: application/json
content-type: application/json
OpenStack-API-Version: placement latest
tests:
- name: create a resource provider
POST: /resource_providers
data:
name: an rp
status: 201
- name: get resource provider
GET: $LOCATION
status: 200
- name: create a resource class
PUT: /resource_classes/CUSTOM_GOLD
status: 201
- name: add inventory to an rp
PUT: /resource_providers/$HISTORY['get resource provider'].$RESPONSE['$.uuid']/inventories
data:
resource_provider_generation: 0
inventories:
VCPU:
total: 24
CUSTOM_GOLD:
total: 5
status: 200
- name: allocate some of it
PUT: /allocations/6d9f83db-6eb5-49f6-84b0-5d03c6aa9fc8
data:
allocations:
- resource_provider:
uuid: $HISTORY['get resource provider'].$RESPONSE['$.uuid']
resources:
VCPU: 5
CUSTOM_GOLD: 1
project_id: 42a32c07-3eeb-4401-9373-68a8cdca6784
user_id: 66cb2f29-c86d-47c3-8af5-69ae7b778c70
status: 204
- name: fail delete resource class allocations
DELETE: /resource_classes/CUSTOM_GOLD
status: 409
response_strings:
- Unable to delete resource class
- Class is in use in inventory
- name: delete the allocation
DELETE: $HISTORY['allocate some of it'].$URL
status: 204
- name: fail delete resource class inventory
DELETE: /resource_classes/CUSTOM_GOLD
status: 409
response_strings:
- Unable to delete resource class
- Class is in use in inventory
- name: delete the inventory
DELETE: $HISTORY['add inventory to an rp'].$URL
status: 204
- name: delete resource class
DELETE: /resource_classes/CUSTOM_GOLD
status: 204