Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added suspendForMs to @RetryingTest #604

Merged

Conversation

mathieufortin01
Copy link
Contributor

fixes #407
Simple implementation just to get the discussion going.

  • Added suspendForMs param to @RetryingTest
  • Added a few tests. These are based on timing, so theres a risk of flakiness.

Proposed commit message:

${action} (${issues} / ${pull-request}) [max 70 characters]

${body} [max 70 characters per line]

${references}: ${issues}
PR: ${pull-request}

PR checklist

The following checklist shall help the PR's author, the reviewers and maintainers to ensure the quality of this project.
It is based on our contributors guidelines, especially the "writing code" section.
It shall help to check for completion of the listed points.
If a point does not apply to the given PR's changes, the corresponding entry can be simply marked as done.

Documentation (general)

  • There is documentation (Javadoc and site documentation; added or updated)
  • There is implementation information to describe why a non-obvious source code / solution got implemented
  • Site documentation has its own .adoc file in the docs folder, e.g. docs/report-entries.adoc
  • Site documentation in .adoc file references demo in src/demo/java instead of containing code blocks as text
  • Only one sentence per line (especially in .adoc files)
  • Javadoc uses formal style, while sites documentation may use informal style

Documentation (new extension)

  • The docs/docs-nav.yml navigation has an entry for the new extension
  • The package-info.java contains information about the new extension

Code

  • Code adheres to code style, naming conventions etc.
  • Successful tests cover all changes
  • There are checks which validate correct / false usage / configuration of a functionality and there are tests to verify those checks
  • Tests use AssertJ or our own PioneerAssert (which are based on AssertJ)

Contributing

  • A prepared commit message exists
  • The list of contributions inside README.md mentions the new contribution (real name optional)

I hereby agree to the terms of the JUnit Pioneer Contributor License Agreement.

@@ -167,6 +192,9 @@ public RetryingTestInvocationContext next() {
if (!hasNext())
throw new NoSuchElementException();
retriesSoFar++;

suspendFor(suspendForMs);

Choose a reason for hiding this comment

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

you should not wait, if this is the first execution of the test

Copy link
Member

@nipafx nipafx left a comment

Choose a reason for hiding this comment

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

@mathieufortin01, thank you for the PR, I really appreciate it! If you've observed the project a bit, you know we occasionally take some time, but we're on it now.

Can you merge main, resolve the conflict and take a look at these comments?

@mathieufortin01
Copy link
Contributor Author

@nipafx Thanks for the review. Addressed all comments. Let me know.

@Michael1993 Michael1993 marked this pull request as ready for review May 24, 2022 17:13
Comment on lines +208 to +210
if (!isFirstExecution()) {
suspendFor(suspendForMs);
}
Copy link
Member

Choose a reason for hiding this comment

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

I like this little refactoring! 👍🏾

@nipafx
Copy link
Member

nipafx commented May 25, 2022

Looks great, thank you @mathieufortin01! I was about to merge when I noticed that you didn't add yourself to the README - we like to list all contributors there to publicly shame thank 😉 them, but this is by no means obligatory if you prefer not to be mentioned. Let me know either way.

@mathieufortin01
Copy link
Contributor Author

@nipafx here you go. let the shame begin.

README.md Outdated Show resolved Hide resolved
@nipafx
Copy link
Member

nipafx commented May 25, 2022

Commit message:

Add option to suspend between retrying tests (#407 / #604)

Retrying tests may be flaky because of issues with external services.
The chance that they recover and behave correctly on the next try may
improve if there's a (short) pause between the test runs. This change
adds an option to suspend for a fixed time span (in milliseconds)
betweet tries.

The implemenation simply lets the executing thread sleep, which
isn't ideal. It would be much better if there were a way to schedule
the next execution for later and use the thread to execute other
tests in between, but Jupiter doesn't offer an API for that.

Closes: #407
PR: #604

@nipafx nipafx merged commit bfb2d02 into junit-pioneer:main May 25, 2022
@nipafx
Copy link
Member

nipafx commented May 25, 2022

Thanks a lot @mathieufortin01, for your contribution and patience! 👏🏾👏🏾👏🏾

Bukama pushed a commit to Bukama/junit-pioneer that referenced this pull request Sep 20, 2022
…it-pioneer#604)

Retrying tests may be flaky because of issues with external services.
The chance that they recover and behave correctly on the next try may
improve if there's a (short) pause between the test runs. This change
adds an option to suspend for a fixed time span (in milliseconds)
betweet tries.

The implemenation simply lets the executing thread sleep, which
isn't ideal. It would be much better if there were a way to schedule
the next execution for later and use the thread to execute other
tests in between, but Jupiter doesn't offer an API for that.

Closes: junit-pioneer#407
PR: junit-pioneer#604
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.

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