Skip to content

Rerun flaky tests that fail in setup - #148

Merged
Jeff-Meadows merged 2 commits into
box:masterfrom
JonathanRRogers:flaky_setup
Jul 8, 2020
Merged

Jeff-Meadows merged 2 commits into
box:masterfrom
JonathanRRogers:flaky_setup

Conversation

@JonathanRRogers

Copy link
Copy Markdown
Contributor

This causes tests that fail in setup to also be considered for re-running as requested in #135

@boxcla

boxcla commented Jan 22, 2019

Copy link
Copy Markdown

Hi @JonathanRRogers, thanks for the pull request. Before we can merge it, we need you to sign our Contributor License Agreement. You can do so electronically here: http://opensource.box.com/cla

Once you have signed, just add a comment to this pull request saying, "CLA signed". Thanks!

@JonathanRRogers

Copy link
Copy Markdown
Contributor Author

CLA signed

@boxcla

boxcla commented Jan 22, 2019

Copy link
Copy Markdown

Verified that @JonathanRRogers has just signed the CLA. Thanks, and we look forward to your contribution.

@danchownow

Copy link
Copy Markdown

@boxcla Any chance of getting this merged in? Would be very helpful for our tests.

@prakashpp

Copy link
Copy Markdown

Guys, can we get this merged?

@Jeff-Meadows

Copy link
Copy Markdown
Contributor

This PR breaks some of flaky's functionality, so it can't be merged as is.

Flaky currently keeps track of how many times a test has passed, and this PR erroneously inflates that number (it counts test setup and test run separately).

Will welcome an update that fixes this problem.

@JonathanRRogers

Copy link
Copy Markdown
Contributor Author

So, after more than a year of no feedback from any person at Box, there was finally a comment requesting a change. Before I did anything else, the fact that I already signed the CLA was inexplicably forgotten. I'm starting to wonder if Box really welcomes contributions.

@Jeff-Meadows

Copy link
Copy Markdown
Contributor

Fair points. It seems the new CLA assistant forgot I signed it, too =/

Apologies for the lack of feedback until now.

@CLAassistant

CLAassistant commented Mar 3, 2020 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@twsheehan

Copy link
Copy Markdown

@JonathanRRogers would you mind resigning and merging? Thanks!

@JonathanRRogers
JonathanRRogers deleted the flaky_setup branch July 2, 2020 22:26
@JonathanRRogers
JonathanRRogers restored the flaky_setup branch July 2, 2020 22:27
@JonathanRRogers

Copy link
Copy Markdown
Contributor Author

Sorry about the delay. I think everything's in order now.

# Start flaky modifications
# only retry on call, not setup or teardown
if report.when == self._PYTEST_WHEN_CALL:
if report.when in self._PYTEST_WHENS:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this new condition should only apply to the failure case (not the success case).

So maybe we can rewrite the following few lines like this:

if report.when == self._PYTEST_WHEN_CALL and report.outcome == self._PYTEST_OUTCOME_PASSED:
    if self._should_handle_test_success(item):
        log = False
elif report.when in self._PYTEST_WHENS and report.outcome == self._PYTEST_OUTCOME_FAILED:
    err, name = self._get_test_name_and_err(item, when)
    if self._will_handle_test_error_or_failure(item, name, err):
        log = False

I think that should still allow rerunning tests that fail in setup, and it won't erroneously count every test success as having passed twice.

@JonathanRRogers JonathanRRogers Jul 7, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you mean about counting every test success as having passed twice. Here's output from running one test in which the setup failed once, then passed:

`
[sscadmin@57a98df50c92 ~]$ pytest -v ~/test_a.py
========================================================================== test session starts ===========================================================================
platform linux2 -- Python 2.7.17, pytest-4.6.11, py-1.9.0, pluggy-0.13.1 -- /home/sscadmin/.local/share/virtualenvs/flaky/bin/python2.7
cachedir: .pytest_cache
rootdir: /home/sscadmin
plugins: cov-2.10.0, forked-1.2.0, xdist-1.32.0, flaky-3.6.1
collected 1 item

test_a.py::test_foo PASSED [100%]
===Flaky Test Report===

test_foo failed (2 runs remaining out of 3).
<type 'exceptions.AssertionError'>
assert 0.615803923129647 < 0.3

  • where 0.615803923129647 = <built-in method random of Random object at 0x81b6f0>()
  • where <built-in method random of Random object at 0x81b6f0> = random.random
    [<TracebackEntry /home/sscadmin/test_a.py:8>]
    test_foo passed 1 out of the required 1 times. Success!

===End Flaky Test Report===

======================================================================== 1 passed in 0.04 seconds ========================================================================
(
`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right! Sorry about the confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Jeff-Meadows

Copy link
Copy Markdown
Contributor

Sorry about the short delay over the long weekend. I do have one comment that needs to be addressed and then I think we're good to go with this one.

@Jeff-Meadows
Jeff-Meadows merged commit 15ab94c into box:master Jul 8, 2020
@Jeff-Meadows

Copy link
Copy Markdown
Contributor

Released to PyPI as version 3.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants