Skip to content

Commit 8801934

Browse files
committed
test: assert both ehcache.xml heap-bound paths, not just the template
HibernateEhcacheConfigFileTest arrived on master with #24762 and pinned the User region to the ehcache.xml default template bound of 1,000,000. This branch declares User explicitly so it can be sized and stored by reference, so that region now carries 100,000 and the assertion failed. The test's stated intent is that regions carry ehcache.xml's settings, bounded rather than the unbounded provider defaults. That still holds; only the specific number changed, and only for regions we now declare explicitly. Assert both paths instead of one: Attribute has no explicit <cache> element and must still inherit the default template, while User is declared and must carry its own bound. That covers strictly more than before. AI Assisted
1 parent 960a2c7 commit 8801934

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/cache/HibernateEhcacheConfigFileTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.hibernate.cache.jcache.internal.JCacheRegionFactory;
4747
import org.hibernate.cache.spi.RegionFactory;
4848
import org.hibernate.engine.spi.SessionFactoryImplementor;
49+
import org.hisp.dhis.attribute.Attribute;
4950
import org.hisp.dhis.cache.HibernateEhcacheConfigFileTest.DhisConfig;
5051
import org.hisp.dhis.external.conf.ConfigurationKey;
5152
import org.hisp.dhis.test.config.PostgresTestConfigOverride;
@@ -86,6 +87,13 @@ public PostgresTestConfigOverride postgresTestConfigOverride() {
8687
/** Heap bound from the ehcache.xml default cache template (jsr107:defaults). */
8788
private static final long EHCACHE_XML_TEMPLATE_HEAP_ENTRIES = 1_000_000;
8889

90+
/**
91+
* Heap bound declared explicitly for the predefined {@code org.hisp.dhis.user.User} region in
92+
* ehcache.xml. Hot regions are declared individually so they can be sized and stored by
93+
* reference; the rest still inherit the default template above.
94+
*/
95+
private static final long EHCACHE_XML_USER_HEAP_ENTRIES = 100_000;
96+
8997
@Autowired private EntityManagerFactory entityManagerFactory;
9098

9199
@Test
@@ -105,10 +113,17 @@ void cacheManagerIsConfiguredFromEhcacheXml() {
105113
void regionsCarryTheEhcacheXmlHeapBounds() {
106114
CacheManager cacheManager = cacheManager();
107115

116+
// Attribute has no explicit <cache> element, so it must inherit the default template.
108117
assertEquals(
109118
EHCACHE_XML_TEMPLATE_HEAP_ENTRIES,
119+
heapEntries(cacheManager, Attribute.class.getName()),
120+
"entity regions without an explicit declaration must carry the heap bound of the"
121+
+ " ehcache.xml default template");
122+
// User is declared explicitly in ehcache.xml and must carry its own bound, not the template's.
123+
assertEquals(
124+
EHCACHE_XML_USER_HEAP_ENTRIES,
110125
heapEntries(cacheManager, User.class.getName()),
111-
"entity regions must carry the heap bound of the ehcache.xml default template");
126+
"explicitly declared entity regions must carry their own ehcache.xml heap bound");
112127
assertEquals(
113128
EHCACHE_XML_TIMESTAMPS_HEAP_ENTRIES,
114129
heapEntries(cacheManager, "default-update-timestamps-region"),

0 commit comments

Comments
 (0)