fetch-subunit-output: introduce zuul_use_fetch_output
This change enables using fetch-subunit-output role along with the fetch-output role. By default the role still synchronizes artifacts back to the executor. Change-Id: I50a50856b96a9112c1b4be82ca04b612fd29d939
This commit is contained in:
parent
be8308c7ac
commit
a07bbee70c
@ -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.
|
||||
|
@ -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) }}"
|
||||
|
@ -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:
|
||||
|
68
test-playbooks/python/fetch-subunit-output.yaml
Normal file
68
test-playbooks/python/fetch-subunit-output.yaml
Normal 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
|
@ -42,6 +42,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
|
||||
@ -49,5 +69,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
|
||||
|
Loading…
Reference in New Issue
Block a user