acceptance-test-harness
acceptance-test-harness copied to clipboard
Bugfix add timeout to core.FreestyleJobTest#discardBuilds
- [x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
- [x] Ensure that the pull request title represents the desired changelog entry
- [x] Please describe what you did
- [x] Link to relevant issues in GitHub or Jira
- [x] Link to relevant pull requests, esp. upstream and downstream changes
- [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue
FreestyleJobTest#discardBuilds
is flaky because of org.jenkinsci.test.acceptance.po.Build#waitUntilFinished()
is not waiting for the build to be actually finished but completed. This is related to https://github.com/jenkinsci/jenkins/pull/6829 and JENKINS-68981 as there is currently no (easy/reliable) way to wait for a build to be finished.
The problem is that org.jenkinsci.test.acceptance.po.Build#waitUntilFinished()
exits before logRotate -> LogRotator#perform gets called, leading to a race condition
If assertThat(b2, pageObjectDoesNotExist());
is called before LogRotator#perform
then the test fails with this stacktrace
java.lang.AssertionError: Expected: Page object exists
but: http://mvn:64648/job/bald_ski/2/ does exist
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
at core.FreestyleJobTest.discardBuilds(FreestyleJobTest.java:200)
Running the ATH with INTERACTIVE=true
, shows that the build is removed as expected.
The workaround add a timeout to mitigate the race condition.