When processing subunit streams we attempt to discover where the
(s)testr commands are located. For some reason the output of our scripts
that do this very occasionally emit a newline before the command path.
When this happens we were using the blank line as the command path which
fails as that empty command results in our command arguments being
interpreted as the command path.
Attempt to address this by trimming the stdout instead of taking the
first line. This should remove the leading and trailing newlines and
give us only the command itself.
Change-Id: Id651e019cf3d0b7ab37fdf9df04be249ea7f7af6
We have seen instances where type -p (s)testr seems to return with a
leading blank line which confuses ansible later when trying to use the
first line of output as the path to (s)testr. Address this by chomping
with grep -v ^$. Additionally use type -P instead of -p to ensure we
always get a path even when the command may be an alias or builtin.
Change-Id: Ibffe1e1499eca18ef5dc3904fe222a55242b827d
We are still trying to get incomplete subunit files into our logs. This
is now failing because we assumed a single dict with a files entry to
iterate over but in reality we get a list of dicts with files entries to
iterate over. In order to iterate over this content we use
with_subelements to iterate over and copy the found files.
Change-Id: I160ac5caeec6fd7f5a35e805b7d4811b20405d14
In a previous change I attempted to log in flight subunit streams that
may be left behind if a job times out. This unfortunately didn't work
because in the cases we leave those files behind we also assume that we
don't have a valid .stestr state due to the contents of this directly.
Address this by modifying the find-stestr.sh script to indicate via its
return code if .stestr or .testrepository are present separate from
which commands are valid to run. Then in ansible we can do steps that
always apply if (s)testr were used (like copying partial logs) and
separately do subunit parsing if the contents of the (s)testr db
directories are valid.
Change-Id: I1c8f2405d74484631f633065baf9764dbd0209ee
If (s)testr are killed during a test run (possibly due to a timeout)
they will "leak" a tmp file containing the subunit stream to that point.
This file is useful for debugging so collect it. We don't process it
further as the file is a partial stream and humans may need to look at
it to make sense of it.
Change-Id: I6f0e61ec78f4dd9e2c4e52bc968b4f57586cb22e
This adds a custom ansible-lint rule at .rules/ZuulJobsNamespaceLoopVar.py
that enforces the loop var policy described at:
https://zuul-ci.org/docs/zuul-jobs/policy.html#ansible-loops-in-roles
It also updates existing roles to follow the policy.
Change-Id: I92b2ff56a1c2702542fc07b316f1809087a4c92f
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
When returning the subunit test result as an artifact it will be
directly linked on the build result page.
Change-Id: I1a83288ac0857333f87cd085b3e0243bd3b92fc2
Stop compressing files that would otherwise be handled uncompressed in
intermediate log handling. The reason for this is final log/artifact
upload should decide if a file need to be compressed or not as some file
hosting services (like swift) may not return the expected data if we get
this wrong.
This was noticed when we used swift to store intermediate tar.gz
tarballs before final upload to permanent storage. When retrieving the
tar.gz files from swift we got them back as uncompressed .tar files
(because swift was being helpful) and then later when we try to
uncompress these files we break.
Instead we'll let the upload to swift (or other storage) decide if files
should be compressed further than their existing state.
This is the first change in the stack that updates this behavior for
fetch-subunit-output.
Change-Id: I5727b270d6d34c256fe78a443baa1ad6c3474108
Change new variable zuul_additional_subunit_dirs to
fetch_subunit_output_additional_dirs to name it after the role.
Change-Id: I7ac0b5d343701409a8741439334fe27f5374a258
In addition to the main subunit file from zuul_work_dir,
collect the subunit files from the elements (directories)
of the zuul_additional_subunit_dirs list.
The default behavior is unchanged.
While the documentation of this role states that zuul_work_dir
contains an absolute path, this is not always true.
So make sure to not make any assumption about zuul_work_dir
in order to not fail spectacularly as it happened with the
previous patch[0].
Add also some tests for the role: both the basic case
and with an additional test directory.
[0] https://review.opendev.org/673885
Change-Id: Iabf2e0cf6d86e36a174778367186bbd39a65c3dd
In addition to the main subunit file from zuul_work_dir,
collect the subunit files from the elements (directories)
of the zuul_additional_subunit_dirs list.
The default behavior is unchanged.
Change-Id: Ic3bc76aa104951bcc0c186347196067342e28751
The role allows override of the zuul_work_dir variable, however in the
step where it retrieves the test results is the only step where it
prepends the directory with a fixed path. This breaks the step if the
zuul_work_dir given is a fully qualified path.
This patch defaults the zuul_work_dir to a fully qualified directory and
standarizes the usage zuul_work_dir across the role.
Change-Id: I62bc7571f625586a0d1b660f896e0c7cbaeae6e1
Use subunit2html from tox envs instead of os-testr-env
We have an openstack-infra hard-coded location in this role. Rework it
to try looking in the tox env if one exists or to look on the system.
Leave /usr/os-testr-env in as a fallback but with a debug statement so
that we can track instances of the fallback being used.
tox_envlist can be a comma separated list. If it is, the "find
subunit2html in a tox env" logic isn't going to work.
Use a shell script so that we can do a first-found logic similar to what
we use in ensure-sphinx for finding requirements files.
It's a big bash blob. Put it in a file so it syntax highlights correctly
and execute it with the script module.
Change-Id: I0b468840fd04a379007fe5aca07feb2eaf7081ac
Review comments from earlier requested a cleaner approach to the whens
with using blocks. This patch started off as that, then realized we
could make it even clearer by collapsing the tox_envlist when as well.
Change-Id: I2a32f1aa802c0727b7d15f24f58322d5e26c8693
stestr can leave a .stestr directory from which subunit cannot be
generated after an initial run that fails due to a python import/parse
error.
In order to determine if a run will be able to generate subunit output,
check for the '.stestr/failing' file.
NOTE: This is **NOT** an indication of a failing run. It's a file that
will be present in the .stestr directory if an entire run has happened
and acts as a marker that the directory has enough information to export
a subunit stream.
Change-Id: Id1dd696c81da09e9d2e5fe350337b73eb0646d2d
This reverts commit 9f4efe98e10c9d553dc8a15bd7b84584e1118684.
Compress testr results.html before fetching it
The synchronize command has testr_results.html.gz in the file list, but
we don't ever gzip it so it fails on fetch.
Make the "Check for testr directory" task actually check for
.testrepository and not for .stestr a second time.
The compression bug broke only for people using stestr. For people
using testr, the path bug meant they don't get html reports.
Change-Id: I0cdfc66ee8b046affeb0b071fef38c21cb7a4948
We don't need two roles for testr and stestr. The roles have logic to
check to see if .testrepository or .stestr dirs exist, and the logic
after the subunit extraction is the same. Combine them into a single
role which should do the right thing.
Also, document it.
Change-Id: I833320cf9a932d8e119645eb798ce0c93d854321