From 396634e07cd7d7e07c27fdb43d06271713f4049a Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Tue, 18 Jan 2022 16:28:25 +0100 Subject: [PATCH] Extra tests around required traits This patch adds some tests to prove the following for both GET /resource_providers and /allocation_candidates API: * in:trait1,trait2 is not yet supported, this will makes sure we don't leak the support to older microversions * repeated `required` query params are not supported. Interestingly the current behavior is that one `required` query param will overwrite the rest. Story: 2005345 Story: 2005346 Change-Id: I67d1af5b8b6e945c744180358d588e95e13c33f6 --- .../allocation-candidates-any-traits.yaml | 48 +++++++++++++++++++ .../gabbits/resource-provider-any-traits.yaml | 29 +++++++++++ 2 files changed, 77 insertions(+) create mode 100644 placement/tests/functional/gabbits/allocation-candidates-any-traits.yaml create mode 100644 placement/tests/functional/gabbits/resource-provider-any-traits.yaml diff --git a/placement/tests/functional/gabbits/allocation-candidates-any-traits.yaml b/placement/tests/functional/gabbits/allocation-candidates-any-traits.yaml new file mode 100644 index 000000000..3609ba232 --- /dev/null +++ b/placement/tests/functional/gabbits/allocation-candidates-any-traits.yaml @@ -0,0 +1,48 @@ +fixtures: + - GranularFixture + +defaults: + request_headers: + x-auth-token: admin + accept: application/json + openstack-api-version: placement latest + +tests: + +- name: the 'in:' trait query is not supported yet + GET: /allocation_candidates?required=in:CUSTOM_FOO,HW_CPU_X86_MMX&resources=VCPU:1 + request_headers: + openstack-api-version: placement 1.38 + status: 400 + response_strings: + - "No such trait(s): in:CUSTOM_FOO" + +- name: the 'in:' trait query is not supported yet in named request group + GET: /allocation_candidates?requiredX=in:CUSTOM_FOO,HW_CPU_X86_MMX&resourcesX=VCPU:1 + request_headers: + openstack-api-version: placement 1.38 + status: 400 + response_strings: + - "No such trait(s): in:CUSTOM_FOO" + +- name: the second required field overwrites the first + # The fixture has one RP for each trait but no RP for both traits. + # As the second 'required' key overwrites the first in <= 1.38 we expect + # that one of that RPs will be returned. + GET: /allocation_candidates?required=CUSTOM_FOO&required=HW_CPU_X86_MMX&resources=VCPU:1 + request_headers: + openstack-api-version: placement 1.38 + status: 200 + response_json_paths: + $.allocation_requests.`len`: 1 + +- name: the second required field overwrites the first in named groups + # The fixture has one RP for each trait but no RP for both traits. + # As the second 'required' key overwrites the first in <= 1.38 we expect + # that one of that RPs will be returned. + GET: /allocation_candidates?requiredX=CUSTOM_FOO&requiredX=HW_CPU_X86_MMX&resourcesX=VCPU:1 + request_headers: + openstack-api-version: placement 1.38 + status: 200 + response_json_paths: + $.allocation_requests.`len`: 1 diff --git a/placement/tests/functional/gabbits/resource-provider-any-traits.yaml b/placement/tests/functional/gabbits/resource-provider-any-traits.yaml new file mode 100644 index 000000000..0299e3cfa --- /dev/null +++ b/placement/tests/functional/gabbits/resource-provider-any-traits.yaml @@ -0,0 +1,29 @@ +fixtures: + - GranularFixture + +defaults: + request_headers: + x-auth-token: admin + accept: application/json + openstack-api-version: placement latest + +tests: + +- name: the 'in:' trait query is not supported yet + GET: /resource_providers?required=in:CUSTOM_FOO,HW_CPU_X86_MMX + request_headers: + openstack-api-version: placement 1.38 + status: 400 + response_strings: + - "No such trait(s): in:CUSTOM_FOO" + +- name: the second required field overwrites the first + # The fixture has one RP for each trait but no RP for both traits. + # As the second 'required' key overwrites the first in <= 1.38 we expect + # that one of that RPs will be returned. + GET: /resource_providers?required=CUSTOM_FOO&required=HW_CPU_X86_MMX + request_headers: + openstack-api-version: placement 1.38 + status: 200 + response_json_paths: + $.resource_providers.`len`: 1