From 069e5ec67c9249827661245daf8feb83087d2acb Mon Sep 17 00:00:00 2001
From: Chris Dent <cdent@anticdent.org>
Date: Tue, 31 Oct 2017 12:54:17 +0000
Subject: [PATCH] [placement] avoid case issues microversions in gabbits

If a gabbi file sets a default microversion by setting a header
'OpenStack-API-Version' with a value like 'placement latest' and then
later overrides that in an individual test with a header of
'openstack-api-version' the difference in case can lead to failure.

In the best case the failure is consistent.

In the worst case it can sometimes work, because the header shows up
twice in the request, and the last header wins, order in the headers
and the resulting list dependent on the vagrancies of python ordering.

The solution is to always use the same case, so this change updates
all use to be lowercase, to establish a precedent that future people
will be able to use as an example.

Note that gabbi is case sensitive here in part because of the
implementation but also because it provides the control and possibility
to test exactly this problem.

Change-Id: I1e89e231cf0d46d211d360cda091b33520f85027
Closes-Bug: #1728934
---
 .../gabbits/allocation-bad-class.yaml         |  2 +-
 .../placement/gabbits/allocations-1-8.yaml    |  2 +-
 .../gabbits/allocations-bug-1714072.yaml      |  2 +-
 .../gabbits/resource-class-in-use.yaml        |  2 +-
 .../gabbits/resource-classes-1-6.yaml         |  2 +-
 .../gabbits/resource-classes-1-7.yaml         |  2 +-
 .../placement/gabbits/resource-classes.yaml   | 20 +++++++++----------
 .../resource-provider-resources-query.yaml    |  4 ++--
 .../placement/gabbits/shared-resources.yaml   |  2 +-
 .../openstack/placement/gabbits/traits.yaml   |  2 +-
 10 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/nova/tests/functional/api/openstack/placement/gabbits/allocation-bad-class.yaml b/nova/tests/functional/api/openstack/placement/gabbits/allocation-bad-class.yaml
index 39e674e95..de0ee1c81 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/allocation-bad-class.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/allocation-bad-class.yaml
@@ -7,7 +7,7 @@ defaults:
         x-auth-token: admin
         accept: application/json
         content-type: application/json
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/allocations-1-8.yaml b/nova/tests/functional/api/openstack/placement/gabbits/allocations-1-8.yaml
index d3a8a6bdc..b42d556d9 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/allocations-1-8.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/allocations-1-8.yaml
@@ -5,7 +5,7 @@ defaults:
     request_headers:
         x-auth-token: admin
         accept: application/json
-        OpenStack-API-Version: placement 1.8
+        openstack-api-version: placement 1.8
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/allocations-bug-1714072.yaml b/nova/tests/functional/api/openstack/placement/gabbits/allocations-bug-1714072.yaml
index f182508b6..c376046a2 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/allocations-bug-1714072.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/allocations-bug-1714072.yaml
@@ -11,7 +11,7 @@ defaults:
         x-auth-token: admin
         accept: application/json
         content-type: application/json
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-class-in-use.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-class-in-use.yaml
index a641eb05d..62e152e15 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/resource-class-in-use.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-class-in-use.yaml
@@ -9,7 +9,7 @@ defaults:
         x-auth-token: admin
         accept: application/json
         content-type: application/json
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-6.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-6.yaml
index 30f250d62..9975aa654 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-6.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-6.yaml
@@ -8,7 +8,7 @@ defaults:
         x-auth-token: admin
         accept: application/json
         content-type: application/json
-        OpenStack-API-Version: placement 1.6
+        openstack-api-version: placement 1.6
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-7.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-7.yaml
index 2187c24da..1c4a5eb68 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-7.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes-1-7.yaml
@@ -6,7 +6,7 @@ defaults:
         x-auth-token: admin
         accept: application/json
         content-type: application/json
-        OpenStack-API-Version: placement 1.7
+        openstack-api-version: placement 1.7
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml
index 9cf3471a4..6867c7d7a 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml
@@ -5,14 +5,14 @@ defaults:
     request_headers:
         x-auth-token: admin
         accept: application/json
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests:
 
 - name: test microversion masks entire resource-classes endpoint with 404
   GET: /resource_classes
   request_headers:
-    OpenStack-API-Version: placement 1.1
+    openstack-api-version: placement 1.1
     content-type: application/json
   status: 404
   response_json_paths:
@@ -22,7 +22,7 @@ tests:
   desc: we want to get a 404 before a 415
   POST: /resource_classes
   request_headers:
-    OpenStack-API-Version: placement 1.1
+    openstack-api-version: placement 1.1
     content-type: text/plain
   data: data
   status: 404
@@ -31,7 +31,7 @@ tests:
   desc: we want to get a 415 when bad content type
   POST: /resource_classes
   request_headers:
-    OpenStack-API-Version: placement 1.2
+    openstack-api-version: placement 1.2
     content-type: text/plain
   data: data
   status: 415
@@ -125,7 +125,7 @@ tests:
   PUT: /resource_classes/VCPU
   request_headers:
     content-type: application/json
-    OpenStack-API-Version: placement 1.6
+    openstack-api-version: placement 1.6
   data:
       name: VCPU_ALTERNATE
   status: 400
@@ -139,7 +139,7 @@ tests:
   PUT: /resource_classes/VCPU
   request_headers:
     content-type: application/json
-    OpenStack-API-Version: placement 1.6
+    openstack-api-version: placement 1.6
   data:
       name: $ENVIRON['CUSTOM_RES_CLASS']
   status: 400
@@ -152,7 +152,7 @@ tests:
   PUT: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS']
   request_headers:
     content-type: application/json
-    OpenStack-API-Version: placement 1.6
+    openstack-api-version: placement 1.6
   data:
       name: VCPU
   status: 400
@@ -173,7 +173,7 @@ tests:
   PUT: /resource_classes/CUSTOM_NFV_FOO
   request_headers:
     content-type: application/json
-    OpenStack-API-Version: placement 1.6
+    openstack-api-version: placement 1.6
   data:
       name: $ENVIRON['CUSTOM_RES_CLASS']
   status: 409
@@ -187,7 +187,7 @@ tests:
   PUT: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS']
   request_headers:
     content-type: application/json
-    OpenStack-API-Version: placement 1.6
+    openstack-api-version: placement 1.6
   data:
       name: CUSTOM_NFV_BAR
   status: 200
@@ -252,7 +252,7 @@ tests:
   PUT: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS']
   request_headers:
       content-type: application/json
-      OpenStack-API-Version: placement 1.6
+      openstack-api-version: placement 1.6
   data:
       name: *name_exceeds_max_length_check
   status: 400
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-resources-query.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-resources-query.yaml
index 2297b4292..f80c1753a 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-resources-query.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-resources-query.yaml
@@ -7,7 +7,7 @@ defaults:
         x-auth-token: admin
         content-type: application/json
         accept: application/json
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests:
 
@@ -41,7 +41,7 @@ tests:
 - name: list resource providers providing resources filter before API 1.4
   GET: /resource_providers?resources=VCPU:1
   request_headers:
-      OpenStack-API-Version: placement 1.3
+      openstack-api-version: placement 1.3
   status: 400
   response_strings:
       - 'Invalid query string parameters'
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/shared-resources.yaml b/nova/tests/functional/api/openstack/placement/gabbits/shared-resources.yaml
index 5d087f3d8..9bfd8b904 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/shared-resources.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/shared-resources.yaml
@@ -14,7 +14,7 @@ defaults:
         x-auth-token: admin
         content-type: application/json
         accept: application/json
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests:
 
diff --git a/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml b/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml
index fd94d3fd3..c8e6ba9bb 100644
--- a/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml
+++ b/nova/tests/functional/api/openstack/placement/gabbits/traits.yaml
@@ -5,7 +5,7 @@ fixtures:
 defaults:
     request_headers:
         x-auth-token: admin
-        OpenStack-API-Version: placement latest
+        openstack-api-version: placement latest
 
 tests: