From 7f97e137eb2e558a0b340025bc7b34b779d751b1 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Fri, 20 Mar 2020 10:09:31 +0100 Subject: [PATCH] Copy test result files to zull logs dir Change-Id: I6abef9016403d6b3c2801a9de64a55f237b99fab --- playbooks/infrared/post.yaml | 9 +++++++++ playbooks/infrared/pre.yaml | 12 +++++++++--- roles/plugin.spec | 4 ---- roles/tobiko-collect/defaults/main.yaml | 3 --- roles/tobiko-collect/tasks/main.yaml | 21 ++++++++------------- roles/tobiko-common/defaults/main.yaml | 20 ++++++++++---------- zuul.d/infrared.yaml | 9 ++++++--- 7 files changed, 42 insertions(+), 36 deletions(-) create mode 100644 playbooks/infrared/post.yaml diff --git a/playbooks/infrared/post.yaml b/playbooks/infrared/post.yaml new file mode 100644 index 000000000..98fc89abb --- /dev/null +++ b/playbooks/infrared/post.yaml @@ -0,0 +1,9 @@ +--- + +- hosts: all + tasks: + + - name: "list test results files at '{{ test_results_dir }}'" + command: + cmd: 'ls -lh' + chdir: '{{ test_results_dir }}' diff --git a/playbooks/infrared/pre.yaml b/playbooks/infrared/pre.yaml index 210ab93f0..a9ed9f0f5 100644 --- a/playbooks/infrared/pre.yaml +++ b/playbooks/infrared/pre.yaml @@ -2,6 +2,12 @@ - hosts: all tasks: - - debug: - msg: | - TODO(fressi): prepare here host before executing tox -e infrared + - name: "ensure test results directory is writable by user '{{ ansible_user }}'" + file: + path: '{{ item }}' + state: directory + owner: '{{ ansible_user }}' + mode: '0755' + become: yes + loop: + - '{{ test_results_dir }}' diff --git a/roles/plugin.spec b/roles/plugin.spec index abc6520d7..f26c02751 100644 --- a/roles/plugin.spec +++ b/roles/plugin.spec @@ -116,7 +116,3 @@ subparsers: type: Value help: local directory where report files are going to be copied to ansible_variable: test_collect_dir - compress-collected: - type: Flag - help: compress report files before collecting them - ansible_variable: compress_collected_files diff --git a/roles/tobiko-collect/defaults/main.yaml b/roles/tobiko-collect/defaults/main.yaml index 0b887804e..96be84768 100644 --- a/roles/tobiko-collect/defaults/main.yaml +++ b/roles/tobiko-collect/defaults/main.yaml @@ -5,6 +5,3 @@ report_dir: '{{ test_report_dir | realpath }}' report_files: '{{ test_report_files }}' report_name: '{{ test_report_name }}' collect_dir: '{{ test_collect_dir | realpath }}' - -compress_collected_files: no -report_files_suffix: '{% if (compress_collected_files | bool) %}.gz{% endif %}' diff --git a/roles/tobiko-collect/tasks/main.yaml b/roles/tobiko-collect/tasks/main.yaml index 9c70d81e7..9ab482678 100644 --- a/roles/tobiko-collect/tasks/main.yaml +++ b/roles/tobiko-collect/tasks/main.yaml @@ -4,7 +4,7 @@ file: path: '{{ collect_dir }}' state: directory - delegate_to: 127.0.0.1 + delegate_to: localhost - name: "look for report files in {{ report_dir }}" @@ -32,24 +32,19 @@ loop: '{{ report_files }}' -- name: "filter out non existing files" +- name: "filter out non existing report files" set_fact: - report_files: '{{ stat_report_files.results | json_query("[?stat.exists].stat.path") }}' - - -- name: "compress report files" - when: compress_collected_files | bool - archive: - path: '{{ item }}' - loop: '{{ report_files }}' + report_files: > + {{ stat_report_files.results | + json_query("[?stat.exists].stat.path") }} - name: "collect report files to local directory '{{ collect_dir }}'" synchronize: - dest: '{{ collect_dir }}' + dest: '{{ collect_dir }}/{{ item | basename }}' mode: pull - src: "{{ item }}{{ report_files_suffix }}" + src: '{{ item }}' use_ssh_args: yes recursive: yes - loop: '{{ report_files }}' ignore_errors: yes + loop: '{{ report_files }}' diff --git a/roles/tobiko-common/defaults/main.yaml b/roles/tobiko-common/defaults/main.yaml index 51f5ca3db..55093f087 100644 --- a/roles/tobiko-common/defaults/main.yaml +++ b/roles/tobiko-common/defaults/main.yaml @@ -2,7 +2,7 @@ # --- Tobiko deploy options --------------------------------------------------- -user_home: '{{ ansible_env.get("HOME", "~")}}' +user_home: '{{ ansible_env.get("HOME", "~") }}' tobiko_dir: '{{ user_home }}/src/tobiko' tobiko_src_dir: '{{ role_path | dirname | dirname }}' @@ -13,9 +13,9 @@ tobiko_git_version: '' # --- Test deploy options ----------------------------------------------------- -test_dir: '{{ tobiko_dir }}' -test_src_dir: '{{ tobiko_src_dir }}' -test_git_repo: '{{ tobiko_git_repo }}' +test_dir: '{{ tobiko_dir | realpath }}' +test_src_dir: '{{ tobiko_src_dir | realpath }}' +test_git_repo: '{{ tobiko_git_repo | realpath }}' test_git_refspec: '' test_git_version: '' @@ -23,7 +23,7 @@ test_git_version: '' # --- Test configuration options ---------------------------------------------- # Configuration options -test_conf_file: '{{ test_dir }}/tobiko.conf' +test_conf_file: '{{ test_dir | realpath }}/tobiko.conf' test_conf: {} @@ -33,16 +33,16 @@ test_log_debug: true # --- Test report options ----------------------------------------------------- # Remote directory where test cases shoulw write report files to -test_report_dir: "{{ test_dir }}" +test_report_dir: "{{ test_dir | realpath }}" test_report_files: - - '{{ test_conf_file }}' - - '{{ test_log_file }}' + - '{{ test_conf_file | realpath }}' + - '{{ test_log_file | realpath }}' # Test report files prefix test_report_name: test_results # Log file where test cases should write logging messages to -test_log_file: "{{ test_report_dir }}/tobiko.log" +test_log_file: '{{ test_report_dir | realpath }}/tobiko.log' # Local where test cases results are being collected to -test_collect_dir: "{{ test_src_dir }}/{{ test_report_name }}" +test_collect_dir: '{{ test_src_dir | realpath }}/{{ test_report_name }}' diff --git a/zuul.d/infrared.yaml b/zuul.d/infrared.yaml index f913af36e..c641d5ff4 100644 --- a/zuul.d/infrared.yaml +++ b/zuul.d/infrared.yaml @@ -2,16 +2,19 @@ - job: name: tobiko-tox-infrared-py36 - parent: openstack-tox + parent: openstack-tox-py36 abstract: true timeout: 1800 description: | Run test cases using tobiko infrared plugin vars: + zuul_output_dir: '{{ ansible_user_dir }}/zuul-output' + test_results_dir: '{{ zuul_output_dir }}/logs' tox_envlist: infrared - bindep_profile: test - python_version: 3.6 + tox_extra_args: > + -- --collect-dir '{{ test_results_dir }}' pre-run: playbooks/infrared/pre.yaml + post-run: playbooks/infrared/post.yaml - job: