From f0239eafecde1f6bd9764b3b049102debb786492 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 18 Mar 2025 19:01:48 +0100 Subject: [PATCH] Execute functional tests through molecule This adopts old functional tests to be executed and verified through molecule instead of the leveraging tests repo. We do not yet fully test connection plugin as more work needs to be put into it. Change-Id: I8a42464f34f2438642046f28a4e8451fd876dcf1 --- molecule/default/verify.yml | 7 +++++ tests/test-filters.yml | 6 ++--- tests/test-modules.yml | 9 ++++--- tests/test.yml | 26 ------------------- .../all.yml => vars/provider_networks.yml} | 2 ++ 5 files changed, 17 insertions(+), 33 deletions(-) create mode 100644 molecule/default/verify.yml delete mode 100644 tests/test.yml rename tests/{group_vars/all.yml => vars/provider_networks.yml} (98%) diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 00000000..bce3cc05 --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,7 @@ +--- + +- name: Running filters tests + ansible.builtin.import_playbook: ../../tests/test-filters.yml + +- name: Running modules tests + ansible.builtin.import_playbook: ../../tests/test-modules.yml diff --git a/tests/test-filters.yml b/tests/test-filters.yml index 784d3822..d8e57aa4 100644 --- a/tests/test-filters.yml +++ b/tests/test-filters.yml @@ -22,7 +22,7 @@ - name: Validate string_2_int filter ansible.builtin.assert: that: - - "{{ 'test' | string_2_int }} == 3752" + - "{{ 'test' | openstack.osa.string_2_int }} == 3752" - name: Set pip package list facts ansible.builtin.set_fact: @@ -53,7 +53,7 @@ - test - name: Set splitlines filter fact ansible.builtin.set_fact: - string_split_lines_filtered: "{{ string_with_lines | splitlines }}" + string_split_lines_filtered: "{{ string_with_lines | openstack.osa.splitlines }}" - name: Validate splitlines filter ansible.builtin.assert: that: "string_split_lines_filtered == string_split_lines" @@ -75,7 +75,7 @@ old_var: old - name: Set deprecated filter fact ansible.builtin.set_fact: - deprecated_value: "{{ new_var | deprecated(old_var, 'old_var', 'new_var', 'Next Release', false) }}" + deprecated_value: "{{ new_var | openstack.osa.deprecated(old_var, 'old_var', 'new_var', 'Next Release', false) }}" - name: Validate deprecated filter ansible.builtin.assert: that: "deprecated_value == old_var" diff --git a/tests/test-modules.yml b/tests/test-modules.yml index 8357c4d4..16877e8e 100644 --- a/tests/test-modules.yml +++ b/tests/test-modules.yml @@ -17,9 +17,11 @@ hosts: localhost connection: local gather_facts: false + vars_files: + - vars/provider_networks.yml tasks: - name: Test network mapping consistent order - provider_networks: + openstack.osa.provider_networks: provider_networks: "{{ provider_networks }}" bind_prefix: "{{ provider_network_bind_prefix | default('') }}" is_metal: "{{ is_metal }}" @@ -29,6 +31,5 @@ - name: Verify network mappings have a consistent order ansible.builtin.assert: - that: >- - pndata.results | map(attribute='network_mappings') | unique | length - == 1 + that: + - pndata.results | map(attribute='network_mappings') | unique | length == 1 diff --git a/tests/test.yml b/tests/test.yml deleted file mode 100644 index 8a2beca6..00000000 --- a/tests/test.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -# Copyright 2016, @WalmartLabs -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Collect facts for all hosts - hosts: hosts:!fake_hosts - gather_facts: yes - -- import_playbook: common/test-setup-host.yml - -- import_playbook: test-filters.yml - -- import_playbook: test-strategy-tagfilter.yml - -- import_playbook: test-connection-plugin.yml diff --git a/tests/group_vars/all.yml b/tests/vars/provider_networks.yml similarity index 98% rename from tests/group_vars/all.yml rename to tests/vars/provider_networks.yml index 9e83f0fd..8a2739c9 100644 --- a/tests/group_vars/all.yml +++ b/tests/vars/provider_networks.yml @@ -1,3 +1,5 @@ +--- +is_metal: true provider_networks: - network: container_bridge: "br-mgmt"