Make JdbcExampleTest robust to reruns and command registration race - #2787
Open
jbonofre wants to merge 1 commit into
Open
Make JdbcExampleTest robust to reruns and command registration race#2787jbonofre wants to merge 1 commit into
jbonofre wants to merge 1 commit into
Conversation
The test hard-coded the booking id (1) and asserted on a shared literal flight code (AF520). The example stores bookings in an AUTO_INCREMENT table shared across runs of the same Karaf instance, so when a transient CommandNotFoundException on booking:remove triggered the whole-method @Retry, the rerun's booking:add got id 2 while id 1's row lingered, making booking:remove 1 + assertContainsNot("AF520") fail deterministically. Use a unique flight code per run and resolve the actual auto-incremented id from the booking:list output instead of assuming 1, so leftover rows no longer disturb the assertions and the retry can genuinely recover.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
org.apache.karaf.itests.examples.JdbcExampleTestrobust so it no longer fails intermittently on CI (observed on thetest (windows-latest)job).Why it was failing
The test hard-coded the booking id (
1) and asserted on a shared literal flight code (AF520):booking:add/list/get/remove) are registered asynchronously as independent SCR components. On the slower Windows runner, the freshly-created shell session hit a registration race andbooking:removethrewCommandNotFoundException.@RetryinKarafTestSupport, which re-runstest(). But the example stores bookings in anAUTO_INCREMENTH2 table that persists across runs of the same Karaf instance, so the rerun'sbooking:addgot id2while id1'sAF520row lingered.booking:remove 1+assertContainsNot("AF520")then failed deterministically — which is the assertion seen in the CI log.The fix
"AF" + System.currentTimeMillis()) so leftover rows from a previous/retried run cannot disturb the assertions.booking:listoutput instead of assuming1, and remove exactly that row.With these changes the test is isolated from leftover data and
@Retrycan genuinely recover from the transient command-registration race.Test-only change.