| |
@@ -0,0 +1,146 @@
|
| |
+ ---
|
| |
+ - name: Add executor host
|
| |
+ add_host:
|
| |
+ name: executor
|
| |
+ ansible_connection: local
|
| |
+ ansible_ssh_host: 127.0.0.1
|
| |
+ ansible_ssh_connection: local
|
| |
+
|
| |
+ - block:
|
| |
+ - name: Gather facts
|
| |
+ setup:
|
| |
+ delegate_facts: True
|
| |
+
|
| |
+ - name: Add restraint repo for restraint-rhts on Fedora hosts
|
| |
+ get_url:
|
| |
+ url: https://copr.fedorainfracloud.org/coprs/bpeck/restraint/repo/fedora-{{ansible_distribution_major_version}}/bpeck-restraint-fedora-{{ansible_distribution_major_version}}.repo
|
| |
+ dest: /etc/yum.repos.d/restraint.repo
|
| |
+ when: ansible_distribution == 'Fedora'
|
| |
+
|
| |
+ - name: Add restraint repo for restraint-rhts on RHEL/CentOS hosts
|
| |
+ get_url:
|
| |
+ url: https://copr.fedorainfracloud.org/coprs/bpeck/restraint/repo/epel-7/bpeck-restraint-epel-7.repo
|
| |
+ dest: /etc/yum.repos.d/restraint.repo
|
| |
+ when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS'
|
| |
+
|
| |
+ - name: Install the behave requirements
|
| |
+ package: name={{item}} state=latest
|
| |
+ with_items:
|
| |
+ - python2-behave
|
| |
+ delegate_to: executor
|
| |
+
|
| |
+ - block:
|
| |
+ - name: Install the behave requirements on target
|
| |
+ package: name={{item}} state=latest
|
| |
+ with_items:
|
| |
+ - python2-behave
|
| |
+
|
| |
+ - name: Install any test-specific package requirements
|
| |
+ package: name={{item}} state=latest
|
| |
+ with_items:
|
| |
+ - "{{ required_packages }}"
|
| |
+
|
| |
+ # Only manually install packages on non atomic hosts
|
| |
+ when: ansible_pkg_mgr != 'unknown'
|
| |
+
|
| |
+ - name: Define remote_artifacts if it is not already defined
|
| |
+ set_fact:
|
| |
+ remote_artifacts: /tmp/artifacts
|
| |
+ when: remote_artifacts is not defined
|
| |
+
|
| |
+ - name: Copy tests to target
|
| |
+ synchronize:
|
| |
+ src: "{{ playbook_dir }}/"
|
| |
+ dest: /usr/local/bin/
|
| |
+ ssh_args: "-o UserKnownHostsFile=/dev/null"
|
| |
+
|
| |
+ - name: Make artifacts directory
|
| |
+ file: path={{ remote_artifacts }} state=directory owner=root mode=755 recurse=yes
|
| |
+
|
| |
+ - block:
|
| |
+ - name: Running behave tests
|
| |
+ shell: |
|
| |
+ export OUTPUTFILE=/dev/stdout TEST={{ item }}
|
| |
+ logfile={{ remote_artifacts }}/test.$(echo {{ item }} | sed -e 's/\//-/g').log
|
| |
+ exec 2>>$logfile 1>>$logfile
|
| |
+ cd /usr/local/bin
|
| |
+ cd {{ tests_folder }}
|
| |
+ if [ -f runtest.sh ]; then
|
| |
+ /bin/sh -e ./runtest.sh {{ item }}
|
| |
+ elif [ -f Makefile ]; then
|
| |
+ make ARGS="{{item}}" run
|
| |
+ else
|
| |
+ echo "FAIL don't know how to run test {{ item }}"
|
| |
+ fi
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+ when: not run_in_background
|
| |
+
|
| |
+
|
| |
+ - block:
|
| |
+ - name: Running behave tests
|
| |
+ shell: |
|
| |
+ export OUTPUTFILE=/dev/stdout TEST={{ item }}
|
| |
+ exec 2>>$logfile 1>>$logfile
|
| |
+ cd /usr/local/bin
|
| |
+ cd {{ tests_folder }}
|
| |
+ if [ -f runtest.sh ]; then
|
| |
+ /bin/sh -e ./runtest.sh {{ item }} &
|
| |
+ elif [ -f Makefile ]; then
|
| |
+ make ARGS="{{item}}" run &
|
| |
+ else
|
| |
+ echo "FAIL don't know how to run test {{ item }}"
|
| |
+ fi
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+ when: run_in_background
|
| |
+
|
| |
+ - name: Waiting to finish of the behave background processes
|
| |
+ shell: |
|
| |
+ echo {{ item }}
|
| |
+ while docker ps | grep {{ item }}
|
| |
+ do
|
| |
+ sleep 2
|
| |
+ done
|
| |
+ when: run_in_background
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+
|
| |
+ - name: Move logs to the remote_artifacts
|
| |
+ shell: |
|
| |
+ logfile=test.$(echo {{ item }} | sed -e 's/\//-/g').log
|
| |
+ cd /usr/local/bin
|
| |
+ cd {{ tests_folder }}
|
| |
+ sudo cat $logfile >> {{ remote_artifacts }}/$logfile
|
| |
+ sudo rm $logfile
|
| |
+ when: run_in_background
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+
|
| |
+
|
| |
+ always:
|
| |
+ - name: Make the master test summary log artifact
|
| |
+ shell: |
|
| |
+ logfile={{ remote_artifacts }}/test.$(echo {{ item }} | sed -e 's/\//-/g').log
|
| |
+ if grep -P ', ([1-9]*) (failed)' "$logfile"; then
|
| |
+ echo "FAIL {{ item }}" >> {{ remote_artifacts }}/test.log
|
| |
+ else
|
| |
+ echo "PASS {{ item }}" >> {{ remote_artifacts }}/test.log
|
| |
+ fi
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+
|
| |
+ - name: Pull out the logs
|
| |
+ synchronize:
|
| |
+ dest: "{{ artifacts }}/"
|
| |
+ src: "{{ remote_artifacts }}/"
|
| |
+ mode: pull
|
| |
+ ssh_args: "-o UserKnownHostsFile=/dev/null"
|
| |
+ when: artifacts|default("") != ""
|
| |
+
|
| |
+ # Can't go in block. See
|
| |
+ #https://github.com/ansible/ansible/issues/20736
|
| |
+ - name: Check the results
|
| |
+ shell: grep "^FAIL" {{ remote_artifacts }}/test.log
|
| |
+ register: test_fails
|
| |
+ failed_when: test_fails.stdout or test_fails.stderr
|
| |