diff --git a/infra/azure/azure-pipelines.yml b/infra/azure/azure-pipelines.yml index 685f349b7e..b4127fb3dc 100644 --- a/infra/azure/azure-pipelines.yml +++ b/infra/azure/azure-pipelines.yml @@ -3,7 +3,7 @@ trigger: - master pool: - vmImage: 'ubuntu-20.04' + vmImage: 'ubuntu-22.04' stages: @@ -17,6 +17,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core" + filter_tests: false # Fedora @@ -28,6 +29,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core <2.14" + filter_tests: false # Fedora @@ -39,6 +41,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.14,<2.15" + filter_tests: false # Galaxy on Fedora @@ -50,6 +53,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.14,<2.15" + filter_tests: false # CentOS 9 Stream @@ -61,6 +65,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c9s ansible_version: "-core >=2.14,<2.15" + filter_tests: false # CentOS 8 Stream @@ -72,3 +77,4 @@ stages: build_number: $(Build.BuildNumber) scenario: c8s ansible_version: "-core >=2.14,<2.15" + filter_tests: false diff --git a/infra/azure/nightly.yml b/infra/azure/nightly.yml index 54d55a2bf7..3811c3cd7a 100644 --- a/infra/azure/nightly.yml +++ b/infra/azure/nightly.yml @@ -24,6 +24,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.13,<2.14" + filter_tests: false - stage: FedoraLatest_Ansible_Core_2_14 dependsOn: [] @@ -33,6 +34,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.14,<2.15" + filter_tests: false - stage: FedoraLatest_Ansible_Core_2_15 dependsOn: [] @@ -42,6 +44,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.15,<2.16" + filter_tests: false - stage: FedoraLatest_Ansible_latest dependsOn: [] @@ -51,6 +54,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "" + filter_tests: false # Galaxy on Fedora @@ -62,6 +66,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.13,<2.14" + filter_tests: false - stage: Galaxy_FedoraLatest_Ansible_Core_2_14 dependsOn: [] @@ -71,6 +76,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.14,<2.15" + filter_tests: false - stage: Galaxy_FedoraLatest_Ansible_Core_2_15 dependsOn: [] @@ -80,6 +86,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "-core >=2.15,<2.16" + filter_tests: false - stage: Galaxy_FedoraLatest_Ansible_latest dependsOn: [] @@ -89,6 +96,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-latest ansible_version: "" + filter_tests: false # Fedora Rawhide @@ -100,6 +108,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-rawhide ansible_version: "-core >=2.13,<2.14" + filter_tests: false - stage: FedoraRawhide_Ansible_Core_2_14 dependsOn: [] @@ -109,6 +118,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-rawhide ansible_version: "-core >=2.14,<2.15" + filter_tests: false - stage: FedoraRawhide_Ansible_Core_2_15 dependsOn: [] @@ -118,6 +128,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-rawhide ansible_version: "-core >=2.15,<2.16" + filter_tests: false - stage: FedoraRawhide_Ansible_latest dependsOn: [] @@ -127,6 +138,7 @@ stages: build_number: $(Build.BuildNumber) scenario: fedora-rawhide ansible_version: "" + filter_tests: false # CentoOS 9 Stream @@ -138,6 +150,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c9s ansible_version: "-core >=2.13,<2.14" + filter_tests: false - stage: c9s_Ansible_Core_2_14 dependsOn: [] @@ -147,6 +160,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c9s ansible_version: "-core >=2.14,<2.15" + filter_tests: false - stage: c9s_Ansible_Core_2_15 dependsOn: [] @@ -156,6 +170,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c9s ansible_version: "-core >=2.15,<2.16" + filter_tests: false - stage: c9s_Ansible_latest dependsOn: [] @@ -165,6 +180,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c9s ansible_version: "" + filter_tests: false # CentOS 8 Stream @@ -176,6 +192,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c8s ansible_version: "-core >=2.13,<2.14" + filter_tests: false - stage: c8s_Ansible_Core_2_14 dependsOn: [] @@ -185,6 +202,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c8s ansible_version: "-core >=2.14,<2.15" + filter_tests: false - stage: c8s_Ansible_Core_2_15 dependsOn: [] @@ -194,6 +212,7 @@ stages: build_number: $(Build.BuildNumber) scenario: c8s ansible_version: "-core >=2.15,<2.16" + filter_tests: false - stage: c8s_Ansible_latest dependsOn: [] @@ -203,3 +222,4 @@ stages: build_number: $(Build.BuildNumber) scenario: c8s ansible_version: "" + filter_tests: false diff --git a/infra/azure/pr-pipeline.yml b/infra/azure/pr-pipeline.yml index afd26c1696..1c6cd14422 100644 --- a/infra/azure/pr-pipeline.yml +++ b/infra/azure/pr-pipeline.yml @@ -12,53 +12,58 @@ stages: - stage: Fedora_Latest dependsOn: [] jobs: - - template: templates/fast_tests.yml + - template: templates/playbook_tests.yml parameters: build_number: $(Build.BuildNumber) distro: fedora-latest ansible_version: "-core >=2.15,<2.16" + filter_tests: true # Galaxy on Fedora - stage: Galaxy_Fedora_Latest dependsOn: [] jobs: - - template: templates/fast_tests.yml + - template: templates/playbook_tests.yml parameters: build_number: $(Build.BuildNumber) distro: fedora-latest ansible_version: "-core >=2.15,<2.16" + filter_tests: true # CentOS 9 Stream - stage: CentOS_9_Stream dependsOn: [] jobs: - - template: templates/fast_tests.yml + - template: templates/playbook_tests.yml parameters: build_number: $(Build.BuildNumber) distro: c9s ansible_version: "-core >=2.15,<2.16" + filter_tests: true # CentOS 8 Stream - stage: CentOS_8_Stream dependsOn: [] jobs: - - template: templates/fast_tests.yml + - template: templates/playbook_tests.yml parameters: build_number: $(Build.BuildNumber) distro: c8s ansible_version: "-core >=2.15,<2.16" - target_python: "/usr/libexec/platform-python" + # target_python: "/usr/libexec/platform-python" + filter_tests: true # Rawhide - stage: Fedora_Rawhide dependsOn: [] jobs: - - template: templates/fast_tests.yml + - template: templates/playbook_tests.yml parameters: build_number: $(Build.BuildNumber) distro: fedora-rawhide ansible_version: "-core >=2.15,<2.16" + filter_tests: true diff --git a/infra/azure/templates/group_tests.yml b/infra/azure/templates/group_tests.yml index 38f183dd97..0d2fee49f2 100644 --- a/infra/azure/templates/group_tests.yml +++ b/infra/azure/templates/group_tests.yml @@ -8,6 +8,9 @@ parameters: - name: ansible_version type: string default: "" + - name: filter_tests + type: boolean + defaut: true jobs: - template: playbook_tests.yml @@ -18,6 +21,7 @@ jobs: scenario: ${{ parameters.scenario }} ansible_version: ${{ parameters.ansible_version }} python_version: '< 3.12' + filter_tests: ${{ parameters.filter_tests }} - template: playbook_tests.yml parameters: @@ -27,6 +31,7 @@ jobs: scenario: ${{ parameters.scenario }} ansible_version: ${{ parameters.ansible_version }} python_version: '< 3.12' + filter_tests: ${{ parameters.filter_tests }} - template: playbook_tests.yml parameters: @@ -36,6 +41,7 @@ jobs: scenario: ${{ parameters.scenario }} ansible_version: ${{ parameters.ansible_version }} python_version: '< 3.12' + filter_tests: ${{ parameters.filter_tests }} # Temporarily disabled due to ansible docker plugin issue. #- template: pytest_tests.yml diff --git a/infra/azure/templates/playbook_fast.yml b/infra/azure/templates/playbook_fast.yml index a00a7875dc..844b2b06fa 100644 --- a/infra/azure/templates/playbook_fast.yml +++ b/infra/azure/templates/playbook_fast.yml @@ -29,39 +29,13 @@ jobs: - template: variables.yaml - template: variables_${{ parameters.distro }}.yaml steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '${{ parameters.python_version }}' - - - script: | - pip install "ansible${{ parameters.ansible_version }}" - retryCountOnTaskFailure: 5 - displayName: Install Ansible - - - script: ansible-galaxy collection install containers.podman - retryCountOnTaskFailure: 5 - displayName: Install Ansible collections - - - script: pip install -r requirements-tests.txt - retryCountOnTaskFailure: 5 - displayName: Install dependencies + - template: templates/prepare_environment.yaml - script: | . utils/set_test_modules python3 utils/check_test_configuration.py ${{ parameters.distro }} displayName: Check test configuration - - script: | - utils/setup_test_container.sh \ - -e podman \ - -a \ - -m 4 \ - -n "ipaserver.test.local" \ - -p ${{ parameters.target_python }} \ - -i ${{ parameters.distro }}-server \ - ${{ parameters.distro }}-test - displayName: Setup target container - - script: | . utils/set_test_modules pytest -m "playbook" --verbose --color=yes --suppress-no-test-exit-code --junit-xml=TEST-results-pr-check.xml diff --git a/infra/azure/templates/playbook_tests.yml b/infra/azure/templates/playbook_tests.yml index c65c955fb1..535d15d96a 100644 --- a/infra/azure/templates/playbook_tests.yml +++ b/infra/azure/templates/playbook_tests.yml @@ -6,7 +6,7 @@ parameters: - name: number_of_groups type: number default: 1 - - name: scenario + - name: distro type: string default: fedora-latest - name: ansible_version @@ -17,69 +17,46 @@ parameters: default: 3.x - name: build_number type: string + - name: filter_tests + type: boolean + default: true + - name: test_type + type: string + default: "playbook" jobs: - job: Test_Group${{ parameters.group_number }} - displayName: Run playbook tests ${{ parameters.scenario }} (${{ parameters.group_number }}/${{ parameters.number_of_groups }}) - timeoutInMinutes: 240 + displayName: Run playbook tests ${{ parameters.distro }} (${{ parameters.group_number }}/${{ parameters.number_of_groups }}) + timeoutInMinutes: 360 variables: - template: variables.yaml - - template: variables_${{ parameters.scenario }}.yaml + - template: variables_${{ parameters.distro }}.yaml steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '${{ parameters.python_version }}' - - - script: | - pip install \ - "molecule-plugins[docker]" \ - "requests<2.29" \ - "ansible${{ parameters.ansible_version }}" - retryCountOnTaskFailure: 5 - displayName: Install molecule and Ansible - - - script: ansible-galaxy collection install community.docker ansible.posix - retryCountOnTaskFailure: 5 - displayName: Install Ansible collections - - - script: pip install -r requirements-tests.txt - retryCountOnTaskFailure: 5 - displayName: Install dependencies - - - script: | - rm -rf ~/ansible - mkdir -p ~/.ansible/roles ~/.ansible/library ~/.ansible/module_utils - cp -a roles/* ~/.ansible/roles - cp -a plugins/modules/* ~/.ansible/library - cp -a plugins/module_utils/* ~/.ansible/module_utils - molecule create -s ${{ parameters.scenario }} - retryCountOnTaskFailure: 5 - displayName: Setup test container - env: - ANSIBLE_LIBRARY: ./molecule - - - script: | - python utils/check_test_configuration.py ${{ parameters.scenario }} - displayName: Check scenario test configuration + - template: templates/prepare_environment.yaml + parameters: + distro: ${{ parameters.distro }} + ansible_version: ${{ parameters.ansible_version }} + python_version: ${{ parameters.python_version }} + filter_tests: ${{ parameters.filter_tests }} - script: | pytest \ - -m "playbook" \ - --verbose \ - --color=yes \ - --splits=${{ parameters.number_of_groups }} \ - --group=${{ parameters.group_number }} \ - --randomly-seed=$(date "+%Y%m%d") \ - --junit-xml=TEST-results-group-${{ parameters.group_number }}.xml + -m "${{ parameters.test_type }}" \ + --verbose \ + --color=yes \ + --suppress-no-test-exit-code \ + --junit-xml=TEST-results-pr-check.xml displayName: Run playbook tests env: - IPA_SERVER_HOST: ${{ parameters.scenario }} - RUN_TESTS_IN_DOCKER: true + ANSIBLE_ROLES_PATH: "${PWD}/roles" + ANSIBLE_LIBRARY: "${PWD}/plugins" + ANSIBLE_MODULE_UTILS: "${PWD}/plugins/module_utils" + IPA_SERVER_HOST: ansible-freeipa-tests + RUN_TESTS_IN_DOCKER: podman IPA_DISABLED_MODULES: ${{ variables.ipa_disabled_modules }} IPA_DISABLED_TESTS: ${{ variables.ipa_disabled_tests }} - IPA_ENABLED_MODULES: ${{ variables.ipa_enabled_modules }} - IPA_ENABLED_TESTS: ${{ variables.ipa_enabled_tests }} IPA_VERBOSITY: "-vvv" + # IPA_PYTHON_PATH: ${{ parameters.target_python }} - task: PublishTestResults@2 inputs: diff --git a/infra/azure/templates/prepare_environment.yaml b/infra/azure/templates/prepare_environment.yaml new file mode 100644 index 0000000000..81c553c709 --- /dev/null +++ b/infra/azure/templates/prepare_environment.yaml @@ -0,0 +1,39 @@ +--- +parameters: + - name: distro + type: string + default: fedora-latest + - name: ansible_version + type: string + default: "" + - name: python_version + type: string + default: 3.x + - name: build_number + type: string + - name: filter_tests + type: bool + default: true + +steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '${{ parameters.python_version }}' + + - script: | + pip install "ansible${{ parameters.ansible_version }}" -r requirements-tests.txt + retryCountOnTaskFailure: 5 + displayName: Install test dependencies + + - script: ansible-galaxy collection install -r requirements-podman.yml + retryCountOnTaskFailure: 5 + displayName: Install Ansible collections + + - script: infra/image/start.sh ${{ parameters.distro }}-server + displayName: Setup target container for ${{ parameters.distro }} + + - script: . utils/set_test_modules + condition: eq(parameters.filter_tests, true) + + - script: python3 utils/check_test_configuration.py ${{ parameters.distro }} + displayName: Check test configuration diff --git a/infra/azure/templates/pytest_tests.yml b/infra/azure/templates/pytest_tests.yml index a7b12110e5..6469d2100c 100644 --- a/infra/azure/templates/pytest_tests.yml +++ b/infra/azure/templates/pytest_tests.yml @@ -2,7 +2,7 @@ parameters: - name: build_number type: string - - name: scenario + - name: distro type: string default: fedora-latest - name: ansible_version @@ -14,58 +14,42 @@ parameters: jobs: - job: Test_PyTests - displayName: Run pytests on ${{ parameters.scenario }} + displayName: Run pytests on ${{ parameters.distro }} timeoutInMinutes: 240 variables: - template: variables.yaml - - template: variables_${{ parameters.scenario }}.yaml + - template: variables_${{ parameters.distro }}.yaml steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '${{ parameters.python_version }}' - - - script: | - pip install \ - "molecule-plugins[docker]" \ - "requests<2.29" \ - "ansible${{ parameters.ansible_version }}" - retryCountOnTaskFailure: 5 - displayName: Install molecule and Ansible + - template: templates/prepare_environment.yaml + parameters: + distro: ${{ parameters.distro }} + ansible_version: ${{ parameters.ansible_version }} + python_version: ${{ parameters.python_version }} + filter_tests: ${{ parameters.filter_tests }} - - script: ansible-galaxy collection install community.docker ansible.posix - retryCountOnTaskFailure: 5 - displayName: Install Ansible collections + - script: . utils/set_test_modules + condition: eq(parameters.filter_tests, true) + displayName: Filter tests - - script: pip install -r requirements-tests.txt - retryCountOnTaskFailure: 5 - displayName: Install dependencies - - - script: | - rm -rf ~/.ansible - mkdir -p ~/.ansible/roles ~/.ansible/library ~/.ansible/module_utils - cp -a roles/* ~/.ansible/roles - cp -a plugins/modules/* ~/.ansible/library - cp -a plugins/module_utils/* ~/.ansible/module_utils - molecule create -s ${{ parameters.scenario }} - retryCountOnTaskFailure: 5 - displayName: Setup test container - env: - ANSIBLE_LIBRARY: ./molecule + - script: python3 utils/check_test_configuration.py ${{ parameters.distro }} + displayName: Check test configuration - script: | pytest \ -m "not playbook" \ --verbose \ --color=yes \ + --suppress-no-test-exit-code \ --junit-xml=TEST-results-pytests.xml displayName: Run tests env: - IPA_SERVER_HOST: ${{ parameters.scenario }} - RUN_TESTS_IN_DOCKER: true + ANSIBLE_ROLES_PATH: "${PWD}/roles" + ANSIBLE_LIBRARY: "${PWD}/plugins" + ANSIBLE_MODULE_UTILS: "${PWD}/plugins/module_utils" + IPA_SERVER_HOST: ansible-freeipa-tests + RUN_TESTS_IN_DOCKER: podman IPA_DISABLED_MODULES: ${{ variables.ipa_disabled_modules }} IPA_DISABLED_TESTS: ${{ variables.ipa_disabled_tests }} - IPA_ENABLED_MODULES: ${{ variables.ipa_enabled_modules }} - IPA_ENABLED_TESTS: ${{ variables.ipa_enabled_tests }} IPA_VERBOSITY: "-vvv" - task: PublishTestResults@2