placement/placement/tests/functional/gabbits/allocations-bug-1778591.yaml

72 lines
2.2 KiB
YAML

# Demonstrate part of bug 1778591, where when creating an allocation for
# a new consumer will create the consumer and its generation, but if it
# fails the subsequent request requires generation 0, not null, which is
# not what we expect. This is made more problematic in the we cannot query
# the generation when the consumer has no allocations.
fixtures:
- APIFixture
defaults:
request_headers:
x-auth-token: admin
# consumer generations were added in 1.28
openstack-api-version: placement 1.28
content-type: application/json
accept: application/json
tests:
# create a simple resource provider with limited inventory
- name: create provider
POST: /resource_providers
data:
name: simple
uuid: $ENVIRON['RP_UUID']
- name: set inventory
PUT: /resource_providers/$ENVIRON['RP_UUID']/inventories
data:
resource_provider_generation: 0
inventories:
VCPU:
total: 4
- name: fail allocations new consumer, bad capacity
PUT: /allocations/88888888-8888-8888-8888-888888888888
data:
allocations:
"$ENVIRON['RP_UUID']":
resources:
VCPU: 9999
project_id: $ENVIRON['PROJECT_ID']
user_id: $ENVIRON['USER_ID']
consumer_generation: null
status: 409
response_strings:
- The requested amount would exceed the capacity
- name: try to get consumer generation
desc: when there are no allocations we can't see the generation of a consumer
GET: /allocations/88888888-8888-8888-8888-888888888888
response_json_paths:
# check entire response
$:
allocations: {}
# The failure to allocate above should have deleted the auto-created consumer,
# so when we retry the allocation here, we should be able to use the
# appropriate null generation to indicate this is a new consumer
- name: retry allocations new consumer, still null gen
PUT: /allocations/88888888-8888-8888-8888-888888888888
data:
allocations:
"$ENVIRON['RP_UUID']":
resources:
VCPU: 1
project_id: $ENVIRON['PROJECT_ID']
user_id: $ENVIRON['USER_ID']
consumer_generation: null
status: 204