Skip to content

Commit

Permalink
upstream ci: Use util scripts instead of molecule
Browse files Browse the repository at this point in the history
This patch start the removal of the dependency on molecule for tests,
by using the scripts under `utils` to setup the environment.

By not using molecule, we have more flexibility on using either docker
or podman as the container engine, and makes it easy to reproduce the
environment on different distros, allowing for a more consistent error
reproduction off Azure.
  • Loading branch information
rjeffman committed Jul 20, 2024
1 parent e97c0b3 commit 1ca5c72
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
34 changes: 19 additions & 15 deletions tests/azure/pr-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ trigger:
- master

pool:
vmImage: 'ubuntu-20.04'
vmImage: 'ubuntu-22.04'

stages:

Expand All @@ -16,7 +16,7 @@ stages:
parameters:
build_number: $(Build.BuildNumber)
scenario: fedora-latest
ansible_version: "-core >=2.14,<2.15"
ansible_version: "-core >=2.15,<2.16"

# Galaxy on Fedora

Expand All @@ -27,7 +27,7 @@ stages:
parameters:
build_number: $(Build.BuildNumber)
scenario: fedora-latest
ansible_version: "-core >=2.14,<2.15"
ansible_version: "-core >=2.15,<2.16"

# CentOS 9 Stream

Expand All @@ -38,7 +38,7 @@ stages:
parameters:
build_number: $(Build.BuildNumber)
scenario: c9s
ansible_version: "-core >=2.14,<2.15"
ansible_version: "-core >=2.15,<2.16"

# CentOS 8 Stream

Expand All @@ -49,18 +49,22 @@ stages:
parameters:
build_number: $(Build.BuildNumber)
scenario: c8s
ansible_version: "-core >=2.14,<2.15"
ansible_version: "-core >=2.15,<2.16"
target_python: "/usr/libexec/platform-python"

# CentOS 7 cannot be used with current systemd
#
# CentOS 7

- stage: CentOS_7
dependsOn: []
jobs:
- template: templates/fast_tests.yml
parameters:
build_number: $(Build.BuildNumber)
scenario: centos-7
ansible_version: "-core >=2.14,<2.15"
#
# - stage: CentOS_7
# dependsOn: []
# jobs:
# - template: templates/fast_tests.yml
# parameters:
# build_number: $(Build.BuildNumber)
# scenario: centos-7
# ansible_version: "-core >=2.15,<2.16"
# target_python: "/usr/bin/python2"

# Rawhide

Expand All @@ -71,4 +75,4 @@ stages:
parameters:
build_number: $(Build.BuildNumber)
scenario: fedora-rawhide
ansible_version: "-core >=2.14,<2.15"
ansible_version: "-core >=2.15,<2.16"
4 changes: 4 additions & 0 deletions tests/azure/templates/fast_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ parameters:
- name: ansible_version
type: string
default: ""
- name: target_python
type: string
default: "/usr/bin/python3"

jobs:
- template: playbook_fast.yml
Expand All @@ -18,6 +21,7 @@ jobs:
scenario: ${{ parameters.scenario }}
ansible_version: ${{ parameters.ansible_version }}
python_version: '< 3.12'
target_python: ${{ parameters.target_python }}

# - template: pytest_tests.yml
# parameters:
Expand Down
56 changes: 24 additions & 32 deletions tests/azure/templates/playbook_fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ parameters:
default: 3.x
- name: build_number
type: string
- name: target_python
type: string
default: "/usr/bin/python3"

jobs:
- job: Test_Group${{ parameters.group_number }}
Expand All @@ -31,59 +34,48 @@ jobs:
versionSpec: '${{ parameters.python_version }}'

- script: |
pip install \
"molecule-plugins[docker]" \
"requests<2.29" \
"ansible${{ parameters.ansible_version }}"
pip install "ansible${{ parameters.ansible_version }}"
retryCountOnTaskFailure: 5
displayName: Install molecule and Ansible
displayName: Install Ansible
- script: ansible-galaxy collection install community.docker ansible.posix
- 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

- 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: |
. utils/set_test_modules
python utils/check_test_configuration.py ${{ parameters.scenario }}
python3 utils/check_test_configuration.py ${{ parameters.scenario }}
displayName: Check scenario test configuration
- script: |
utils/setup_test_container.sh \
-e podman \
-a \
-m 4 \
-n "ipaserver.test.local" \
-p ${{ parameters.target_python }} \
-i ${{ parameters.scenario }} \
${{ parameters.scenario }}
displayName: Setup target container
- script: |
. utils/set_test_modules
if ! pytest \
-m "playbook" \
--verbose \
--color=yes \
--suppress-no-test-exit-code \
--splits=${{ parameters.number_of_groups }} \
--group=${{ parameters.group_number }} \
--randomly-seed=$(date "+%Y%m%d") \
--junit-xml=TEST-results-group-${{ parameters.group_number }}.xml
then
[ $? -eq 5 ] && true || false
fi
pytest -m "playbook" --verbose --color=yes --suppress-no-test-exit-code --junit-xml=TEST-results-pr-check.xml
displayName: Run playbook tests
env:
ANSIBLE_ROLES_PATH: "${PWD}/roles"
ANSIBLE_LIBRARY: "${PWD}/plugins"
ANSIBLE_MODULE_UTILS: "${PWD}/plugins/module_utils"
IPA_SERVER_HOST: ${{ parameters.scenario }}
RUN_TESTS_IN_DOCKER: true
RUN_TESTS_IN_DOCKER: podman
IPA_DISABLED_MODULES: ${{ variables.ipa_disabled_modules }}
IPA_DISABLED_TESTS: ${{ variables.ipa_disabled_tests }}
IPA_VERBOSITY: "-vvv"
IPA_PYTHON_PATH: ${{ parameters.target_python }}
- task: PublishTestResults@2
inputs:
Expand Down

0 comments on commit 1ca5c72

Please sign in to comment.