Stabilize flaky HibernateAdministrationDAOTest OutboxEvent metadata lookup#6326
Open
dkayiwa wants to merge 1 commit into
Open
Stabilize flaky HibernateAdministrationDAOTest OutboxEvent metadata lookup#6326dkayiwa wants to merge 1 commit into
dkayiwa wants to merge 1 commit into
Conversation
…ookup getMaximumPropertyLength(OutboxEvent.class, ...) intermittently failed with "Couldn't find a class in the hibernate configuration named: org.openmrs.event.outbox.OutboxEvent". HibernateAdministrationDAO captures the boot-time Hibernate Metadata once at context creation; when an earlier test in the same fork rebuilds the shared Spring context, the DAO can end up holding a Metadata that omits the annotation-scanned OutboxEvent entity, so the lookup throws. The class passes in isolation and only fails in some full-suite orderings. Force a fresh context for this test class (@DirtiesContext BEFORE_CLASS) so the DAO's Metadata is rebuilt from a full org.openmrs package scan that includes OutboxEvent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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
HibernateAdministrationDAOTest.getMaximumPropertyLength_*fails intermittently in CI with:Root cause
HibernateAdministrationDAOcaptures the boot-time HibernateMetadataonce, insetApplicationContext, fromHibernateSessionFactoryBean.getMetadata().OutboxEventis a@Entitywith no hbm.xml, so it is registered only via thepackagesToScan = org.openmrsannotation scan. When an earlier test in the same fork rebuilds the shared Spring context, the DAO can end up holding aMetadatathat omitsOutboxEvent, andmetadata.getEntityBinding(...)returns null. The class passes in isolation and only fails in some full-suite orderings, i.e. order-dependent context pollution, not a code regression.Fix
Force a fresh context for this test class with
@DirtiesContext(classMode = BEFORE_CLASS), so the DAO'sMetadatais rebuilt from a fullorg.openmrsscan that includesOutboxEvent.Verification and caveat
The class passes in isolation (6/6) both before and after the change, confirming a fresh context has
OutboxEventand that the annotation is honored (the base test's@TestExecutionListenersuseMERGE_WITH_DEFAULTS, so theDirtiesContextlisteners are registered). I could not reproduce the order-dependent failure locally to prove elimination against a live repro, so this is a mechanism-sound, verified-non-breaking mitigation rather than a repro-verified one.Scope
Only the 2.9.x line has these
getMaximumPropertyLength/OutboxEventtests, so this targets 2.9.x directly. master has the DAO method but not these tests; 2.8.x has noOutboxEvent. This is the first use of@DirtiesContextin the repo.