From 03bf6e24cb4a4e35c61d86aee6ea87f64bec2770 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Tue, 15 Oct 2024 12:57:59 -0300 Subject: [PATCH] fixup! upstream CI: Use start.sh script and environment template --- infra/azure/azure-pipelines.yml | 16 ++-- infra/azure/nightly.yml | 56 ++++++------ infra/azure/pr-pipeline.yml | 13 +-- .../azure/templates/galaxy_pytest_script.yml | 65 -------------- infra/azure/templates/galaxy_script.yml | 86 ------------------- infra/azure/templates/galaxy_tests.yml | 50 ----------- infra/azure/templates/group_tests.yml | 32 +++++-- .../{playbook_tests.yml => run_tests.yml} | 21 ++++- 8 files changed, 91 insertions(+), 248 deletions(-) delete mode 100644 infra/azure/templates/galaxy_pytest_script.yml delete mode 100644 infra/azure/templates/galaxy_script.yml delete mode 100644 infra/azure/templates/galaxy_tests.yml rename infra/azure/templates/{playbook_tests.yml => run_tests.yml} (71%) diff --git a/infra/azure/azure-pipelines.yml b/infra/azure/azure-pipelines.yml index b4127fb3dc..4cd2419920 100644 --- a/infra/azure/azure-pipelines.yml +++ b/infra/azure/azure-pipelines.yml @@ -15,7 +15,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core" filter_tests: false @@ -27,7 +27,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core <2.14" filter_tests: false @@ -39,7 +39,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.14,<2.15" filter_tests: false @@ -48,12 +48,13 @@ stages: - stage: Galaxy_Fedora_Latest dependsOn: [] jobs: - - template: templates/galaxy_tests.yml + - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.14,<2.15" filter_tests: false + test_galaxy: true # CentOS 9 Stream @@ -63,7 +64,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c9s + distro: c9s ansible_version: "-core >=2.14,<2.15" filter_tests: false @@ -75,6 +76,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c8s + distro: c8s ansible_version: "-core >=2.14,<2.15" + target_python: "/usr/libexec/platform-python" filter_tests: false diff --git a/infra/azure/nightly.yml b/infra/azure/nightly.yml index 3811c3cd7a..a76c6c0330 100644 --- a/infra/azure/nightly.yml +++ b/infra/azure/nightly.yml @@ -22,7 +22,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.13,<2.14" filter_tests: false @@ -32,7 +32,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.14,<2.15" filter_tests: false @@ -42,7 +42,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.15,<2.16" filter_tests: false @@ -52,7 +52,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "" filter_tests: false @@ -61,42 +61,46 @@ stages: - stage: Galaxy_FedoraLatest_Ansible_Core_2_13 dependsOn: [] jobs: - - template: templates/galaxy_tests.yml + - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.13,<2.14" filter_tests: false + test_galaxy: true - stage: Galaxy_FedoraLatest_Ansible_Core_2_14 dependsOn: [] jobs: - - template: templates/galaxy_tests.yml + - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.14,<2.15" filter_tests: false + test_galaxy: true - stage: Galaxy_FedoraLatest_Ansible_Core_2_15 dependsOn: [] jobs: - - template: templates/galaxy_tests.yml + - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "-core >=2.15,<2.16" filter_tests: false + test_galaxy: true - stage: Galaxy_FedoraLatest_Ansible_latest dependsOn: [] jobs: - - template: templates/galaxy_tests.yml + - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-latest + distro: fedora-latest ansible_version: "" filter_tests: false + test_galaxy: true # Fedora Rawhide @@ -106,7 +110,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-rawhide + distro: fedora-rawhide ansible_version: "-core >=2.13,<2.14" filter_tests: false @@ -116,7 +120,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-rawhide + distro: fedora-rawhide ansible_version: "-core >=2.14,<2.15" filter_tests: false @@ -126,7 +130,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-rawhide + distro: fedora-rawhide ansible_version: "-core >=2.15,<2.16" filter_tests: false @@ -136,7 +140,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: fedora-rawhide + distro: fedora-rawhide ansible_version: "" filter_tests: false @@ -148,7 +152,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c9s + distro: c9s ansible_version: "-core >=2.13,<2.14" filter_tests: false @@ -158,7 +162,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c9s + distro: c9s ansible_version: "-core >=2.14,<2.15" filter_tests: false @@ -168,7 +172,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c9s + distro: c9s ansible_version: "-core >=2.15,<2.16" filter_tests: false @@ -178,7 +182,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c9s + distro: c9s ansible_version: "" filter_tests: false @@ -190,8 +194,9 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c8s + distro: c8s ansible_version: "-core >=2.13,<2.14" + target_python: "/usr/libexec/platform-python" filter_tests: false - stage: c8s_Ansible_Core_2_14 @@ -200,8 +205,9 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c8s + distro: c8s ansible_version: "-core >=2.14,<2.15" + target_python: "/usr/libexec/platform-python" filter_tests: false - stage: c8s_Ansible_Core_2_15 @@ -210,8 +216,9 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c8s + distro: c8s ansible_version: "-core >=2.15,<2.16" + target_python: "/usr/libexec/platform-python" filter_tests: false - stage: c8s_Ansible_latest @@ -220,6 +227,7 @@ stages: - template: templates/group_tests.yml parameters: build_number: $(Build.BuildNumber) - scenario: c8s + distro: c8s ansible_version: "" + target_python: "/usr/libexec/platform-python" filter_tests: false diff --git a/infra/azure/pr-pipeline.yml b/infra/azure/pr-pipeline.yml index 1c6cd14422..a590844a6e 100644 --- a/infra/azure/pr-pipeline.yml +++ b/infra/azure/pr-pipeline.yml @@ -12,7 +12,7 @@ stages: - stage: Fedora_Latest dependsOn: [] jobs: - - template: templates/playbook_tests.yml + - template: templates/run_tests.yml parameters: build_number: $(Build.BuildNumber) distro: fedora-latest @@ -24,19 +24,20 @@ stages: - stage: Galaxy_Fedora_Latest dependsOn: [] jobs: - - template: templates/playbook_tests.yml + - template: templates/run_tests.yml parameters: build_number: $(Build.BuildNumber) distro: fedora-latest ansible_version: "-core >=2.15,<2.16" filter_tests: true + test_galaxy: true # CentOS 9 Stream - stage: CentOS_9_Stream dependsOn: [] jobs: - - template: templates/playbook_tests.yml + - template: templates/run_tests.yml parameters: build_number: $(Build.BuildNumber) distro: c9s @@ -48,12 +49,12 @@ stages: - stage: CentOS_8_Stream dependsOn: [] jobs: - - template: templates/playbook_tests.yml + - template: templates/run_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 @@ -61,7 +62,7 @@ stages: - stage: Fedora_Rawhide dependsOn: [] jobs: - - template: templates/playbook_tests.yml + - template: templates/run_tests.yml parameters: build_number: $(Build.BuildNumber) distro: fedora-rawhide diff --git a/infra/azure/templates/galaxy_pytest_script.yml b/infra/azure/templates/galaxy_pytest_script.yml deleted file mode 100644 index 3b16416961..0000000000 --- a/infra/azure/templates/galaxy_pytest_script.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -parameters: - - name: build_number - type: string - - name: scenario - type: string - default: fedora-latest - - name: ansible_version - type: string - default: "" - - name: python_version - type: string - default: 3.x - -jobs: -- job: Test_PyTests - displayName: Run pytests on ${{ parameters.scenario }} - timeoutInMinutes: 240 - 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: | - utils/build-galaxy-release.sh -i - molecule create -s ${{ parameters.scenario }} - retryCountOnTaskFailure: 5 - displayName: Setup test container - env: - ANSIBLE_LIBRARY: ./molecule - - - script: | - cd ~/.ansible/collections/ansible_collections/freeipa/ansible_freeipa - pytest \ - -m "not playbook" \ - --verbose \ - --color=yes \ - --junit-xml=TEST-results-pytests.xml - displayName: Run tests - env: - IPA_SERVER_HOST: ${{ parameters.scenario }} - RUN_TESTS_IN_DOCKER: true - IPA_VERBOSITY: "-vvv" - - - task: PublishTestResults@2 - inputs: - mergeTestResults: true - testRunTitle: PlaybookTests-Build${{ parameters.build_number }} - condition: succeededOrFailed() diff --git a/infra/azure/templates/galaxy_script.yml b/infra/azure/templates/galaxy_script.yml deleted file mode 100644 index a00dd0a55f..0000000000 --- a/infra/azure/templates/galaxy_script.yml +++ /dev/null @@ -1,86 +0,0 @@ ---- -parameters: - - name: group_number - type: number - default: 1 - - name: number_of_groups - type: number - default: 1 - - name: scenario - type: string - default: fedora-latest - - name: ansible_version - type: string - default: "" - - name: python_version - type: string - default: 3.x - - name: build_number - type: string - - -jobs: -- job: Test_Group${{ parameters.group_number }} - displayName: Run playbook tests ${{ parameters.scenario }} (${{ parameters.group_number }}/${{ parameters.number_of_groups }}) - timeoutInMinutes: 240 - variables: - - template: variables.yaml - - template: variables_${{ parameters.scenario }}.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: | - utils/build-galaxy-release.sh -i - 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 - - - script: | - cd ~/.ansible/collections/ansible_collections/freeipa/ansible_freeipa - 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 - displayName: Run playbook tests - env: - IPA_SERVER_HOST: ${{ parameters.scenario }} - RUN_TESTS_IN_DOCKER: true - 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 - inputs: - mergeTestResults: true - testRunTitle: PlaybookTests-Build${{ parameters.build_number }} - condition: succeededOrFailed() diff --git a/infra/azure/templates/galaxy_tests.yml b/infra/azure/templates/galaxy_tests.yml deleted file mode 100644 index 9464fba7ec..0000000000 --- a/infra/azure/templates/galaxy_tests.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -parameters: - - name: scenario - type: string - default: fedora-latest - - name: build_number - type: string - - name: ansible_version - type: string - default: "" - -jobs: -- template: galaxy_script.yml - parameters: - group_number: 1 - number_of_groups: 3 - build_number: ${{ parameters.build_number }} - scenario: ${{ parameters.scenario }} - ansible_version: ${{ parameters.ansible_version }} - python_version: '< 3.12' - -- template: galaxy_script.yml - parameters: - group_number: 2 - number_of_groups: 3 - build_number: ${{ parameters.build_number }} - scenario: ${{ parameters.scenario }} - ansible_version: ${{ parameters.ansible_version }} - python_version: '< 3.12' - -- template: galaxy_script.yml - parameters: - group_number: 3 - number_of_groups: 3 - build_number: ${{ parameters.build_number }} - scenario: ${{ parameters.scenario }} - ansible_version: ${{ parameters.ansible_version }} - python_version: '< 3.12' - -# Temporarily disabled due to ansible docker plugin issue. -# - template: playbook_tests.yml -# parameters: -# group_number: 3 -# number_of_groups: 3 -# build_number: ${{ parameters.build_number }} -# scenario: ${{ parameters.scenario }} -# ansible_version: ${{ parameters.ansible_version }} -# python_version: '< 3.12' -# filter_tests: ${{ parameters.filter_tests }} -# test_type: "not playbook" diff --git a/infra/azure/templates/group_tests.yml b/infra/azure/templates/group_tests.yml index bab63efdcf..373e3046c3 100644 --- a/infra/azure/templates/group_tests.yml +++ b/infra/azure/templates/group_tests.yml @@ -1,6 +1,6 @@ --- parameters: - - name: scenario + - name: distro type: string default: fedora-latest - name: build_number @@ -8,49 +8,63 @@ parameters: - name: ansible_version type: string default: "" + - name: target_python + type: string + default: "/usr/bin/python3" - name: filter_tests type: boolean default: true + - name: test_galaxy + type: boolean + default: false jobs: -- template: playbook_tests.yml +- template: run_tests.yml parameters: group_number: 1 number_of_groups: 3 build_number: ${{ parameters.build_number }} - scenario: ${{ parameters.scenario }} + distro: ${{ parameters.distro }} ansible_version: ${{ parameters.ansible_version }} python_version: '< 3.12' + target_python: ${{ parameters.target_python }} filter_tests: ${{ parameters.filter_tests }} + test_galaxy: ${{ parameters.test_galaxy }} -- template: playbook_tests.yml +- template: run_tests.yml parameters: group_number: 2 number_of_groups: 3 build_number: ${{ parameters.build_number }} - scenario: ${{ parameters.scenario }} + distro: ${{ parameters.distro }} ansible_version: ${{ parameters.ansible_version }} python_version: '< 3.12' + target_python: ${{ parameters.target_python }} filter_tests: ${{ parameters.filter_tests }} + test_galaxy: ${{ parameters.test_galaxy }} -- template: playbook_tests.yml +- template: run_tests.yml parameters: group_number: 3 number_of_groups: 3 build_number: ${{ parameters.build_number }} - scenario: ${{ parameters.scenario }} + distro: ${{ parameters.distro }} ansible_version: ${{ parameters.ansible_version }} python_version: '< 3.12' + target_python: ${{ parameters.target_python }} filter_tests: ${{ parameters.filter_tests }} + test_galaxy: ${{ parameters.test_galaxy }} # Temporarily disabled due to ansible docker plugin issue. -# - template: playbook_tests.yml +# - template: run_tests.yml # parameters: # group_number: 3 # number_of_groups: 3 # build_number: ${{ parameters.build_number }} -# scenario: ${{ parameters.scenario }} +# distro: ${{ parameters.distro }} # ansible_version: ${{ parameters.ansible_version }} # python_version: '< 3.12' +# target_python: ${{ parameters.target_python }} # filter_tests: ${{ parameters.filter_tests }} # test_type: "not playbook" +# test_galaxy: ${{ parameters.test_galaxy }} diff --git a/infra/azure/templates/playbook_tests.yml b/infra/azure/templates/run_tests.yml similarity index 71% rename from infra/azure/templates/playbook_tests.yml rename to infra/azure/templates/run_tests.yml index 5de2646cfd..5d0137d08a 100644 --- a/infra/azure/templates/playbook_tests.yml +++ b/infra/azure/templates/run_tests.yml @@ -17,12 +17,18 @@ parameters: default: 3.x - name: build_number type: string + - name: target_python + type: string + default: "/usr/bin/python3" - name: filter_tests type: boolean default: true - name: test_type type: string default: "playbook" + - name: test_galaxy + type: boolean + default: false jobs: - job: Test_Group${{ parameters.group_number }} @@ -39,6 +45,13 @@ jobs: ansible_version: ${{ parameters.ansible_version }} python_version: ${{ parameters.python_version }} + - script: | + git fetch --all --shallow-since $(date --date="-9 months" "+%Y-%m-%d") + utils/build-galaxy-release.sh -i + retryCountOnTaskFailure: 5 + displayName: Build Galaxy release + condition: ${{ parameters.test_galaxy }} + - script: | [ "${{ parameters.filter_tests }}" == "True" ] && . utils/set_test_modules python3 utils/check_test_configuration.py ${{ parameters.distro }} @@ -46,10 +59,14 @@ jobs: - script: | [ "${{ parameters.filter_tests }}" == "True" ] && . utils/set_test_modules + [ "${{ parameters.test_galaxy }}" == "True" ] && cd ~/.ansible/collections/ansible_collections/freeipa/ansible_freeipa pytest \ -m "${{ parameters.test_type }}" \ --verbose \ --color=yes \ + --splits=${{ parameters.number_of_groups }} \ + --group=${{ parameters.group_number }} \ + --randomly-seed=$(date "+%Y%m%d") \ --suppress-no-test-exit-code \ --junit-xml=TEST-results-pr-check.xml displayName: Run playbook tests @@ -61,8 +78,10 @@ jobs: 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 }} + IPA_PYTHON_PATH: ${{ parameters.target_python }} - task: PublishTestResults@2 inputs: