Commit Graph

33 Commits

Author SHA1 Message Date
Clark Boylan b5cabbbfc7 Update fetch-subunit-output to look for nox envs
Some projects are converting from tox to nox for driving tests. This
means there isn't a tox env to find testr/stestr in. Update
fetch-subunit-output to look for nox envs as well.

Change-Id: I051c4b27d22921f1f0c3a44dc4eaccdbb50afa29
2022-12-29 13:36:03 -08:00
Ian Wienand 6d23d20f2f linters: add names to blocks
This is preparation for a later version of ansbile-lint, which finds
missing names on blocks.  This seems a reasonable rule, and the
Ansible manual says [1]

  Names for blocks have been available since Ansible 2.3. We recommend
  using names in all tasks, within blocks or elsewhere, for better
  visibility into the tasks being executed when you run the playbook.

This simply adds a name tag for blocks that are missing it.  This
should have no operational change, but allows us to update the linter
in a follow-on change.

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
2022-07-27 17:13:39 +10:00
Ian Wienand f76cfbab11 linters: fix spaces between filters
This fixes a number of places where we do not have spaces between
filters.  I think that this is a reasonable rule for readability (I
also think it probably was enforced, but maybe later versions got
better at detecting it?).

These are detected by a later version of Ansible lint; this change
should have no operational change to any roles but prepares us to
update in a follow-on change.

Change-Id: I07e1a109b87adce86f483d14d7e02fcecb8313d5
2022-07-27 17:13:39 +10:00
Clark Boylan 0206d6671a Try to fix broken stestr command discovery
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
2021-12-08 10:51:55 -08:00
Clark Boylan ce31c2c678 Find (s)testr more reliably
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
2021-08-11 10:04:39 -07:00
Sorin Sbarnea 6b8cc6d468 More E208 (final)
Change-Id: I705d1b10696326f3d4d5bef4b5a88a83f2c3d960
2020-11-10 19:34:45 +00:00
Clark Boylan 4ab37d798a Loop over incomplete subunit files properly
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
2020-08-07 14:01:18 -07:00
Clark Boylan f9475ddc41 Fix partial subunit stream logging
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
2020-08-06 11:40:46 -07:00
Clark Boylan 8a08cb94ac Collect partial subunit files
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
2020-07-22 15:32:25 -07:00
Zuul 8a35f60eb3 Merge "Remove unused tox_envlist in fetch-subunit-output" 2020-05-27 14:58:05 +00:00
Albin Vass 9a132054a6 fetch-subunit-output: update include to import_tasks
Change-Id: I5a5fb6a827ae0e6c125a21bd4058e4dca602ac45
2020-05-26 10:05:52 +02:00
Albin Vass f52d7441c4 Remove unused tox_envlist in fetch-subunit-output
Change-Id: Iaeaecaeb0e86c2d34f6526ae799b5aa65e0b5487
2020-05-19 20:24:37 +02:00
Albin Vass a914ca7a8b fetch-subunit-output: do not synchronize owner
Change-Id: I8456324fea0f064255cd8aae68035e8ee12f60e0
2020-05-18 17:05:32 +02:00
Sorin Sbarnea 4af438d136 Made sequence indent consistent
Change-Id: I5ea4232ca4fd6e03d5b5f72eb6704bee84d04ea5
2020-05-07 14:13:55 +01:00
Zuul 95a9562b81 Merge "fetch-subunit-output: use failed_when: instead of ignore_errors:" 2020-05-04 16:20:02 +00:00
Albin Vass 9062289151 Check for loop_control in with_ type loops
Change-Id: I191265df7709a6262b44a428d78fe28ffaeb4b75
2020-05-01 13:45:34 +02:00
Albin Vass d0e2016592 Add loop var policy to ansible-lint
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
2020-04-29 17:20:59 +02:00
Albin Vass 9c30d35cd6 fetch-subunit-output: use failed_when: instead of ignore_errors:
Change-Id: I6437200afb6734bba02073f07061e56f8adf1f8e
2020-04-28 16:20:20 +02:00
Tristan Cacqueray a07bbee70c 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
2020-01-24 21:07:50 +00:00
Tobias Henkel 3b0fa71dd2
Return subunit test report as artifact
When returning the subunit test result as an artifact it will be
directly linked on the build result page.

Change-Id: I1a83288ac0857333f87cd085b3e0243bd3b92fc2
2020-01-18 13:31:51 +01:00
Clark Boylan bbca430417 Stop compressing files during intermediate steps part 1
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
2020-01-08 09:24:43 -08:00
Andreas Jaeger 293b064d29 fetch_subunit: Change variable
Change new variable zuul_additional_subunit_dirs to
fetch_subunit_output_additional_dirs to name it after the role.

Change-Id: I7ac0b5d343701409a8741439334fe27f5374a258
2019-10-21 21:07:39 +02:00
Luigi Toscano ab8f9fc403 fetch-subunit-output: collect additional subunits (2nd try)
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
2019-10-17 00:42:28 +02:00
Andreas Jaeger 04f4cecaec Revert "fetch-subunit-output: collect additional subunit files"
This reverts commit 8624201e0c.

This breaks builds like in https://logs.opendev.org/01/673401/2/check/openstacksdk-tox-py36-tips/0e0bed9/job-output.txt.gz#_2019-08-01_17_04_29_549629

Change-Id: Ie4c8f966cfe72828a6ff9a7512948d6c55c62fde
2019-08-01 17:55:58 +00:00
Luigi Toscano 8624201e0c fetch-subunit-output: collect additional subunit files
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
2019-08-01 17:49:02 +02:00
Michel Peterson 724a520adf Fix lookup of subunit files in fetch-subunit-output
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
2018-02-28 14:33:35 +02:00
Monty Taylor 65257f26d7
Look for subunit2html - not an empty variable
http://logs.openstack.org/06/540406/2/check/osc-tox-py35-tips/5bbcf05/ara/result/ba549fa3-3cca-4247-98c8-4befa78f8e6c/

This is a little embarrasing.

Change-Id: I5e57af4bf04d26d4504eaa950342945efcd8ceed
2018-02-02 16:30:49 -06:00
Monty Taylor f6a92ecb6c
Make subunit processing more resilient
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
2018-01-21 10:39:49 -06:00
Monty Taylor fa54ff21e1
Clean up when conditions in fetch-subunit-output
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
2018-01-16 12:32:49 -06:00
Monty Taylor 2a0f06147e
Adjust check for .stestr directory
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
2018-01-16 11:58:24 -06:00
Monty Taylor 3d0550a96c
Revert "Revert "Add consolidated role for processing subunit""
This reverts commit 9f4efe98e1.

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
2018-01-16 11:58:18 -06:00
Monty Taylor 9f4efe98e1 Revert "Add consolidated role for processing subunit"
This reverts commit ebdcf57fb0.

Change-Id: Icfa811571ec7c26617e0f8e9db086001fc0bc81f
2018-01-16 01:10:56 +00:00
Monty Taylor ebdcf57fb0
Add consolidated role for processing subunit
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
2017-12-20 08:33:42 -06:00