| |
@@ -0,0 +1,112 @@
|
| |
+ ---
|
| |
+ - 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: 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=present
|
| |
+ 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: |
|
| |
+ cd /usr/local/bin/{{ tests_folder }}
|
| |
+ ./dnf-testing.sh run {{ item }} > test.{{ item }}.log 2>&1
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+ when: not run_in_background
|
| |
+
|
| |
+
|
| |
+ - block:
|
| |
+ - name: Running behave tests
|
| |
+ shell: |
|
| |
+ cd /usr/local/bin/{{ tests_folder }}
|
| |
+ ./dnf-testing.sh run {{ item }} > test.{{ item }}.log 2>&1 &
|
| |
+ echo $!
|
| |
+ register: proc_id
|
| |
+ with_items:
|
| |
+ - "{{ features }}"
|
| |
+ when: run_in_background
|
| |
+
|
| |
+ - name: Waiting to finish of the behave background processes
|
| |
+ shell: |
|
| |
+ while ps -p {{ item.stdout }}| grep {{ item.stdout }}
|
| |
+ do
|
| |
+ sleep 2
|
| |
+ done
|
| |
+ when: run_in_background
|
| |
+ with_items:
|
| |
+ - "{{ proc_id.results }}"
|
| |
+
|
| |
+ - name: Move logs to the remote_artifacts
|
| |
+ shell: |
|
| |
+ logfile=test.$(echo {{ item }} | sed -e 's/\//-/g').log
|
| |
+ cd /usr/local/bin/{{ tests_folder }}
|
| |
+ sudo cat $logfile > {{ remote_artifacts }}/$logfile
|
| |
+ sudo rm $logfile
|
| |
+ 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
|
| |
+ echo FAIL
|
| |
+ else
|
| |
+ echo "PASS {{ item }}" >> {{ remote_artifacts }}/test.log
|
| |
+ echo PASS
|
| |
+ fi
|
| |
+ register: test_results
|
| |
+ failed_when: "'FAIL' in test_results.stdout"
|
| |
+ 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("") != ""
|
| |
Justification
The main goal is to adopt current dnf_docker tests for ci_pipeline, see https://pagure.io/fedora-ci/AtomicCi/pull-request/74.
Added new role standard-test-behave, which includes possibility to run tests in parallel, starting it as daemon.