[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
This commit is contained in:
Chris Dent 2017-07-17 13:28:36 +01:00
parent 551fb91ebb
commit 7792ba33a0
3 changed files with 27 additions and 39 deletions

View File

@ -206,19 +206,14 @@ class SharedStorageFixture(APIFixture):
super(SharedStorageFixture, self).start_fixture()
self.context = context.get_admin_context()
# These UUIDs are staticly defined here because the JSONPath querying
# needed in the allocation-candidates.yaml gabbits cannot refer to an
# ENVIRON variable because the $ sign is a token in the JSONPath
# parser.
os.environ['CN1_UUID'] = 'c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d'
os.environ['CN2_UUID'] = 'c2c2c2c2-beef-49a0-98a0-b998b88debfd'
os.environ['SS_UUID'] = 'dddddddd-61a6-472e-b8c1-74796e803066'
os.environ['AGG_UUID'] = 'aaaaaaaa-04b3-458c-9a9f-361aad56f41c'
cn1_uuid = os.environ['CN1_UUID']
cn2_uuid = os.environ['CN2_UUID']
ss_uuid = os.environ['SS_UUID']
agg_uuid = os.environ['AGG_UUID']
cn1_uuid = uuidutils.generate_uuid()
cn2_uuid = uuidutils.generate_uuid()
ss_uuid = uuidutils.generate_uuid()
agg_uuid = uuidutils.generate_uuid()
os.environ['CN1_UUID'] = cn1_uuid
os.environ['CN2_UUID'] = cn2_uuid
os.environ['SS_UUID'] = ss_uuid
os.environ['AGG_UUID'] = agg_uuid
cn1 = objects.ResourceProvider(
self.context,

View File

@ -11,15 +11,6 @@ defaults:
tests:
# NOTE(jaypipes): The following static UUIDs are used in this file. We use
# static UUIDs because JSONPath's parser cannot understand $ subtitution if we
# refer to them with $ENVIRON[]
#
# os.environ['CN1_UUID'] = 'c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d'
# os.environ['CN2_UUID'] = 'c2c2c2c2-beef-49a0-98a0-b998b88debfd'
# os.environ['SS_UUID'] = 'dddddddd-61a6-472e-b8c1-74796e803066'
# os.environ['AGG_UUID'] = 'aaaaaaaa-04b3-458c-9e9f-361aad56f41c'
- name: list traits
GET: /traits
status: 200
@ -57,29 +48,31 @@ tests:
# shared storage provider
$.allocation_requests.`len`: 2
# Verify that compute node #1 only has VCPU and MEMORY_MB listed in the
# resource requests
$.allocation_requests..allocations[?(@.resource_provider.uuid='c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d')].resources[VCPU]: 1
$.allocation_requests..allocations[?(@.resource_provider.uuid='c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d')].resources[MEMORY_MB]: 1024
# 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='c2c2c2c2-beef-49a0-98a0-b998b88debfd')].resources[VCPU]: 1
$.allocation_requests..allocations[?(@.resource_provider.uuid='c2c2c2c2-beef-49a0-98a0-b998b88debfd')].resources[MEMORY_MB]: 1024
$.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='dddddddd-61a6-472e-b8c1-74796e803066')].resources[DISK_GB]: [100, 100]
$.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['c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d'].resources[VCPU].capacity: 384 # 16.0 * 24
$.provider_summaries['c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d'].resources[VCPU].used: 0
$.provider_summaries['c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d'].resources[MEMORY_MB].capacity: 196608 # 1.5 * 128G
$.provider_summaries['c1c1c1c1-2894-4df1-aa6b-c61fa72ed22d'].resources[MEMORY_MB].used: 0
$.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['c2c2c2c2-beef-49a0-98a0-b998b88debfd'].resources[VCPU].capacity: 384 # 16.0 * 24
$.provider_summaries['c2c2c2c2-beef-49a0-98a0-b998b88debfd'].resources[VCPU].used: 0
$.provider_summaries['c2c2c2c2-beef-49a0-98a0-b998b88debfd'].resources[MEMORY_MB].capacity: 196608 # 1.5 * 128G
$.provider_summaries['c2c2c2c2-beef-49a0-98a0-b998b88debfd'].resources[MEMORY_MB].used: 0
$.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['dddddddd-61a6-472e-b8c1-74796e803066'].resources[DISK_GB].capacity: 1900 # 1.0 * 2000 - 100G
$.provider_summaries['dddddddd-61a6-472e-b8c1-74796e803066'].resources[DISK_GB].used: 0
$.provider_summaries["$ENVIRON['SS_UUID']"].resources[DISK_GB].capacity: 1900 # 1.0 * 2000 - 100G
$.provider_summaries["$ENVIRON['SS_UUID']"].resources[DISK_GB].used: 0

View File

@ -26,7 +26,7 @@ testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
bandit>=1.1.0 # Apache-2.0
openstackdocstheme>=1.11.0 # Apache-2.0
gabbi>=1.30.0 # Apache-2.0
gabbi>=1.35.0 # Apache-2.0
# vmwareapi driver specific dependencies
oslo.vmware>=2.17.0 # Apache-2.0