From bece1aa24197e2d59fc2ad917e646b51864d9705 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 29 Sep 2017 11:34:38 -0500 Subject: [PATCH] Make fetch-tox-output more resilient The current find command fails when there is an empty log directory in the dist dir as seen here: http://logs.openstack.org/87/508287/1/check/openstack-tox-py27/4e00cb9/job-output.txt.gz#_2017-09-29_04_10_39_589261 Update it to make it look specifically for the tox environments specified in tox_envlist. Make sure it supports a comma separated list as well as 'all' in tox_envlist, as those are stated valid inputs. Depends-On: I1c98508fe227f7f6aa1d0b2f7dcf270cecaa60d8 Change-Id: Id28dbd19f4f612e3e9b9feb6350250b18ae2f8c6 --- roles/fetch-tox-output/README.rst | 19 ++++++++++++- roles/fetch-tox-output/defaults/main.yaml | 5 +++- roles/fetch-tox-output/tasks/main.yaml | 28 +++++++++++-------- .../library/tox_install_sibling_packages.py | 6 +++- roles/tox-siblings/tasks/main.yaml | 1 + 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/roles/fetch-tox-output/README.rst b/roles/fetch-tox-output/README.rst index 7e1934b53..e12140142 100644 --- a/roles/fetch-tox-output/README.rst +++ b/roles/fetch-tox-output/README.rst @@ -1 +1,18 @@ -Collect output from a tox build +Collect log output from a tox build + +**Role Variables** + +.. zuul:rolevar:: tox_envlist + :default: all + + Which tox environment to fetch log output from. + +.. zuul:rolevar:: tox_executable + :default: tox + + Location of the tox executable. + +.. zuul:rolevar:: zuul_work_dir + :default: {{ zuul.project.src_dir }} + + Directory tox was run in. diff --git a/roles/fetch-tox-output/defaults/main.yaml b/roles/fetch-tox-output/defaults/main.yaml index a0afa22c5..04d20860a 100644 --- a/roles/fetch-tox-output/defaults/main.yaml +++ b/roles/fetch-tox-output/defaults/main.yaml @@ -1,2 +1,5 @@ --- -zuul_work_dir: "src/{{ zuul.project.canonical_name }}" +tox_envlist: all +tox_executable: tox + +zuul_work_dir: "{{ zuul.project.src_dir }}" diff --git a/roles/fetch-tox-output/tasks/main.yaml b/roles/fetch-tox-output/tasks/main.yaml index 31a6d0b5a..de5278d48 100644 --- a/roles/fetch-tox-output/tasks/main.yaml +++ b/roles/fetch-tox-output/tasks/main.yaml @@ -1,12 +1,3 @@ -- name: Find tox directories to synchrionize - find: - file_type: directory - paths: "{{ zuul_work_dir }}/.tox" - # NOTE(pabelanger): The .tox/log folder is empty, ignore it. - patterns: ^(?!log).*$ - use_regex: yes - register: result - - name: Set tox log path for multiple nodes set_fact: log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox" @@ -23,10 +14,25 @@ state: directory delegate_to: localhost +- name: Set envlist fact + set_fact: + envlist: "{{ tox_envlist.split(',') }}" + when: tox_envlist is defined + +- name: Find all environments + command: tox -l + register: tox_environments + when: tox_envlist is not defined or tox_envlist == 'all' + +- name: Set envlist fact + set_fact: + envlist: "{{ tox_environments.stdout_lines }}" + when: tox_envlist is not defined or tox_envlist == 'all' + - name: Collect tox logs synchronize: dest: "{{ log_path }}" mode: pull - src: "{{ item.path }}/log/" + src: "{{ zuul_work_dir }}/.tox/{{ item }}/log/" verify_host: true - with_items: "{{ result.files }}" + with_items: "{{ envlist }}" diff --git a/roles/tox-siblings/library/tox_install_sibling_packages.py b/roles/tox-siblings/library/tox_install_sibling_packages.py index 1b9df5689..8edbfe35a 100644 --- a/roles/tox-siblings/library/tox_install_sibling_packages.py +++ b/roles/tox-siblings/library/tox_install_sibling_packages.py @@ -115,8 +115,12 @@ def main(): tox_python = '{project_dir}/.tox/{envlist}/bin/python'.format( project_dir=project_dir, envlist=envlist) # Write a log file into the .tox dir so that it'll get picked up - log_file = '{project_dir}/.tox/{envlist}/log/siblings.txt'.format( + # Name it with envlist as a prefix so that fetch-tox-output will properly + # get it in a multi-env scenario + log_dir = '{project_dir}/.tox/{envlist}/log'.format( project_dir=project_dir, envlist=envlist) + log_file = '{log_dir}/{envlist}-siblings.txt'.format( + log_dir=log_dir, envlist=envlist) log = list() log.append( diff --git a/roles/tox-siblings/tasks/main.yaml b/roles/tox-siblings/tasks/main.yaml index 006369721..f2c25c1df 100644 --- a/roles/tox-siblings/tasks/main.yaml +++ b/roles/tox-siblings/tasks/main.yaml @@ -9,6 +9,7 @@ chdir: "{{ zuul_work_dir }}" when: tox_install_siblings +# TODO(mordred) handle tox_envlist being a list - name: Install any sibling python packages tox_install_sibling_packages: tox_envlist: "{{ tox_envlist }}"