Test cross contamination in openstack/valiadations-libs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
tripleo |
Fix Released
|
Medium
|
Jiri Podivin |
Bug Description
The existing tests are using shared fakes as return value
of certain mocks.
Unfortunately, while perfectly fine in most cases,
certain methods change values passed in place.
This created a race condition, which caused fluctuation in the reported
coverage of the relevant modules.
The undesirable test behavior only becomes apparent when the tests
are run in a succession and their behavior is analyzed, for example
during the run of the recently implemented 'coverchange' job.
Final statistics of the coverage measurement, obtained for the openstack/
displaying the totals for number of lines, lines without coverage, branches etc.,
display following pattern. Note the third column, indicating number of lines without coverage.
-------
TOTAL 995 105 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 108 340 56 86%
TOTAL 995 108 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 108 340 56 86%
TOTAL 995 105 340 56 86%
-------
Number of lines without coverage oscillates between '108' and '105' depending
on the order in which the tests were run. The culprit being one of the functions
of the 'validations_
Code snip:
~~~~~~~~~~
for host in row['Status_
try:
_name, _status = host.split(',')
except ValueError:
# if ValueError, then host is in unknown state:
_name = host
_status = 'UNKNOWN'
_name = colors.
hosts.
As the data processed are passed from patched object, and the data itself are defined withing the shared 'fakes' module, it emerges with inevitability, that the tested code operates on data previously altered by the tests.
Reviewed: https:/ /review. opendev. org/c/openstack /validations- libs/+/ 799754 /opendev. org/openstack/ validations- libs/commit/ b2a9d713612d8ef 0b4058347fc37b4 a4c6e80ec2
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit b2a9d713612d8ef 0b4058347fc37b4 a4c6e80ec2
Author: Jiri Podivin <email address hidden>
Date: Wed Jul 7 10:24:53 2021 +0200
Test cross contamination prevention
The existing tests were using shared fakes as return value
of certain mocks. Unfortunately, while perfectly fine in most cases,
certain methods change values passed in place.
This created a race condition, which caused fluctuation in the reported
coverage of the relevant modules.
The undesirable test behavior only becomes apparent when the tests
are run in a succession and their behavior is analyzed, for example
during the run of the recently implemented 'coverchange' job.
Final statistics of the coverage measurement, displaying the totals
for number of lines, lines without coverage, branches etc., display
following pattern. Note the third column.
TOTAL 995 105 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 108 340 56 86%
TOTAL 995 108 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 105 340 56 86%
TOTAL 995 108 340 56 86%
TOTAL 995 105 340 56 86%
Number of lines without coverage oscillates between '108' and '105' depending libs.cli. common' module, which edits data passed in place.
on the order in which the tests were run. The culprit being one of the functions
of the 'validations_
As the data processed are passed from patched object, and the data itself are
defined withing the relevant 'fakes' module, it emerges with inevitability,
that the tested code operates on data previously altered by the tests.
Furthermore the 'test_run_ command_ failed_ validation' test was augmented
to place further assertion on the arguments passed.
Closes-Bug: #1935003
Signed-off-by: Jiri Podivin <email address hidden> d503eb882a24824 eaf18d7bd3e
Change-Id: I2210fa1775691d