test: fix flaky AuditIntegrationTest await conditions [DHIS2-21858]#24502
Merged
Conversation
The await conditions used countAudits(query) >= 0 which is vacuously true, so the tests never actually waited for the async Artemis audit consumer and raced it instead (expected 1 audit but was 0). testSaveRoute additionally reused the shared BASE_UID for every AuthScheme parameter run. Audit rows are written outside the test transaction and are not rolled back, so a late audit from a previous run leaked into the next run's query (expected 1 but was 2). Await >= 1 and use a unique UID per parameterized run. AI Assisted
This was referenced Jul 19, 2026
|
jbee
approved these changes
Jul 20, 2026
david-mackessy
approved these changes
Jul 21, 2026
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.



Problem
AuditIntegrationTestregularly fails PR CI, e.g.testSaveRoute(AuthScheme)[3]expected 1 audit but was 0,[4]expected 1 but was 2 (example run).Two bugs:
countAudits(query) >= 0, which is vacuously true - the tests never waited for the async Artemis audit consumer and raced it (was 0).testSaveRoutereused the sharedBASE_UIDfor everyAuthSchemeparameter run. Audit rows are written outside the test transaction and not rolled back, so a late audit from a previous run leaked into the next run's query (was 2).Fix
Await
countAudits(query) >= 1and use a uniqueCodeGenerator.generateUid()per parameterized run.Verification
mvn test -pl dhis-test-integration -Dtest=AuditIntegrationTest(Testcontainers Postgres): 10/10 pass.AI Assisted