From 131e8544b832580d9884806c99f305aba15d8672 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Mon, 7 Aug 2017 13:53:38 -0400 Subject: [PATCH] Add fetch-stestr-output role This commit adds a new role for jobs that run stestr instead of testrepository. This will generate the output using stestr for those cases like we do with testr for the old jobs which leverage testrepository. This change is the dual of the jenkins script patch: I1fc3b146e99e3484fa009b227ee5d0aeb6ed6084 Change-Id: Ibf652801507ad2845281dd540b4007b04875b2ae --- roles/fetch-stestr-output/defaults/main.yaml | 2 ++ roles/fetch-stestr-output/tasks/main.yaml | 23 +++++++++++++++ roles/fetch-stestr-output/tasks/process.yaml | 31 ++++++++++++++++++++ roles/fetch-testr-output/tasks/main.yaml | 2 ++ 4 files changed, 58 insertions(+) create mode 100644 roles/fetch-stestr-output/defaults/main.yaml create mode 100644 roles/fetch-stestr-output/tasks/main.yaml create mode 100644 roles/fetch-stestr-output/tasks/process.yaml diff --git a/roles/fetch-stestr-output/defaults/main.yaml b/roles/fetch-stestr-output/defaults/main.yaml new file mode 100644 index 000000000..a0afa22c5 --- /dev/null +++ b/roles/fetch-stestr-output/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +zuul_work_dir: "src/{{ zuul.project.canonical_name }}" diff --git a/roles/fetch-stestr-output/tasks/main.yaml b/roles/fetch-stestr-output/tasks/main.yaml new file mode 100644 index 000000000..baa10b174 --- /dev/null +++ b/roles/fetch-stestr-output/tasks/main.yaml @@ -0,0 +1,23 @@ +- name: Register stestr directory + stat: + path: "{{ zuul_work_dir }}/.stestr" + register: stestr_stat + +- name: Process testr artifacts + include: process.yaml + when: + - stestr_stat.stat.exists + +- name: Collect test-results + synchronize: + dest: "{{ zuul.executor.log_root }}" + mode: pull + rsync_opts: + - "--ignore-missing-args" + src: "{{ zuul_work_dir }}/{{ item }}" + verify_host: true + with_items: + - "*testr_results.html.gz" + - "*testrepository.subunit.gz" + when: + - stestr_stat.stat.exists diff --git a/roles/fetch-stestr-output/tasks/process.yaml b/roles/fetch-stestr-output/tasks/process.yaml new file mode 100644 index 000000000..96eabe173 --- /dev/null +++ b/roles/fetch-stestr-output/tasks/process.yaml @@ -0,0 +1,31 @@ +- name: Generate testrepository.subunit file + shell: ".tox/{{ tox_envlist }}/bin/stestr last --subunit > ./testrepository.subunit" + args: + chdir: "{{ zuul_work_dir }}" + +- name: Generate testr_results.html file + command: "/usr/os-testr-env/bin/subunit2html ./testrepository.subunit testr_results.html" + args: + chdir: "{{ zuul_work_dir }}" + +- name: Register testrepository.subunit file + stat: + path: "{{ zuul_work_dir }}/testrepository.subunit" + register: p + +- name: Compress testrepository.subunit file + archive: + path: "{{ p.stat.path }}" + when: + - p.stat.exists + +- name: Register testr_results.html file + stat: + path: "{{ zuul_work_dir }}/testr_results.html" + register: html + +- name: Compress testr_results.html file + archive: + path: "{{ html.stat.path }}" + when: + - html.stat.exists diff --git a/roles/fetch-testr-output/tasks/main.yaml b/roles/fetch-testr-output/tasks/main.yaml index 5e8f0633d..0fe37b821 100644 --- a/roles/fetch-testr-output/tasks/main.yaml +++ b/roles/fetch-testr-output/tasks/main.yaml @@ -19,3 +19,5 @@ with_items: - "*testr_results.html.gz" - "*testrepository.subunit.gz" + when: + - testrepository_stat.stat.exists