Yet more ansible muckery, to get test results

Looks like the code I copied from standard-test-roles
has changed; let's reincorporate it.

In particular, there is now an annoying step that pulls
logs and artifacts from remote-host:/tmp/artifacts .
Well, that doesn't exist in our case because /tmp may
not survive reboots. Workaround: after completion of
each test, push our local (master) artifacts to remote.

And, fix a typo in results.yml

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago 2020-05-13 13:29:13 -06:00
parent f86ac1f054
commit 5dd1bdae66
3 changed files with 41 additions and 12 deletions

View File

@ -1,21 +1,36 @@
---
# Copied from standard-test-basic
- name: check results
local_action: shell egrep "^(FAIL|ERROR)" "{{ artifacts }}/test.log"
register: test_fails
# Never fail at this step. Just store result of tests.
failed_when: False
# ...and, 2020-05-13, updated, looks like they changed the whole thing around
- name: Check the results
local_action:
module: shell
cmd: |
log="{{ artifacts }}/test.log"
if [ ! -f "$log" ]; then
echo ERROR
echo "Test results not found." 1>&2
elif grep ^ERROR "$log" 1>&2; then
echo ERROR
elif grep ^FAIL "$log" 1>&2; then
echo FAIL
elif grep -q ^PASS "$log"; then
echo PASS
else
echo ERROR
echo "No test results found." 1>&2
fi
register: test_results
- name: preserve results
- name: Set role result
set_fact:
role_result_failed: "{{ (test_fails.stdout|d|length > 0) or (test_fails.stderr|d|length > 0) }}"
role_result_msg: "{{ test_fails.stdout|d('tests failed.') }}"
role_result: "{{ test_results.stdout }}"
role_message: "{{ test_results.stderr|d('test execution error.') }}"
- name: display results
vars:
msg: |
Tests failed: {{ role_result_failed|d('Undefined') }}
Tests msg: {{ role_result_msg|d('None') }}
role_result: {{ role_result|d('Undefined') }}
{{ role_message|d('[No error messages found]') }}
debug:
msg: "{{ msg.split('\n') }}"
failed_when: "role_result_failed|bool"
failed_when: role_message|d("") != ""

View File

@ -71,3 +71,17 @@
- test.bats.log
- test.summary.log
- helper.sh
# AAAAARGH!
#
# Fedora gating tests are failing, because str-common-final/tasks/main.yml
# tries to pull test.log and other logs from $remote_host:/tmp/artifacts .
# Those don't exist, because I track status and artifacts locally, because
# with the reboot I can't rely on /tmp being preserved.
# I see no way to tell str-common-final to skip this step; so let's just
# push logs over upon completion of each subtest.
- name: keep remote artifacts synced
synchronize:
src: "{{ artifacts }}/"
dest: "{{ remote_artifacts|d('/tmp/artifacts') }}/"
mode: push

View File

@ -21,7 +21,7 @@
local_action: command truncate --size=0 {{ artifacts }}/test.log
- name: clear test results (results.yml)
local_action: copy content="requires:\n" dest={{ artifacts }}/results.yml
local_action: copy content="results:\n" dest={{ artifacts }}/results.yml
# These are the actual tests: set cgroups vN, then run root/rootless tests.
- name: set cgroups and run podman tests