nova/nova/tests/functional/api/openstack/placement/gabbits/allocation-candidates.yaml
Chris Dent 7792ba33a0 [placement] Update allocation-candidates.yaml for gabbi 1.35
Gabbi 1.35 provides template variable susbtitution on the left hand side
of a JSONPath expression. That's used here to remove the need for static
fake uuids in the test data for allocation-candidates and the
SharedStorageFixture.

A couple of other clean ups to the use of gabbi, unrelated to the 1.35
update:

* It's possible to test the entire value in one response:

    resources:
         VCPU: 4
         DISK_GB: 5

  instead of:

    resources.VCPU: 4
    resources.DISK_GB: 5

  This is handy when the root of the expression is calculated and
  repeating that calculation is noisy.

* [?foo.bar=baz] is the more canonical form of [?(@.foo.bar=baz)]. The
  former is built into jsonpath, the latter dips into the underlying
  implementation.

Change-Id: Ie6b5e0186533581815d04411ed7b321948464bb6
2017-07-17 13:04:48 +00:00

79 lines
3.4 KiB
YAML

# Tests of allocation candidates API
fixtures:
- SharedStorageFixture
defaults:
request_headers:
x-auth-token: admin
accept: application/json
openstack-api-version: placement 1.10
tests:
- name: list traits
GET: /traits
status: 200
response_strings:
# We at least want to make sure that this trait is supported.
- MISC_SHARES_VIA_AGGREGATE
- name: get allocation candidates before microversion
GET: /allocation_candidates?resources=VCPU:1
request_headers:
openstack-api-version: placement 1.8
status: 404
- name: get allocation candidates no resources
GET: /allocation_candidates
status: 400
response_strings:
- "'resources' is a required property"
- name: get bad resource class
GET: /allocation_candidates?resources=MCPU:99
status: 400
response_strings:
- Invalid resource class in resources parameter
- name: get allocation candidates no allocations yet
GET: /allocation_candidates?resources=VCPU:1,MEMORY_MB:1024,DISK_GB:100
status: 200
response_json_paths:
# There are 3 providers involved. 2 compute nodes, 1 shared storage
# provider
$.provider_summaries.`len`: 3
# However, there are only 2 allocation requests, one for each compute
# node that provides the VCPU/MEMORY_MB and DISK_GB provided by the
# shared storage provider
$.allocation_requests.`len`: 2
# Verify that compute node #1 only has VCPU and MEMORY_MB listed in the
# resource requests. This validates the entire resources key.
$.allocation_requests..allocations[?resource_provider.uuid="$ENVIRON['CN1_UUID']"].resources:
VCPU: 1
MEMORY_MB: 1024
# Verify that compute node #2 only has VCPU and MEMORY_MB listed in the
# resource requests
$.allocation_requests..allocations[?resource_provider.uuid="$ENVIRON['CN2_UUID']"].resources:
VCPU: 1
MEMORY_MB: 1024
# Verify that shared storage provider only has DISK_GB listed in the
# resource requests, but is listed twice
$.allocation_requests..allocations[?resource_provider.uuid="$ENVIRON['SS_UUID']"].resources[DISK_GB]: [100, 100]
# Verify that the resources listed in the provider summary for compute
# node #1 show correct capacity and usage
$.provider_summaries["$ENVIRON['CN1_UUID']"].resources[VCPU].capacity: 384 # 16.0 * 24
$.provider_summaries["$ENVIRON['CN1_UUID']"].resources[VCPU].used: 0
$.provider_summaries["$ENVIRON['CN1_UUID']"].resources[MEMORY_MB].capacity: 196608 # 1.5 * 128G
$.provider_summaries["$ENVIRON['CN1_UUID']"].resources[MEMORY_MB].used: 0
# Verify that the resources listed in the provider summary for compute
# node #2 show correct capacity and usage
$.provider_summaries["$ENVIRON['CN2_UUID']"].resources[VCPU].capacity: 384 # 16.0 * 24
$.provider_summaries["$ENVIRON['CN2_UUID']"].resources[VCPU].used: 0
$.provider_summaries["$ENVIRON['CN2_UUID']"].resources[MEMORY_MB].capacity: 196608 # 1.5 * 128G
$.provider_summaries["$ENVIRON['CN2_UUID']"].resources[MEMORY_MB].used: 0
# Verify that the resources listed in the provider summary for shared
# storage show correct capacity and usage
$.provider_summaries["$ENVIRON['SS_UUID']"].resources[DISK_GB].capacity: 1900 # 1.0 * 2000 - 100G
$.provider_summaries["$ENVIRON['SS_UUID']"].resources[DISK_GB].used: 0