Skip to content

Commit

Permalink
[polarion] Merge xmls with junitparser
Browse files Browse the repository at this point in the history
In case there are multiple xml files that need to be reported
to polarion, we need to merge them before passing them to jump.
Using junitparser even in cases where there is only one xml file
will have these benefits:
* we don't have to write when conditions
* the output xml will have the same structure - the content will
be wrapped in <testsuites> tags whether we have more xml results
or not - testsuite in junitparser context equals to one xml input.
  • Loading branch information
kopecmartin authored and openshift-merge-bot[bot] committed Jul 10, 2024
1 parent 3d799fb commit 7527689
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions roles/polarion/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
state: latest # noqa: package-latest
extra_args: --upgrade

- name: Install junitparser
ansible.builtin.pip:
name: junitparser
virtualenv: "{{ cifmw_polarion_jump_repo_dir }}/jump-venv"
state: latest # noqa: package-latest

- name: Use polarion-staging
when:
- cifmw_polarion_use_stage
Expand All @@ -88,17 +94,23 @@
ansible.builtin.debug:
var: pylero_output.stdout_lines

- name: Merge result XML files
ansible.builtin.shell:
chdir: "{{ cifmw_polarion_jump_result_dir }}"
cmd: >-
source "{{ cifmw_polarion_jump_repo_dir }}/jump-venv/bin/activate" &&
junitparser merge {{ xml_files.files | json_query('[*].path') | join(' ') }} ./results_merged.xml
- name: Update Test Runs
ansible.builtin.shell:
chdir: "{{ cifmw_polarion_jump_repo_dir }}"
cmd: >-
source "{{ cifmw_polarion_jump_repo_dir }}/jump-venv/bin/activate" &&
{{ cifmw_polarion_jump_repo_dir }}/jump-venv/bin/python jump.py
--testrun-id={{ cifmw_polarion_testrun_id }}
--xml-file={{ item.path }}
--xml-file={{ cifmw_polarion_jump_result_dir }}/results_merged.xml
--update_testcases={{ cifmw_polarion_update_testcases | default(false) }}
{{ cifmw_polarion_jump_extra_vars | default ('') }}
loop: "{{ xml_files.files }}"
register: jump_script

- name: Output of jump
Expand Down

0 comments on commit 7527689

Please sign in to comment.