Commit Graph

101 Commits

Author SHA1 Message Date
Takashi Kajinami 61e4defcf7 Remove six
This library no longer supports python 2 thus usage of six is no longer
needed.

Change-Id: Id114f020916e52bf1588c8679bfd7df776b1c702
2024-02-08 17:50:28 +09:00
Takashi Kajinami a4876f6d6d Fix compatibility with subunit >= 1.4.3
The subunit.test_results module is no longer imported by the top-level
subunit module and we have to explicitly import it.

This also fixes the broken doc build caused by the history.rst file.
The change log is now maintained differently so we don't need it
any more.

Closes-Bug: #2045766
Change-Id: Iae1ae0c55b8e1660a2bb41379a1f8f8506679cca
2023-12-20 23:23:58 +09:00
niuke 204fe38386 remove unicode from code
Change-Id: Iea91567941e16007750498114d279dde12571fb8
2022-09-21 08:22:13 +08:00
Ghanshyam Mann 6f10535042 Remove the deprecated ostestr command
ostestr command has been deprecated in June 2019
- I3a6084db9f86627e3e94abaa4fb4aec52a01126a

This command is replaced by the stestr. os_testr
repo which has other utilities also is not deprecated
and will continue to be maintained.

QA meeting discussion:
https://meetings.opendev.org/irclogs/%23openstack-qa/%23openstack-qa.2022-03-22.log.html#t2022-03-22T15:45:36

Change-Id: Ic0cddcc226f092ac6df405e83b2e7660d71d0ba2
2022-03-24 16:49:44 -05:00
dengzhaosen 738256ac5a Ussuri+ is python3 only and update python to python3
Change-Id: Ief7301cffbe84ebf9b6d3fc7ca261ebe2b69eee3
2021-05-06 09:34:13 +08:00
Hervé Beraud 3ee44d3708 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: I34614487e74771ea980b7bd213d11ed5c960460d
2020-08-01 19:43:16 +00:00
Ghanshyam Mann eabcb94756 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I8c269117dba546ee2c75685dbd29756407488aaf
2020-07-31 23:22:25 +00:00
Zuul 248dc815d0 Merge "[ussuri][goal] Drop python 2.7 support and testing" 2020-03-10 18:01:24 +00:00
Ghanshyam Mann fcf791b38a [ussuri][goal] Drop python 2.7 support and testing
OpenStack is dropping the py2.7 support in ussuri cycle.

os-testr is ready with python 3 and ok to drop the
python 2.7 support.

Complete discussion & schedule can be found in
- http://lists.openstack.org/pipermail/openstack-discuss/2019-October/010142.html
- https://etherpad.openstack.org/p/drop-python2-support

Ussuri Communtiy-wide goal:
https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html

Switch to using sphinx-build, remove cruft from setup.cfg, setup.py,
tox.ini, conf.py.
Update hacking version to support python3 properly.
Fix problems found by pep8.

Change-Id: I6ab22dda05132a735bd9e5caf16cc2bd172b06cc
2020-03-04 01:35:46 +00:00
lkuchlan 2c07d4e638 subunit2html dealing with incorrect data format
The patch encodes a data string which contains
non-ASCII characters to unicode type.

In python2 there are two text types str and unicode.
When we add two different text types, for example:
>>> "Hello " + u"World"
u'Hello World'

The string on the left is decoded by using the default
system encoding into a Unicode string.
If it would contain non-ASCII characters(as in our case)
this normally blow up with an UnicodeDecodeError because
the default encoding is set to ASCII.

Change-Id: I17e5aa6f45133d9d12aa38cec9cc42694913d4bd
Closes-Bug: #1857901
2020-01-22 10:55:32 +02:00
jacky06 414bbf6d85 Update hacking version
Use latest release 1.1.0 and compatible changes w.r.t pep8

Change-Id: I67c57d65accb3822f7f6a03fea96356fae9025b9
2019-06-30 05:52:12 +00:00
caoyuan ad00e6d41b Replace git.openstack.org URLs with opendev.org URLs
1. Replace git.openstack.org URLs with opendev.org URLs
2. Update some URLs to latest

Change-Id: Ifcb01ece24fb28d4dc28daa0a638787280fe8eb5
Closes-Bug: #1826529
2019-06-25 09:33:30 +00:00
Zuul bced00648a Merge "Deprecate ostestr command" 2019-06-18 13:44:34 +00:00
Masayuki Igawa a5bc990fdc
Deprecate ostestr command
This commit adds deprecation comments to README, the user doc and
warning message to in the command. We already switched to use
`stestr` command instead of `ostestr`. And we haven't maintained
this command recently. So, it would be good to make it clearer for
users.

Change-Id: I3a6084db9f86627e3e94abaa4fb4aec52a01126a
2019-06-03 18:44:07 +09:00
Zuul f16df2636c Merge "Fix warning message with double "to"" 2019-06-02 15:04:46 +00:00
Andreas Jaeger 70f183c052 Fix warning message with double "to"
Fix warning message:
One "to" is enough, also improve sentence with adding "file".

Change-Id: I69b1f9f30ac51a5d34eec78ceda8fdd9405a6ff1
2019-05-24 20:11:47 +00:00
Tim Burke 595c06c5bc Default concurrency to 0 to avoid TypeError in stestr
The traceback would look like

Traceback (most recent call last):
  File ".../bin/ostestr", line 10, in <module>
    sys.exit(main())
  File ".../os_testr/ostestr.py", line 263, in main
    exit(ostestr(sys.argv[1:]))
  File ".../os_testr/ostestr.py", line 259, in ostestr
    return _select_and_call_runner(opts, regex, others)
  File ".../os_testr/ostestr.py", line 212, in _select_and_call_runner
    black_regex=opts.black_regex)
  File ".../os_testr/ostestr.py", line 167, in call_testr
    black_regex=black_regex)
  File ".../stestr/commands/run.py", line 334, in run_command
    concurrency = _to_int(concurrency)
  File ".../stestr/commands/run.py", line 39, in _to_int
    i = int(possible)
TypeError: int() argument must be a string or a number, not 'NoneType'

New enough stestr will tolerate it, but still write a warning to stderr.
See https://github.com/mtreinish/stestr/commit/ac8dac0

Change-Id: I70a3ed6c3edaafc8bb6269b1ae07bd46b06f4db4
2019-04-09 08:28:45 -07:00
Manik Bindlish 59db2ded82 Change openstack-dev to openstack-discuss
Mailinglists have been updated.
Openstack-discuss replaces openstack-dev.

Change-Id: I18dac707d84cf34ae4af2b506ff9e95ce8833383
2018-12-16 10:56:29 +00:00
Matthew Treinish 2b3e2e88f7
Fix load command in pdb/no-discover path
This commit fixes a small oversight in the ostestr --pdb/--no-discover
path. When we go to load the results from the run the command used to
load the results was still using testrepository, which is not used
anywhere else in ostestr at this point.(and is not in requirements.txt
anymore) This commit fixes this and switches it to use stestr instead.
That also exposed another bug in that code path where it was assuming
a repository was created before ostestr was run which is fixed as part
of this commit.

Change-Id: Icb3492ab0f08248a33f711807b150b4a9748fda6
2018-01-17 12:34:51 -05:00
Szymon Datko 96db91056a Fix regex builder
Currently when the blacklist_file and regex string is provided,
the constructed regex looks like '^((?!black1|black2|...).)*$regex'.
This is incorrect, as it will match nothing - some string
is expected after end of the line [denoted as $ in the regex].

The proper construction is like ^(?!black1|black2|...).*(regex).*$
This solves the issue with Tempest, where using blacklist for smoke
tests is not working now, as it leads into the issue described above.

Change-Id: Icdeb3c311f7eb414158aedb4c030494b419211c0
Closes-Bug: #1506215
Closes-Bug: #1595119
Closes-Bug: #1622722
Closes-Bug: #1669455
2017-11-24 16:59:10 +01:00
Luigi Toscano b6ac6ac48e Fix .testr.conf detection: test path follows discover
Apparently if -t is not specified, the path to the unit test directory
follows immediately the "discover" keyword.
This fixes the discovery for the .testr.conf in the sahara repository
(even if is being replaced by .stestr.conf, the fix may still be
useful).

Also, split the code which discover the legacy values in its own function
to simplify the testing.

Finally, disable hacking rule H405 which kept flagging incorrectly a long
multiline string as docstring.

Change-Id: Ide155a8e6b2b746c81388bacc0822c68d853b5a1
2017-09-27 17:17:45 +02:00
Matthew Treinish 7dd678e372 Switch to stestr under the covers
This commit switches the ostestr command to use stestr under the covers.
This simplifies the majority of the logic, eventually ostestr will
be deprecated as a result of this migration. (since almost all the logic
here is contained in stestr already)

Depends-On: I2c7618a742439fd2ed26879f3114f0f66fd6337f
Change-Id: Id7cb2a39a8308f1413608dcf19273a1d7f33592e
2017-08-29 11:03:30 -04:00
Divyansh Acharya 8ca44080d7 Just changed the opening of the file
Previous code worked fine in python 2.7 but generated
"ResourceWarning: Unclosed file" in python 3.4+
Does not change the funtionality of the code at all.
Also updated the unit tests to work with the new code.

Change-Id: If98df5c4905f4b5a22602ba19224f9368fc8129f
2017-08-24 18:58:57 +00:00
Attila Fazekas c282cbfc46 Fail when no test case selected
When the list based filtering logic was used
and no test was selected at the end.
testr was invoked to run all test.

For example:
ostestr --regex a --black-regex a

Change-Id: I7b580c3954f71dc5fe347b82d6d14004bfdb8f22
2017-05-22 12:06:28 +02:00
Masayuki Igawa 289b7e3d38
Fix error when without --regex option
This commit fixes the error when executing without --regex option.

Closes-bug: #1666569
Change-Id: Iee7037328e41c1087b87219dac4256d50784ae64
2017-02-21 16:41:00 -05:00
Jenkins f0e3a1a014 Merge "Track failures during sorting of test results" 2017-01-30 14:35:24 +00:00
Jenkins 90cc78ab0a Merge "Fix typo and change regexp to regex" 2017-01-30 14:28:38 +00:00
Jenkins 5fd84420f8 Merge "Save subunit results file when using --no-discover" 2017-01-27 00:40:10 +00:00
Masayuki Igawa ac8fb7ca90 Fix typo and change regexp to regex
This commit fixes some typos and changes 'regexp' to 'regex'. I think
'regexp' is also correct. However, in ostestr, they are mixed. So users
may be confused with it. So let's fix it.

Change-Id: I6c9042527707315f5dbb56f4a406327668c57d04
2016-12-02 17:18:08 +09:00
melanie witt b296846535 Track failures during sorting of test results
The current logic only considers the first occurrence of a test class
and doesn't update a class's pass/fail status after that. So a test
class, for example:

 TestClass
   test_1 pass
   test_2 fail
   test_3 pass

is counted as a passing test class even though it has a failure.

This adds failure tracking to the test result sorting so that any
failure in a test class will make it considered a failing test class
and be sorted at the top of the HTML result page.

Closes-Bug: #1640889

Change-Id: I06919336a09c4afda8ec3a9e7d64d305fbd169c3
2016-11-10 18:24:09 +00:00
Matthew Treinish 3acc96e47a
Handle overlapping black regexes
It's very common for blacklist files and/or a black regex to have
overlapping matches. In this case ostestr was incorrectly trying to
remove tests from the set of test cases more than once. This commit
fixes this case by simply adding a check if the test is in the set
before trying to delete it. If it's not there, then something else
already removed it from the set of tests we'll be running so we can
just move on.

Change-Id: I1dabf9fb9c182af3dd6e124e79e54e1eb99bed82
2016-09-27 15:28:21 -04:00
Jenkins 158b2506b7 Merge "Make subprocess outputs to text for Python 3" 2016-09-27 18:53:27 +00:00
Jenkins 91e4c776fe Merge "Add ostestr as a function" 2016-09-21 12:59:50 +00:00
Jenkins a0be39dede Merge "Error on invalid list parameter combination" 2016-09-21 12:59:13 +00:00
Attila Fazekas f2187de8e0 Add ostestr as a function
The new entry point is created to allow external python programs,
to call ostestr without using an execve(2), and get the same
functionalty as using it form command line.

ostestr expected to work if it called multiple times in a
sequence. Parallel usage is not considered, but is similary safe as
the underlaying test(r) commands.

The explicit exit calls get replaced by returns.

Change-Id: I8efa495347a6956ef0a188063e6f474a4bbe8101
2016-09-21 14:05:45 +02:00
Attila Fazekas 16416b2eef Error on invalid list parameter combination
pdb and no_discover cannot be combined with black or white lists,
it was documented, but not checked.

Change-Id: I7168aef00505cb94051e2e587381efba9fd3e445
2016-09-21 13:59:34 +02:00
Attila Fazekas 359224b4b0 Use dash instead of underscore in args
--whitelist_file, --blacklist_file is an unusual argument,
because of the underscore usage instead of
--blacklist-file/--blacklist-file .

Adding support for the '-' variant, and documenting only the
the '-' variant in the rst.

Change-Id: I8cc8197719f45bcfc05dc9412a03b9b1fe69e722
2016-09-21 11:57:12 +00:00
Attila Fazekas 113e038869 Add --black-regex/-B option
Adding option for reject regexp,
it works like any entry in the black list file,
so after the basic test selection regexp (including the white list),
the test cases satisfying the black-regexp search condition
 will be removed from the final test list.

Change-Id: Id9fecf4aaa799828ae38b31ff3a4798763edfdd1
2016-09-21 11:57:52 +02:00
Attila Fazekas b39332d760 Allow to specifiy black/white list at the same time
Allow to specify both black list and white list file at
the same time.

Change-Id: Id112c01f6fad0bd568bd9178ee30338b885f1223
2016-09-19 14:31:42 +02:00
Attila Fazekas ea7fb00122 Make the listbuilder the default strategy
The listbuilder is able to support very long white list.

construct_regex is considered as deprecated function,
but external project like tempest still using it at the moment.
os-testr internally does not uses it anymore.

Change-Id: I0748605207eaad3065e18b84eecc9ddc4e47404e
2016-09-19 14:30:22 +02:00
Attila Fazekas a3b403bd4e Construct a list of test cases instead of passing a regexp
The way how we handled the regular expressions had a lot of
limitation.

 - We are not able to pass huge arguments to testr, it makes
   difficult to have long list if accepted and/or rejected test cases,
   but we can pass a path to a file of test cases,
   which can be arbitrary big.
 - How we wanted to handle the backlists before was not worked together
   with the regular selecting regex because it consumed the pattern.
   Now the blacklisting happens in a separated phase after the selecting
   regex search.

This change just allows the new code path to run when both
 a blacklist_file and a selecting regexp specified.

The new way depends on the usual test discovery and just
filters the output of the discovery command,
this strategy can be the default in the future, now I just
wanted to preserve the old behavior as much as possible in
all the other cases.

Change-Id: Ie8e5928e286d0c9076c4eee23319149c9869a6fa
Closes-Bug: #1506215
2016-09-19 14:26:03 +02:00
Luz Cazares 054fb04f66 Save subunit results file when using --no-discover
When using ostestr --no-discover flag. The output subunit
results file is not saved under .testrepository as it is
when using testr run command.

Change-Id: Ied6c5a46661b3b36bf15fd538bc6cac764fddcc8
Closes-Bug: #1597111
2016-08-13 06:46:52 +00:00
Attila Fazekas 083faa0741 Simplify logic in _get_test_list
_get_test_list had the same action for the elif case,
it was replaced by 'or' .

Change-Id: I2be9974beea3ca398d61e58726a63518b15cf3c4
2016-07-27 15:40:15 +02:00
Jenkins e15700f1b9 Merge "Make unexpected success as fail" 2016-07-07 21:14:31 +00:00
Masayuki Igawa 056794cdde Make subprocess outputs to text for Python 3
This commit makes subprocess outputs to str with universal_newlines
option. In Python 3, we need to do it explicitly. Otherwise an error
occurs. This commit also adds a unit test to prevent regression.

Change-Id: I2e428a3c57357e47c9057e8dbbbb51ae4b65e4e6
2016-06-30 16:49:10 +09:00
Masayuki Igawa 10f1d43b07 Make unexpected success as fail
This commit makes unexpected success (uxsuccess) as fail. We already
consider expected fail as success. So this is a consistent change.

Change-Id: Ic8f9f07354dc16bc0daac71f59aa9799c04c27a6
2016-06-17 16:42:21 +09:00
melanie witt f95f1d4448 Sort failed tests at the top on HTML result page
Currently tests are sorted alphabetically by test class name regardless
of the pass/fail status. When troubleshooting failed unit tests in
jenkins jobs with many unit tests (> 11242 in nova), one must scroll
potentially a lot or wait as the page loads to search for the word
'fail' to get to the details of the failed test.

This sorts failed (and error) tests at the top of the HTML page for
easier troubleshooting (sorted failed tests + sorted passed tests).

Change-Id: I0b575e77c4a3e1cc73e60ea48ca5b9bf2e84d76f
2016-05-26 20:38:37 +00:00
Jenkins a04c851f35 Merge "Split functionality out of main" 2016-05-24 19:25:41 +00:00
Matthew Treinish 73bf72c71b
Seperate regex builder logic into a seperate module
The regex building logic is independently useful and will likely start
to be used in other places. This commits splits it out from the ostestr
cli and makes it an independent module that just contains the pieces
necessary for building a selection regex.

Change-Id: Ic8494d0f54357fdafd650b40219e6ad7fd5a65ad
2016-05-23 19:10:16 -04:00
Jenkins a5bd26aaa8 Merge "Fix docs typos" 2016-05-23 23:04:17 +00:00