28 Commits

Author SHA1 Message Date
Eduardo Olivares
5af7c53c05 Add support to skip tests from CLI
With this patch, a new pytest optional arg has been added:
--skipregex

When it is used, tests are skipped when the regex is found in their test
names. Fully qualified test names are used for this search. Example:
tobiko.tests.unit.test_exception.TestException.test_init

It can be used from CLI with pytest like this:
$ .tox/py3/bin/pytest \
  --skipregex='test_join_chunks_.*_bytes|test_join_chunks_with_unicodes' \
  tobiko/tests/unit

It can be used from CLI with tox like this:
$ PYTEST_ADDOPTS="--skipregex='test_join_chunks_.*_bytes|test_join_chunks_with_unicodes'" \
  TOX_PYTHON=python3.9 \
  tox -e py3

It can be used from the Tobiko Infrared plugin by using the following
option (limitation: the skipregex is applied to all the steps from the
the executed Tobiko workflow):
$ infrared tobiko ... --pytest-addopts "--skipregex='test_join_chunks_.*_bytes|test_join_chunks_with_unicodes'"

It can be used from a zuul job by configuring the following variable
within the zuul job yaml file (limitation: the skipregex is applied to
all the steps from the executed Tobiko workflow):
pytest_addopts_global: "--skipregex='test_join_chunks_.*_bytes|test_join_chunks_with_unicodes'"

Change-Id: I8ee32ba467bd70142816953598d1736fa353d3d0
2023-12-04 12:17:26 +01:00
Eduardo Olivares
4ff3f54fdf Reset tox_env and other params for every test workflow step
The tox env values defined at step N are reused at step N+1
These values should be reset at the end of every step

Change-Id: Ied76f789a071e50917ce6752ecea17140775a99f
2022-08-10 12:24:07 +02:00
Eduardo Olivares
ca75cf4ff4 Remove redundant printing of tobiko execution output
Tobiko test run output was printed twice:
- during the execution of the tests
- during the debug task "show test cases output" right after the
  previous one

This patch removes the second task

Change-Id: I5336660baece1fe4df64d0aa09bd575f6e9b98fc
2022-07-06 16:27:43 +02:00
Federico Ressi
886f21cb2e Add option to select test cases by markers
Change-Id: I773b710eb4f4a8abb1cebc13088d3cc16ff08334
2022-02-15 14:56:17 +00:00
Federico Ressi
ad94fe92b1 Handle maxfail pytest option from InfraRed plugin
This allows to specify PyTest options depending on the workflow step
For instance in the faults workflow step below option is used:
  --maxfail 1

The option can be forced for all speps with below InfraRed plugin option:

 --pytest-maxfail <N>

For more details about pytest options please have a look to pytest help page:

  tox -e py3 -- --help

Change-Id: I3146819b5f80fa4768ea38032cc8e69dc7b44f18
2022-01-26 10:30:57 +01:00
Federico Ressi
9a418ad0ed Skip flaky test cases with IR plugin
Change-Id: I0320cdd00078f1c8a6acc19116fce88daed891c6
2022-01-25 15:50:24 +00:00
Federico Ressi
03b9eec659 Use local upper-constraints.txt
- Remove support for constrains file from infrared plugin
- Use file stored on tobiko repository by default

Change-Id: I0f835d753fb9d3a1670e8eb9b196e02e989d4262
2021-10-27 14:33:56 +02:00
Zuul
88fbfe6329 Merge "Add option to skip all remaining test cases after a given timeout is expired" 2021-07-10 00:15:58 +00:00
Federico Ressi
61a6332185 Add option to skip all remaining test cases after a given timeout is expired
After some given seconds of timeout test runner execution self-interrupt
to avoid hitting jobs timeout.

The problem is that when it occurs all remaining test cases that didn't started
yet are missing from the reports.

This changes things by marking such test cases as skipped, so that we
can see it from test results.

Change-Id: Idd0064812fc5a2da295712914c4531bdef466c24
2021-07-09 09:39:32 +00:00
Federico Ressi
3fa4d50d71 Accept yaml format for --tox-enviroment Infrared plugin option
This allows to execute below command line:

  tox -e infrared -- --tox-environment '\{VAR1: VALUE1, VAR2: VALUE2\}'

Change-Id: Ic6cc2f62f9baa8d2e6d233209de1ed3f22f7887c
2021-07-08 20:11:50 +00:00
Eduardo Olivares
8073f3ae5a Fix "raise error in case of timeout" task from tobiko-tox role
Change-Id: I2fb9090edac3e6c764df56fbe971b5b8ec69ee6c
2021-03-23 11:23:33 +00:00
Eduardo Olivares
84d8592c82 Force failure when test execution times out
Change-Id: Ie585f6de6c760f02a8b2cf169a0f4a768f52db95
2021-03-12 09:19:43 +01:00
Federico Ressi
31a9a6e8e6 Add a timeout for workflow stages
Change-Id: I9938a8bbd71ab131c8b6a2210e5d1a903ef21efd
2020-09-28 12:04:49 +02:00
Federico Ressi
9cf069dbb0 Remove support for Python2.7 on all upstream jobs
Because upstream OpenStack requirements master branch
(Victoria) removed any support for Python 2.7 upstream
jobs started failing. We where only using Python 2
because infrared installation process fails on
RHEL/CentOS 7 and Python 3 due to lacking SE Linux
Python bindings.

This workaround this issue by removing support
for Python 2.7 and CentOS/RHEL 7. The support for
CentOS 7 could be restored once the IR issue has
been fixed.

Change-Id: I09d2577a0e5cb4c7efbb6863294f63b2dd88de0a
2020-05-18 14:58:20 +02:00
Alex Katz
32c91c7264 Added --ignore-test-failures CLI flag
Tox venv commands are expected to return a code that indicates
test cases final outcome:

 - 0 => any test vase has failed
 - 1 => some test case has failed
 - not in [0, 1] => any other error

This change handles the special case when some test cases have
failed. In any of below cases:
 - JENKINS_URL environment variable is defined on controller node
 - --ignore-test-failure flag is passed to IR plugin
then the plugin runs without treating it as an error.

This has been introduced because when running the plugin from
a Jenkins slave host, Jenkins itself is expected to check test
case have failed looking at produced Junit XML artifacts.

Change-Id: Ia7d7f736ae18a7561dced2271228d86ca658e892
2020-05-11 13:57:26 +00:00
Federico Ressi
92248c8506 Refactor test execution scripts
- Acreate a new tools/run_tests.py script to
  execute test cases
- Move report generation to such script and
  remove 'report' tox environment
- Running test cases generates report files
  (.log, .html, .xml) into 'report/{envname}'
  directory
- Test cases failures will returns exit code 1
  Other script test runner failures returns
  exit code 2

Big refactory to tox.ini file to try semplifying it:

- create the new 'py3' tox environment for running unit
  tests as default platform python 3 interpreter
- use same as py3 '{envdir}' for scenario, functional,
  neutron and faults tox environments

Change-Id: Id09425245cc86b84b41e6b3b1c1db759cc686f3a
2020-05-06 17:41:35 +02:00
Federico Ressi
388426812d Use upper-constraints file from requirements project
Change-Id: I26318898ced32248a2ff31a78ec15d49382b9027
2020-05-04 14:47:41 +02:00
Federico Ressi
31f6026ab9 Implement test workflow steps
Change-Id: I34026836ac42dd6f2a5e5dfc05203c460cc949fc
2020-04-08 14:32:58 +02:00
Federico Ressi
86441d7aac Update roles requiring python
Change-Id: Iae5cd4affc3e7d148221e55768fbdf6d28907e54
2020-04-03 11:10:38 +00:00
Federico Ressi
0d9e88a6fe Verify infrared plugin actually collect output files
Change-Id: Ib4f8961f50bd3ed68e472eb0fb6be67e27f156f3
2020-04-02 07:59:20 +00:00
Federico Ressi
5c1edfac76 Add role to ensure tox is installed on target host
Change-Id: I8d2ee07bc84efb7eb0eb23a64ecdff97fd5cecb6
2020-04-01 12:22:27 +02:00
Federico Ressi
10c1eda1fc Add role to ensure python3 is installed on target host
Change-Id: I3b514f3a3cb1f50ac121ca9d865eb500cf49b975
2020-04-01 11:27:25 +02:00
Federico Ressi
e116222308 Allow to specify python interpter used for testing IR plugin
Change-Id: I2ea68efed1fe1c0dc22b3c49118cfc5c93c8a037
2020-04-01 08:42:00 +00:00
Federico Ressi
5a41476432 Separate run_tox and make_report tasks
Change-Id: Ic064cdaa2b001358f3748b433baa1f9055db940a
2020-03-23 20:25:24 +00:00
Zuul
c355ccd476 Merge "Keep separed test results messages from errors" 2020-03-17 16:36:01 +00:00
Federico Ressi
cbfb7ffbdc Keep separed test results messages from errors
Change-Id: I17bbdba20aa863b316d3ff5850eeeac885a5b4c4
2020-03-17 13:39:09 +00:00
Federico Ressi
71722d07c6 Use regular tox as default command
Change-Id: Id929b2bf80fd8e4898c743f9bfa085b431799de6
2020-03-17 13:40:44 +01:00
Federico Ressi
a4ab99ba89 Spliting infrared plugin into roles
Create a set of roles to be composed into a new infrared plugin. The
final goal for these roles is to be used for either downstream and
upstream CI

Change-Id: I48d5f500c2e694c3f94ee497a0df1d92b6c411b3
2020-03-17 11:07:08 +00:00