question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve `@RetryingTest`: offer suspend attribute or similar to configure pauses between reruns

See original GitHub issue

Related to #355

User should be able to specify a “cooldown” period between failed test re-runs. Example:

@RetryingTest(value = 3, suspendForMs = 1000)
void test() {
  Assertions.fail(); // should wait 1 second (1000 ms) between runs
}

Alternatives/additions:

@RetryingTest(value = 3, suspend = 1, suspendUnit = ChronoUnit.SECONDS)
void test() {
  Assertions.fail(); // should wait 1 second (1000 ms) between runs
}

Adding other suspend modes, e.g.: RANDOM, to wait a random amount of time between 0 and suspend.

@RetryingTest(value = 3, suspend = 1000, suspendUnit = ChronoUnit.MILLIS, suspendMode = SuspendMode.RANDOM)
void test() {
  Assertions.fail(); // should wait between 0-1 second (0-1000 ms) between runs
}

Alternative:

@RetryingTest(value = 3, suspendForMs = 1000, suspendForMsFactor = 400)
void test() {
  Assertions.fail(); // should wait 1-1.4 second (1000-1400 ms) between runs
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
slawekjaranowskicommented, May 25, 2021

When test depends on external resource (eg. web service) and project is developed by many developers, run on many ci systems it can happen that test from each environment will retry in the some similar time.

Of course I think about some of IT, system tests - unit test shouldn’t depends on external resources.

0reactions
nipafxcommented, Mar 1, 2022

Hey @mathieufortin01, thanks for offering to contribute. 👍🏾 You can definitely give it a go. I’m not 100% sure what would be the best way to implement this, so I recommend to start with a proof of concept (basic implementation and a few demos/tests to demonstrate) without polish (no documentation, tests don’t need to assert anything if that turns out to be complicated) and open a draft PR with that, so we can take a look.

On your two points:

  • I agree, go with suspendForMs.
  • While reading that I also thought about exponential backoff, shortly before you brought it up. 😆 I think that that would be a natural expansion of this concept. And while implementing randomization and backoff would probably be fairly straightforward once the basics are done, they also require documentation and tests, which would make this change much larger. Let’s go without that for the moment, so we can get a POC and eventually a merged PR reasonably soon and then expand on that in a separate PR.

PS: We’re not always timely with out replies to issues and PRs, so best prepare for that. 😊

Read more comments on GitHub >

github_iconTop Results From Across the Web

Move Rerunner-Jupiter/improve RetryingTest? #355 - GitHub
offer suspend -like attribute to configure pauses between reruns; offer minSuccess -like attribute to configure how often a test has to pass in...
Read more >
Retrying Failing Tests - JUnit Pioneer
The suspendForMs attribute specifies the amount of time to pause between retries, in milliseconds. The thread executing this test is sleeping during that...
Read more >
pytest-rerunfailures - PyPI
pytest plugin to re-run tests to eliminate flaky failures.
Read more >
python retry with tenacity, disable `wait` for unittest
The function uses the tenacity wait -argument to wait some time in between calls. The function together with the @retry -decorator seems to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found