From 45951a69a666bba5a40354586b6776663c027b5e Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 21 Mar 2017 00:30:02 -0700 Subject: [PATCH] Rewrite ansible-pull tests to use local repo. (#22821) --- .../{pull_limit_inventory => pull}/aliases | 0 .../pull/pull-integration-test/ansible.cfg | 2 + .../pull/pull-integration-test/inventory | 2 + .../pull/pull-integration-test/local.yml | 13 +++++++ test/integration/targets/pull/runme.sh | 37 +++++++++++++++++++ .../targets/pull_limit_inventory/runme.sh | 11 ------ test/integration/targets/pull_no_127/aliases | 1 - test/integration/targets/pull_no_127/runme.sh | 12 ------ test/integration/targets/pull_run/aliases | 1 - test/integration/targets/pull_run/runme.sh | 11 ------ 10 files changed, 54 insertions(+), 36 deletions(-) rename test/integration/targets/{pull_limit_inventory => pull}/aliases (100%) create mode 100644 test/integration/targets/pull/pull-integration-test/ansible.cfg create mode 100644 test/integration/targets/pull/pull-integration-test/inventory create mode 100644 test/integration/targets/pull/pull-integration-test/local.yml create mode 100755 test/integration/targets/pull/runme.sh delete mode 100755 test/integration/targets/pull_limit_inventory/runme.sh delete mode 100644 test/integration/targets/pull_no_127/aliases delete mode 100755 test/integration/targets/pull_no_127/runme.sh delete mode 100644 test/integration/targets/pull_run/aliases delete mode 100755 test/integration/targets/pull_run/runme.sh diff --git a/test/integration/targets/pull_limit_inventory/aliases b/test/integration/targets/pull/aliases similarity index 100% rename from test/integration/targets/pull_limit_inventory/aliases rename to test/integration/targets/pull/aliases diff --git a/test/integration/targets/pull/pull-integration-test/ansible.cfg b/test/integration/targets/pull/pull-integration-test/ansible.cfg new file mode 100644 index 0000000000..f8fc6cdba7 --- /dev/null +++ b/test/integration/targets/pull/pull-integration-test/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory = inventory diff --git a/test/integration/targets/pull/pull-integration-test/inventory b/test/integration/targets/pull/pull-integration-test/inventory new file mode 100644 index 0000000000..72644cefa6 --- /dev/null +++ b/test/integration/targets/pull/pull-integration-test/inventory @@ -0,0 +1,2 @@ +testhost1.example.com +localhost diff --git a/test/integration/targets/pull/pull-integration-test/local.yml b/test/integration/targets/pull/pull-integration-test/local.yml new file mode 100644 index 0000000000..f251b43473 --- /dev/null +++ b/test/integration/targets/pull/pull-integration-test/local.yml @@ -0,0 +1,13 @@ +- name: test playbook for ansible-pull + hosts: all + tasks: + - name: debug output + debug: msg="test task" + - name: check for correct inventory + debug: msg="testing for inventory content" + failed_when: "'testhost1.example.com' not in groups['all']" + - name: check for correct limit + debug: msg="testing for limit" + failed_when: "'testhost1.example.com' == inventory_hostname" + - name: final task, has to be reached for the test to succeed + debug: msg="MAGICKEYWORD" diff --git a/test/integration/targets/pull/runme.sh b/test/integration/targets/pull/runme.sh new file mode 100755 index 0000000000..4b9da90116 --- /dev/null +++ b/test/integration/targets/pull/runme.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -eux +set -o pipefail + +# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x +temp_dir=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'ansible-testing-XXXXXXXXXX') +trap 'rm -rf "${temp_dir}"' EXIT + +repo_dir="${temp_dir}/repo" +pull_dir="${temp_dir}/pull" +temp_log="${temp_dir}/pull.log" + +cp -av "pull-integration-test" "${repo_dir}" + +( + cd "${repo_dir}" + git init + git config user.email "ansible@ansible.com" + git config user.name "Ansible Test Runner" + git add . + git commit -m "Initial commit." +) + +ANSIBLE_CONFIG='' ansible-pull -d "${pull_dir}" -U "${repo_dir}" "$@" | tee "${temp_log}" + +# test for https://github.com/ansible/ansible/issues/13688 +if ! grep MAGICKEYWORD "${temp_log}"; then + echo "Missing MAGICKEYWORD in output." + exit 1 +fi + +# test for https://github.com/ansible/ansible/issues/13681 +if grep '127\.0\.0\.1' "${temp_log}"; then + echo "Found host 127.0.0.1 in output. Only localhost should be present." + exit 1 +fi diff --git a/test/integration/targets/pull_limit_inventory/runme.sh b/test/integration/targets/pull_limit_inventory/runme.sh deleted file mode 100755 index 245ea522da..0000000000 --- a/test/integration/targets/pull_limit_inventory/runme.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -eux -set -o pipefail - -# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x -MYTMPDIR=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'ansible-testing-XXXXXXXXXX') -trap 'rm -rf "${MYTMPDIR}"' EXIT - -# test for https://github.com/ansible/ansible/issues/13688 -ANSIBLE_CONFIG='' ansible-pull -d "${MYTMPDIR}" -U https://github.com/ansible-test-robinro/pull-integration-test "$@" diff --git a/test/integration/targets/pull_no_127/aliases b/test/integration/targets/pull_no_127/aliases deleted file mode 100644 index 79d8b9285e..0000000000 --- a/test/integration/targets/pull_no_127/aliases +++ /dev/null @@ -1 +0,0 @@ -posix/ci/group3 diff --git a/test/integration/targets/pull_no_127/runme.sh b/test/integration/targets/pull_no_127/runme.sh deleted file mode 100755 index 1dc12e81dd..0000000000 --- a/test/integration/targets/pull_no_127/runme.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -eux -set -o pipefail - -# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x -MYTMPDIR=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'ansible-testing-XXXXXXXXXX') -trap 'rm -rf "${MYTMPDIR}"' EXIT - -# test for https://github.com/ansible/ansible/issues/13681 -ANSIBLE_CONFIG='' ansible-pull -d "${MYTMPDIR}" -U https://github.com/ansible-test-robinro/pull-integration-test "$@" \ - | grep -v '127\.0\.0\.1' diff --git a/test/integration/targets/pull_run/aliases b/test/integration/targets/pull_run/aliases deleted file mode 100644 index 79d8b9285e..0000000000 --- a/test/integration/targets/pull_run/aliases +++ /dev/null @@ -1 +0,0 @@ -posix/ci/group3 diff --git a/test/integration/targets/pull_run/runme.sh b/test/integration/targets/pull_run/runme.sh deleted file mode 100755 index 6100601e80..0000000000 --- a/test/integration/targets/pull_run/runme.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -eux -set -o pipefail - -# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x -MYTMPDIR=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'ansible-testing-XXXXXXXXXX') -trap 'rm -rf "${MYTMPDIR}"' EXIT - -ANSIBLE_CONFIG='' ansible-pull -d "${MYTMPDIR}" -U https://github.com/ansible-test-robinro/pull-integration-test "$@" \ - | grep MAGICKEYWORD