Merge "fetch-subunit-output: introduce zuul_use_fetch_output"

This commit is contained in:
Zuul 2020-02-17 16:42:46 +00:00 committed by Gerrit Code Review
commit 1a84d2ff5a
5 changed files with 109 additions and 0 deletions

View File

@ -17,3 +17,11 @@ Collect subunit outputs
.. zuul:rolevar:: tox_envlist
tox environment that was used to run the tests originally.
.. zuul:rolevar:: zuul_use_fetch_output
:default: false
Whether to synchronize files to the executor work dir, or to copy them
on the test instance.
When set to false, the role synchronizes the file to the executor.
When set to true, the job needs to use the fetch-output role later.

View File

@ -2,3 +2,5 @@
tox_envlist: ""
fetch_subunit_output_additional_dirs: []
zuul_work_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
zuul_output_dir: "{{ ansible_user_dir }}/zuul-output"
zuul_use_fetch_output: "{{ zuul_site_use_fetch_output|default(false) }}"

View File

@ -23,6 +23,15 @@
src: "{{ item.path }}"
verify_host: true
with_items: "{{ subunit_files.files }}"
when: not zuul_use_fetch_output
- name: Copy test-results
copy:
dest: "{{ zuul_output_dir }}/logs/"
src: "{{ item.path }}"
remote_src: true
with_items: "{{ subunit_files.files }}"
when: zuul_use_fetch_output
- name: Return artifact to Zuul
zuul_return:

View File

@ -0,0 +1,68 @@
- hosts: all
pre_tasks:
# Run ensure-output-dirs now as it is not performed speculatively
- import_role:
name: ensure-output-dirs
- name: Create fake test directory
file:
path: "{{ zuul.project.src_dir }}/ztest"
state: directory
- name: Simplify tox config
copy:
content: "{{ item.content }}"
dest: "{{ zuul.project.src_dir }}/{{ item.dest }}"
with_items:
- content: |
[testenv]
sitepackages = True
usedevelop = True
deps = stestr
[testenv:venv]
commands = stestr run --test-path ./ztest/ {posargs}
dest: tox.ini
- content: |
import setuptools
setuptools.setup()
dest: setup.py
- content: ""
dest: setup.cfg
- content: |
import unittest
class TestTestCase(unittest.TestCase):
def test_test(self):
assert True
dest: ztest/__init__.py
- name: Generate tox results
include_role:
name: "{{ item }}"
with_items:
- ensure-tox
- ensure-python
- tox
tasks:
- import_role:
name: fetch-subunit-output
- import_role:
name: fetch-output
when: zuul_use_fetch_output
post_tasks:
- name: Check for artifact on the test instance
stat:
path: "{{ ansible_user_dir }}/zuul-output/logs/testr_results.html"
register: _test_artifact
failed_when: not _test_artifact.stat.exists
when: zuul_use_fetch_output
- name: Check for artifact on the executor
stat:
path: "{{ zuul.executor.log_root }}/testr_results.html"
delegate_to: localhost
register: _executor_artifact
failed_when: not _executor_artifact.stat.exists

View File

@ -49,6 +49,26 @@
vars:
zuul_use_fetch_output: false
- job:
name: zuul-jobs-test-fetch-subunit-output
description: Test the fetch-subunit-output
files:
- roles/ensure-output-dirs/.*
- roles/fetch-subunit-output/.*
- roles/fetch-output/.*
run: test-playbooks/python/fetch-subunit-output.yaml
vars:
zuul_use_fetch_output: true
- job:
name: zuul-jobs-test-fetch-subunit-output-synchronize
description: Test the fetch-subunit-output
files:
- roles/fetch-subunit-output/.*
run: test-playbooks/python/fetch-subunit-output.yaml
vars:
zuul_use_fetch_output: false
- project:
check:
jobs: &id001
@ -57,5 +77,7 @@
- zuul-jobs-test-tox-siblings
- zuul-jobs-test-fetch-tox-output
- zuul-jobs-test-fetch-tox-output-synchronize
- zuul-jobs-test-fetch-subunit-output
- zuul-jobs-test-fetch-subunit-output-synchronize
gate:
jobs: *id001