From 20ab1d2994eebf3a0af3925a8a1f6faf210a2842 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Sat, 10 Feb 2018 10:48:44 -0800 Subject: [PATCH] Move requirements into tests. (#35885) (cherry picked from commit e7b793c8c6818a32c07f4f2b3e174b9994aa8449) --- test/integration/targets/ansible-galaxy/aliases | 1 + test/integration/targets/ansible-galaxy/runme.sh | 2 ++ .../integration/targets/ansible-galaxy/setup.yml | 6 ++++++ .../targets/command_shell/tasks/main.yml | 12 +++--------- test/integration/targets/copy/tasks/tests.yml | 4 ---- test/integration/targets/gem/tasks/main.yml | 16 ++++++++++++++++ test/integration/targets/gem/vars/FreeBSD.yml | 3 +++ test/integration/targets/gem/vars/RedHat.yml | 2 ++ test/integration/targets/gem/vars/default.yml | 1 + test/integration/targets/git/tasks/setup.yml | 5 +++++ test/integration/targets/pull/runme.sh | 2 ++ test/integration/targets/pull/setup.yml | 6 ++++++ .../targets/subversion/tasks/main.yml | 5 +++++ .../targets/synchronize/tasks/main.yml | 5 +++++ test/runner/setup/remote.sh | 12 ------------ 15 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 test/integration/targets/ansible-galaxy/setup.yml create mode 100644 test/integration/targets/gem/vars/FreeBSD.yml create mode 100644 test/integration/targets/gem/vars/RedHat.yml create mode 100644 test/integration/targets/gem/vars/default.yml create mode 100644 test/integration/targets/pull/setup.yml diff --git a/test/integration/targets/ansible-galaxy/aliases b/test/integration/targets/ansible-galaxy/aliases index 79d8b9285e..20777639a7 100644 --- a/test/integration/targets/ansible-galaxy/aliases +++ b/test/integration/targets/ansible-galaxy/aliases @@ -1 +1,2 @@ +destructive posix/ci/group3 diff --git a/test/integration/targets/ansible-galaxy/runme.sh b/test/integration/targets/ansible-galaxy/runme.sh index 5372568769..58f9a0a9e0 100755 --- a/test/integration/targets/ansible-galaxy/runme.sh +++ b/test/integration/targets/ansible-galaxy/runme.sh @@ -2,6 +2,8 @@ set -eux -o pipefail +ansible-playbook setup.yml + # Need a relative custom roles path for testing various scenarios of -p galaxy_relative_rolespath="my/custom/roles/path" diff --git a/test/integration/targets/ansible-galaxy/setup.yml b/test/integration/targets/ansible-galaxy/setup.yml new file mode 100644 index 0000000000..581902474d --- /dev/null +++ b/test/integration/targets/ansible-galaxy/setup.yml @@ -0,0 +1,6 @@ +- hosts: localhost + tasks: + - name: install git + package: + name: git + when: ansible_distribution != "MacOSX" diff --git a/test/integration/targets/command_shell/tasks/main.yml b/test/integration/targets/command_shell/tasks/main.yml index b8d5438187..858f07d1a8 100644 --- a/test/integration/targets/command_shell/tasks/main.yml +++ b/test/integration/targets/command_shell/tasks/main.yml @@ -100,10 +100,6 @@ shell: which bash register: bash -- name: locate sha1sum/shasum - shell: which sha1sum || which shasum - register: sha1sum - ## ## command ## @@ -196,7 +192,7 @@ - "command_result5.stdout == 'foobar'" - name: send to stdin literal multiline block - command: "{{ sha1sum.stdout }}" + command: "{{ ansible_python_interpreter }} -c 'import hashlib, sys; print(hashlib.sha1((sys.stdin.buffer if hasattr(sys.stdin, \"buffer\") else sys.stdin).read()).hexdigest())'" args: stdin: |- this is the first line @@ -209,7 +205,7 @@ - name: assert the multiline input was passed correctly assert: that: - - "command_result6.stdout == '9cd0697c6a9ff6689f0afb9136fa62e0b3fee903 -'" + - "command_result6.stdout == '9cd0697c6a9ff6689f0afb9136fa62e0b3fee903'" ## ## shell @@ -278,9 +274,7 @@ "multiline echo" \ "with a new line in quotes" \ - | {{ sha1sum.stdout }} \ - | tr -s ' ' \ - | cut -f1 -d ' ' + | {{ ansible_python_interpreter }} -c 'import hashlib, sys; print(hashlib.sha1((sys.stdin.buffer if hasattr(sys.stdin, "buffer") else sys.stdin).read()).hexdigest())' echo "this is a second line" register: shell_result5 diff --git a/test/integration/targets/copy/tasks/tests.yml b/test/integration/targets/copy/tasks/tests.yml index 59afb2bfad..3567171d6f 100644 --- a/test/integration/targets/copy/tasks/tests.yml +++ b/test/integration/targets/copy/tasks/tests.yml @@ -9,10 +9,6 @@ set_fact: remote_file: "{{ remote_dir }}/foo.txt" -- name: Locate sha1sum/shasum - shell: which sha1sum || which shasum - register: sha1sum - - name: Initiate a basic copy, and also test the mode copy: src: foo.txt diff --git a/test/integration/targets/gem/tasks/main.yml b/test/integration/targets/gem/tasks/main.yml index adf76d7c33..77b93e663d 100644 --- a/test/integration/targets/gem/tasks/main.yml +++ b/test/integration/targets/gem/tasks/main.yml @@ -16,6 +16,22 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +- include_vars: '{{ item }}' + with_first_found: + - files: + - '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml' + - '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml' + - '{{ ansible_os_family }}.yml' + - 'default.yml' + paths: '../vars' + +- name: install dependencies for test + package: name={{ package_item }} state=present + with_items: "{{ test_packages }}" + loop_control: + loop_var: package_item + when: ansible_distribution != "MacOSX" + - name: remove a gem gem: name=gist state=absent diff --git a/test/integration/targets/gem/vars/FreeBSD.yml b/test/integration/targets/gem/vars/FreeBSD.yml new file mode 100644 index 0000000000..84e0b483d5 --- /dev/null +++ b/test/integration/targets/gem/vars/FreeBSD.yml @@ -0,0 +1,3 @@ +test_packages: + - "devel/ruby-gems" + - "ruby" diff --git a/test/integration/targets/gem/vars/RedHat.yml b/test/integration/targets/gem/vars/RedHat.yml new file mode 100644 index 0000000000..c044d109b6 --- /dev/null +++ b/test/integration/targets/gem/vars/RedHat.yml @@ -0,0 +1,2 @@ +test_packages: + - "rubygems" diff --git a/test/integration/targets/gem/vars/default.yml b/test/integration/targets/gem/vars/default.yml new file mode 100644 index 0000000000..7d6e61ac46 --- /dev/null +++ b/test/integration/targets/gem/vars/default.yml @@ -0,0 +1 @@ +test_packages: [] diff --git a/test/integration/targets/git/tasks/setup.yml b/test/integration/targets/git/tasks/setup.yml index 588d99c99c..8fdb2a401c 100644 --- a/test/integration/targets/git/tasks/setup.yml +++ b/test/integration/targets/git/tasks/setup.yml @@ -8,6 +8,11 @@ path: "{{ output_dir }}" state: directory +- name: SETUP | install git + package: + name: git + when: ansible_distribution != "MacOSX" + - name: SETUP | verify that git is installed so this test can continue shell: which git diff --git a/test/integration/targets/pull/runme.sh b/test/integration/targets/pull/runme.sh index 7334df93ca..0ad9e01ba9 100755 --- a/test/integration/targets/pull/runme.sh +++ b/test/integration/targets/pull/runme.sh @@ -11,6 +11,8 @@ repo_dir="${temp_dir}/repo" pull_dir="${temp_dir}/pull" temp_log="${temp_dir}/pull.log" +ansible-playbook setup.yml + cp -av "pull-integration-test" "${repo_dir}" cd "${repo_dir}" ( diff --git a/test/integration/targets/pull/setup.yml b/test/integration/targets/pull/setup.yml new file mode 100644 index 0000000000..581902474d --- /dev/null +++ b/test/integration/targets/pull/setup.yml @@ -0,0 +1,6 @@ +- hosts: localhost + tasks: + - name: install git + package: + name: git + when: ansible_distribution != "MacOSX" diff --git a/test/integration/targets/subversion/tasks/main.yml b/test/integration/targets/subversion/tasks/main.yml index 3f89c236eb..5631adbd89 100644 --- a/test/integration/targets/subversion/tasks/main.yml +++ b/test/integration/targets/subversion/tasks/main.yml @@ -25,6 +25,11 @@ - name: clean out the output_dir shell: rm -rf {{ output_dir }}/* +- name: install subversion + package: + name: subversion + when: ansible_distribution != "MacOSX" + - name: verify that subversion is installed so this test can continue shell: which svn diff --git a/test/integration/targets/synchronize/tasks/main.yml b/test/integration/targets/synchronize/tasks/main.yml index 5913762183..80e052a6a3 100644 --- a/test/integration/targets/synchronize/tasks/main.yml +++ b/test/integration/targets/synchronize/tasks/main.yml @@ -16,6 +16,11 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +- name: install rsync + package: + name: rsync + when: ansible_distribution != "MacOSX" + - name: cleanup old files shell: rm -rf {{output_dir}}/* diff --git a/test/runner/setup/remote.sh b/test/runner/setup/remote.sh index 2b83056c81..d8d2a7707e 100644 --- a/test/runner/setup/remote.sh +++ b/test/runner/setup/remote.sh @@ -14,16 +14,9 @@ if [ "${platform}" = "freebsd" ]; then pkg install -y \ bash \ curl \ - devel/ruby-gems \ - git \ gtar \ - mercurial \ python \ - rsync \ - ruby \ - subversion \ sudo \ - zip \ && break echo "Failed to install packages. Sleeping before trying again..." sleep 10 @@ -34,15 +27,10 @@ elif [ "${platform}" = "rhel" ]; then while true; do yum install -y \ gcc \ - git \ - mercurial \ python-devel \ python-jinja2 \ python-virtualenv \ python2-cryptography \ - rubygems \ - subversion \ - unzip \ && break echo "Failed to install packages. Sleeping before trying again..." sleep 10