Update the standard-test-scripts from standard-test-roles

We're still before a new release of standard-test-roles, so
keep updating this role here.
This commit is contained in:
Stef Walter 2017-09-25 19:37:22 +02:00
parent d9a218b7d5
commit 0be74aea08
2 changed files with 22 additions and 7 deletions

View File

@ -8,7 +8,7 @@ the role will fail.
In the case of test subjects such a host or container, these In the case of test subjects such a host or container, these
test scripts and related files will be copied to the target into test scripts and related files will be copied to the target into
/usr/local/bin before execution. /var/tmp/tests before execution.
You should define the following variables: You should define the following variables:

View File

@ -1,8 +1,14 @@
--- ---
- name: Install testing requirements
package: name={{ item }} state=present
with_items:
- rsync
when: ansible_pkg_mgr != 'unknown'
- name: Copy test scripts to target - name: Copy test scripts to target
synchronize: synchronize:
src: "{{ item }}" src: "{{ item }}"
dest: /usr/local/bin/ dest: /var/tmp/tests/
ssh_args: "-o UserKnownHostsFile=/dev/null" ssh_args: "-o UserKnownHostsFile=/dev/null"
with_items: with_items:
- "{{ tests }}" - "{{ tests }}"
@ -11,16 +17,17 @@
- block: - block:
- name: Execute test scripts - name: Execute test scripts
shell: | shell: |
mkdir -p /tmp/artifacts set -e
logfile=/tmp/artifacts/test.$(echo {{ item }} | sed -e 's/\//-/g').log mkdir -p /var/tmp/artifacts
logfile=/var/tmp/artifacts/test.$(echo {{ item }} | sed -e 's/\//-/g').log
exec 2>>$logfile 1>>$logfile exec 2>>$logfile 1>>$logfile
cd /usr/local/bin cd /var/tmp/tests
if [ -x {{ item }} ]; then if [ -x {{ item }} ]; then
./$(basename {{ item }}) && result="PASS" || result="FAIL" ./$(basename {{ item }}) && result="PASS" || result="FAIL"
else else
/bin/sh -e ./$(basename {{ item }}) && result="PASS" || result="FAIL" /bin/sh -e ./$(basename {{ item }}) && result="PASS" || result="FAIL"
fi fi
echo "$result {{ item }}" >> /tmp/artifacts/test.log echo "$result {{ item }}" >> /var/tmp/artifacts/test.log
with_items: with_items:
- "{{ tests }}" - "{{ tests }}"
@ -28,6 +35,14 @@
- name: Pull out the logs - name: Pull out the logs
synchronize: synchronize:
dest: "{{ artifacts }}" dest: "{{ artifacts }}"
src: "/tmp/artifacts/./" src: "/var/tmp/artifacts/./"
mode: pull mode: pull
ssh_args: "-o UserKnownHostsFile=/dev/null"
when: artifacts|default("") != "" when: artifacts|default("") != ""
# Can't go in block. See
# https://github.com/ansible/ansible/issues/20736
- name: Check the results
shell: grep "^FAIL" /var/tmp/artifacts/test.log
register: test_fails
failed_when: test_fails.stdout or test_fails.stderr