diff options
author | Matt Clay <matt@mystile.com> | 2023-02-28 22:21:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-28 22:21:11 +0100 |
commit | f47bc03599eedc48753d2cd5e1bea177f35e6133 (patch) | |
tree | ade0b2627a3245a329308b9d8bec53b684097701 /test | |
parent | add a worker queue to get updates from the main results thread (#79886) (diff) | |
download | ansible-f47bc03599eedc48753d2cd5e1bea177f35e6133.tar.xz ansible-f47bc03599eedc48753d2cd5e1bea177f35e6133.zip |
Relocate the AZP entry point scripts (#80114)
Scripts previously under `test/utils/shippable/` are now under `.azure-pipelines/commands/` instead.
Diffstat (limited to 'test')
22 files changed, 38 insertions, 452 deletions
diff --git a/test/lib/ansible_test/_internal/classification/__init__.py b/test/lib/ansible_test/_internal/classification/__init__.py index 5c7009488a..3cf6044e52 100644 --- a/test/lib/ansible_test/_internal/classification/__init__.py +++ b/test/lib/ansible_test/_internal/classification/__init__.py @@ -662,21 +662,54 @@ class PathMapper: def _classify_ansible(self, path: str) -> t.Optional[dict[str, str]]: """Return the classification for the given path using rules specific to Ansible.""" + dirname = os.path.dirname(path) + filename = os.path.basename(path) + name, ext = os.path.splitext(filename) + + minimal: dict[str, str] = {} + + # Early classification that needs to occur before common classification belongs here. + if path.startswith('test/units/compat/'): return { 'units': 'test/units/', } + if dirname == '.azure-pipelines/commands': + test_map = { + 'cloud.sh': 'integration:cloud/', + 'linux.sh': 'integration:all', + 'network.sh': 'network-integration:all', + 'remote.sh': 'integration:all', + 'sanity.sh': 'sanity:all', + 'units.sh': 'units:all', + 'windows.sh': 'windows-integration:all', + } + + test_match = test_map.get(filename) + + if test_match: + test_command, test_target = test_match.split(':') + + return { + test_command: test_target, + } + + cloud_target = f'cloud/{name}/' + + if cloud_target in self.integration_targets_by_alias: + return { + 'integration': cloud_target, + } + + # Classification common to both ansible and collections. + result = self._classify_common(path) if result is not None: return result - dirname = os.path.dirname(path) - filename = os.path.basename(path) - name, ext = os.path.splitext(filename) - - minimal: dict[str, str] = {} + # Classification here is specific to ansible, and runs after common classification. if path.startswith('bin/'): return all_tests(self.args) # broad impact, run all tests @@ -792,39 +825,6 @@ class PathMapper: if path.startswith('test/support/'): return all_tests(self.args) # test infrastructure, run all tests - if path.startswith('test/utils/shippable/'): - if dirname == 'test/utils/shippable': - test_map = { - 'cloud.sh': 'integration:cloud/', - 'linux.sh': 'integration:all', - 'network.sh': 'network-integration:all', - 'remote.sh': 'integration:all', - 'sanity.sh': 'sanity:all', - 'units.sh': 'units:all', - 'windows.sh': 'windows-integration:all', - } - - test_match = test_map.get(filename) - - if test_match: - test_command, test_target = test_match.split(':') - - return { - test_command: test_target, - } - - cloud_target = 'cloud/%s/' % name - - if cloud_target in self.integration_targets_by_alias: - return { - 'integration': cloud_target, - } - - return all_tests(self.args) # test infrastructure, run all tests - - if path.startswith('test/utils/'): - return minimal - if '/' not in path: if path in ( '.gitattributes', diff --git a/test/sanity/code-smell/package-data.py b/test/sanity/code-smell/package-data.py index 0c6e76134e..38509f1da6 100644 --- a/test/sanity/code-smell/package-data.py +++ b/test/sanity/code-smell/package-data.py @@ -29,9 +29,6 @@ def assemble_files_to_ship(complete_file_list): 'hacking/ticket_stubs/*', 'test/sanity/code-smell/botmeta.*', 'test/sanity/code-smell/release-names.*', - 'test/utils/*', - 'test/utils/*/*', - 'test/utils/*/*/*', 'test/results/.tmp/*', 'test/results/.tmp/*/*', 'test/results/.tmp/*/*/*', diff --git a/test/utils/shippable/alpine.sh b/test/utils/shippable/alpine.sh deleted file mode 120000 index 6ddb776854..0000000000 --- a/test/utils/shippable/alpine.sh +++ /dev/null @@ -1 +0,0 @@ -remote.sh
\ No newline at end of file diff --git a/test/utils/shippable/cloud.sh b/test/utils/shippable/cloud.sh deleted file mode 100755 index da037e09e1..0000000000 --- a/test/utils/shippable/cloud.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -cloud="${args[0]}" -python="${args[1]}" -group="${args[2]}" - -target="shippable/${cloud}/group${group}/" - -stage="${S:-prod}" - -changed_all_target="shippable/${cloud}/smoketest/" - -if ! ansible-test integration "${changed_all_target}" --list-targets > /dev/null 2>&1; then - # no smoketest tests are available for this cloud - changed_all_target="none" -fi - -if [ "${group}" == "1" ]; then - # only run smoketest tests for group1 - changed_all_mode="include" -else - # smoketest tests already covered by group1 - changed_all_mode="exclude" -fi - -# shellcheck disable=SC2086 -ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - --remote-terminate always --remote-stage "${stage}" \ - --docker --python "${python}" --changed-all-target "${changed_all_target}" --changed-all-mode "${changed_all_mode}" diff --git a/test/utils/shippable/fedora.sh b/test/utils/shippable/fedora.sh deleted file mode 120000 index 6ddb776854..0000000000 --- a/test/utils/shippable/fedora.sh +++ /dev/null @@ -1 +0,0 @@ -remote.sh
\ No newline at end of file diff --git a/test/utils/shippable/freebsd.sh b/test/utils/shippable/freebsd.sh deleted file mode 120000 index 6ddb776854..0000000000 --- a/test/utils/shippable/freebsd.sh +++ /dev/null @@ -1 +0,0 @@ -remote.sh
\ No newline at end of file diff --git a/test/utils/shippable/galaxy.sh b/test/utils/shippable/galaxy.sh deleted file mode 120000 index 700ad3edcf..0000000000 --- a/test/utils/shippable/galaxy.sh +++ /dev/null @@ -1 +0,0 @@ -cloud.sh
\ No newline at end of file diff --git a/test/utils/shippable/generic.sh b/test/utils/shippable/generic.sh deleted file mode 100755 index 28eb12688e..0000000000 --- a/test/utils/shippable/generic.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -python="${args[1]}" - -if [ "${#args[@]}" -gt 2 ]; then - target="shippable/generic/group${args[2]}/" -else - target="shippable/generic/" -fi - -# shellcheck disable=SC2086 -ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - --docker default --python "${python}" diff --git a/test/utils/shippable/i.sh b/test/utils/shippable/i.sh deleted file mode 100755 index efa2866d2e..0000000000 --- a/test/utils/shippable/i.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# Temporary script to support side-by-side testing for incidental code coverage. -# Once collection migration has been completed the incidental tests can be combined with the regular tests. - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -script="${args[1]}" - -IFS='/' test="${args[*]:1}" - -"test/utils/shippable/incidental/${script}.sh" "${test}" diff --git a/test/utils/shippable/incidental/ios.sh b/test/utils/shippable/incidental/ios.sh deleted file mode 120000 index cad3e41b70..0000000000 --- a/test/utils/shippable/incidental/ios.sh +++ /dev/null @@ -1 +0,0 @@ -network.sh
\ No newline at end of file diff --git a/test/utils/shippable/incidental/network.sh b/test/utils/shippable/incidental/network.sh deleted file mode 100755 index 1c489f9e31..0000000000 --- a/test/utils/shippable/incidental/network.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -platform="${args[0]}" -version="${args[1]}" -python_version="${args[2]}" - -target="shippable/${platform}/incidental/" - -stage="${S:-prod}" -provider="${P:-default}" - -# python versions to test in order -# all versions run full tests -IFS=' ' read -r -a python_versions <<< \ - "$(PYTHONPATH="${PWD}/test/lib" python -c 'from ansible_test._internal import constants; print(" ".join(constants.CONTROLLER_PYTHON_VERSIONS))')" - -if [ "${python_version}" ]; then - # limit tests to a single python version - python_versions=("${python_version}") -fi - -for python_version in "${python_versions[@]}"; do - # terminate remote instances on the final python version tested - if [ "${python_version}" = "${python_versions[-1]}" ]; then - terminate="always" - else - terminate="never" - fi - - # shellcheck disable=SC2086 - ansible-test network-integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - --platform "${platform}/${version}" \ - --docker default --python "${python_version}" \ - --remote-terminate "${terminate}" --remote-stage "${stage}" --remote-provider "${provider}" -done diff --git a/test/utils/shippable/incidental/vyos.sh b/test/utils/shippable/incidental/vyos.sh deleted file mode 120000 index cad3e41b70..0000000000 --- a/test/utils/shippable/incidental/vyos.sh +++ /dev/null @@ -1 +0,0 @@ -network.sh
\ No newline at end of file diff --git a/test/utils/shippable/incidental/windows.sh b/test/utils/shippable/incidental/windows.sh deleted file mode 100755 index ad77ace726..0000000000 --- a/test/utils/shippable/incidental/windows.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -version="${args[1]}" - -target="shippable/windows/incidental/" - -stage="${S:-prod}" -provider="${P:-default}" - -# python version to run full tests on while other versions run minimal tests -python_default="$(PYTHONPATH="${PWD}/test/lib" python -c 'from ansible_test._internal import constants; print(constants.CONTROLLER_MIN_PYTHON_VERSION)')" - -# version to test when only testing a single version -single_version=2012-R2 - -# shellcheck disable=SC2086 -ansible-test windows-integration --list-targets -v ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} > /tmp/explain.txt 2>&1 || { cat /tmp/explain.txt && false; } -{ grep ' windows-integration: .* (targeted)$' /tmp/explain.txt || true; } > /tmp/windows.txt - -if [ -s /tmp/windows.txt ] || [ "${CHANGED:+$CHANGED}" == "" ]; then - echo "Detected changes requiring integration tests specific to Windows:" - cat /tmp/windows.txt - - echo "Running Windows integration tests for multiple versions concurrently." - - platforms=( - --windows "${version}" - ) -else - echo "No changes requiring integration tests specific to Windows were detected." - echo "Running Windows integration tests for a single version only: ${single_version}" - - if [ "${version}" != "${single_version}" ]; then - echo "Skipping this job since it is for: ${version}" - exit 0 - fi - - platforms=( - --windows "${version}" - ) -fi - -# shellcheck disable=SC2086 -ansible-test windows-integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - "${platforms[@]}" \ - --docker default --python "${python_default}" \ - --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}" diff --git a/test/utils/shippable/linux.sh b/test/utils/shippable/linux.sh deleted file mode 100755 index 9cc2f966cb..0000000000 --- a/test/utils/shippable/linux.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -image="${args[1]}" - -if [ "${#args[@]}" -gt 2 ]; then - target="shippable/posix/group${args[2]}/" -else - target="shippable/posix/" -fi - -# shellcheck disable=SC2086 -ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - --docker "${image}" diff --git a/test/utils/shippable/macos.sh b/test/utils/shippable/macos.sh deleted file mode 120000 index 6ddb776854..0000000000 --- a/test/utils/shippable/macos.sh +++ /dev/null @@ -1 +0,0 @@ -remote.sh
\ No newline at end of file diff --git a/test/utils/shippable/remote.sh b/test/utils/shippable/remote.sh deleted file mode 100755 index b64e0d46fc..0000000000 --- a/test/utils/shippable/remote.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -platform="${args[0]}" -version="${args[1]}" -pyver=default - -# check for explicit python version like 8.3@3.8 -declare -a splitversion -IFS='@' read -ra splitversion <<< "$version" - -if [ "${#splitversion[@]}" -gt 1 ]; then - version="${splitversion[0]}" - pyver="${splitversion[1]}" -fi - -if [ "${#args[@]}" -gt 2 ]; then - target="shippable/posix/group${args[2]}/" -else - target="shippable/posix/" -fi - -stage="${S:-prod}" -provider="${P:-default}" - -# shellcheck disable=SC2086 -ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - --python "${pyver}" --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}" \ diff --git a/test/utils/shippable/rhel.sh b/test/utils/shippable/rhel.sh deleted file mode 120000 index 6ddb776854..0000000000 --- a/test/utils/shippable/rhel.sh +++ /dev/null @@ -1 +0,0 @@ -remote.sh
\ No newline at end of file diff --git a/test/utils/shippable/sanity.sh b/test/utils/shippable/sanity.sh deleted file mode 100755 index 6dc4d1da9a..0000000000 --- a/test/utils/shippable/sanity.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -group="${args[1]}" - -if [ "${BASE_BRANCH:-}" ]; then - base_branch="origin/${BASE_BRANCH}" -else - base_branch="" -fi - -case "${group}" in - 1) options=(--skip-test pylint --skip-test ansible-doc --skip-test docs-build --skip-test package-data --skip-test changelog --skip-test validate-modules) ;; - 2) options=( --test ansible-doc --test docs-build --test package-data --test changelog) ;; - 3) options=(--test pylint --exclude test/units/ --exclude lib/ansible/module_utils/) ;; - 4) options=(--test pylint test/units/ lib/ansible/module_utils/) ;; - 5) options=( --test validate-modules) ;; -esac - -# shellcheck disable=SC2086 -ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \ - --docker --keep-git --base-branch "${base_branch}" \ - "${options[@]}" --allow-disabled diff --git a/test/utils/shippable/shippable.sh b/test/utils/shippable/shippable.sh deleted file mode 100755 index 8fa12482f2..0000000000 --- a/test/utils/shippable/shippable.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -script="${args[0]}" - -test="$1" - -docker images -docker ps - -for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do - docker rm -f "${container}" || true # ignore errors -done - -docker ps - -export PATH="${PWD}/bin:${PATH}" -export PYTHONIOENCODING='utf-8' - -if [ -n "${COVERAGE:-}" ]; then - # on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value - export COVERAGE="--coverage" -elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then - # on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message - export COVERAGE="--coverage" -else - # on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled) - export COVERAGE="--coverage-check" -fi - -if [ -n "${COMPLETE:-}" ]; then - # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value - export CHANGED="" -elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then - # disable change detection triggered by having 'ci_complete' in the latest commit message - export CHANGED="" -else - # enable change detection (default behavior) - export CHANGED="--changed" -fi - -if [ "${IS_PULL_REQUEST:-}" == "true" ]; then - # run unstable tests which are targeted by focused changes on PRs - export UNSTABLE="--allow-unstable-changed" -else - # do not run unstable tests outside PRs - export UNSTABLE="" -fi - -if [[ "${COVERAGE:-}" == "--coverage" ]]; then - timeout=60 -else - timeout=50 -fi - -ansible-test env --dump --show --timeout "${timeout}" --color -v - -"test/utils/shippable/${script}.sh" "${test}" diff --git a/test/utils/shippable/ubuntu.sh b/test/utils/shippable/ubuntu.sh deleted file mode 120000 index 6ddb776854..0000000000 --- a/test/utils/shippable/ubuntu.sh +++ /dev/null @@ -1 +0,0 @@ -remote.sh
\ No newline at end of file diff --git a/test/utils/shippable/units.sh b/test/utils/shippable/units.sh deleted file mode 100755 index dc115dec15..0000000000 --- a/test/utils/shippable/units.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -version="${args[1]}" - -# shellcheck disable=SC2086 -ansible-test units --color -v --docker default --python "${version}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \ diff --git a/test/utils/shippable/windows.sh b/test/utils/shippable/windows.sh deleted file mode 100755 index 714588b88b..0000000000 --- a/test/utils/shippable/windows.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail -eux - -declare -a args -IFS='/:' read -ra args <<< "$1" - -version="${args[1]}" -group="${args[2]}" - -target="shippable/windows/group${group}/" - -stage="${S:-prod}" -provider="${P:-default}" - -# python versions to test in order -IFS=' ' read -r -a python_versions <<< \ - "$(PYTHONPATH="${PWD}/test/lib" python -c 'from ansible_test._internal import constants; print(" ".join(constants.CONTROLLER_PYTHON_VERSIONS))')" - -# python version to run full tests on while other versions run minimal tests -python_default="$(PYTHONPATH="${PWD}/test/lib" python -c 'from ansible_test._internal import constants; print(constants.CONTROLLER_MIN_PYTHON_VERSION)')" - -# version to test when only testing a single version -single_version=2012-R2 - -# shellcheck disable=SC2086 -ansible-test windows-integration --list-targets -v ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} > /tmp/explain.txt 2>&1 || { cat /tmp/explain.txt && false; } -{ grep ' windows-integration: .* (targeted)$' /tmp/explain.txt || true; } > /tmp/windows.txt - -if [ -s /tmp/windows.txt ] || [ "${CHANGED:+$CHANGED}" == "" ]; then - echo "Detected changes requiring integration tests specific to Windows:" - cat /tmp/windows.txt - - echo "Running Windows integration tests for multiple versions concurrently." - - platforms=( - --windows "${version}" - ) -else - echo "No changes requiring integration tests specific to Windows were detected." - echo "Running Windows integration tests for a single version only: ${single_version}" - - if [ "${version}" != "${single_version}" ]; then - echo "Skipping this job since it is for: ${version}" - exit 0 - fi - - platforms=( - --windows "${version}" - ) -fi - -for version in "${python_versions[@]}"; do - changed_all_target="all" - changed_all_mode="default" - - if [ "${version}" == "${python_default}" ]; then - # smoketest tests - if [ "${CHANGED}" ]; then - # with change detection enabled run tests for anything changed - # use the smoketest tests for any change that triggers all tests - ci="${target}" - changed_all_target="shippable/windows/smoketest/" - if [ "${target}" == "shippable/windows/group1/" ]; then - # only run smoketest tests for group1 - changed_all_mode="include" - else - # smoketest tests already covered by group1 - changed_all_mode="exclude" - fi - else - # without change detection enabled run entire test group - ci="${target}" - fi - else - # only run minimal tests for group1 - if [ "${target}" != "shippable/windows/group1/" ]; then continue; fi - # minimal tests for other python versions - ci="shippable/windows/minimal/" - fi - - # terminate remote instances on the final python version tested - if [ "${version}" = "${python_versions[-1]}" ]; then - terminate="always" - else - terminate="never" - fi - - # shellcheck disable=SC2086 - ansible-test windows-integration --color -v --retry-on-error "${ci}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \ - "${platforms[@]}" --changed-all-target "${changed_all_target}" --changed-all-mode "${changed_all_mode}" \ - --docker default --python "${version}" \ - --remote-terminate "${terminate}" --remote-stage "${stage}" --remote-provider "${provider}" -done |