Skip to content

Commit

Permalink
CI - Add app/testinfra results into combinedf junit
Browse files Browse the repository at this point in the history
In english, this should make it much simpler for a developer to get
status in CircleCI when either the testinfra or application tests fail
at an execution level. Previously this data was hard to parse and/or
required manually reading thru an artifact.

Fixes #2800

(cherry picked from commit 39f2d82)
  • Loading branch information
msheiny authored and redshiftzero committed Jan 26, 2018
1 parent 652b274 commit 54cdbb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
25 changes: 20 additions & 5 deletions molecule/aws/side_effect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,30 @@
ignore_errors: true
no_log: true

- name: Establish list of raw test results
set_fact:
raw_test_results:
- type: app
file: scripts/app-tests.sh
result: "{{ app_test_register }}"
- type: testinfra
file: scripts/ci-tester.sh
result: "{{ testinfra_results }}"

- name: Dump raw test output
copy:
dest: "../../raw-test-output/{{item.type}}_tests.raw"
content: "{{ item.result }}"
with_items:
- type: app
result: "{{ app_test_register }}"
- type: testinfra
result: "{{ testinfra_results }}"
with_items: "{{ raw_test_results }}"
no_log: true
become: no
delegate_to: localhost

- name: Dump results into junit files
template:
src: junit.xml.j2
dest: "../../{{ item.type }}-results.xml"
with_items: "{{ raw_test_results }}"
become: no
no_log: true
delegate_to: localhost
Expand Down
8 changes: 8 additions & 0 deletions molecule/aws/templates/junit.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="{% if item.result|failed %}1{% else %}0{% endif %}" name="ansible" tests="1" time="0">
<testcase classname="high-level-test-runner-result" file="{{ item.file }}" name="{{ item.type }}" time="0">
<system-out>{{ item.result.stdout|striptags }}</system-out>
<system-err>{{ item.result.stderr|striptags }}</system-err>
{% if item.result|failed %}<failure message="{{ item.type }} runner failed during execution phase"></failure>{% endif %}
</testcase>
</testsuite>

0 comments on commit 54cdbb1

Please sign in to comment.