Repository navigation
test: narrow the Spring context for tests that don't need the full application - #2113
Conversation
ExtensionVersionJooqRepositoryTest and ExtensionJooqRepositoryTest test ExtensionVersionJooqRepository/ExtensionJooqRepository - plain @component classes that talk to the database directly through jOOQ, not Spring Data JPA repositories. A bare @SpringBootTest still boots the entire RegistryApplication for them regardless, pulling in every auto-configuration the app has: all ~30 Spring Data JPA repository interfaces (each one's derived/@query methods individually parsed and validated against the Hibernate metamodel - the dominant cost of a full context in this project, on the order of a minute, logged between "QueryEnhancerFactories" and the next line with nothing in between), JobRunr's SQL storage provider, the web/MVC layer, security, actuator, and more - none of which either jOOQ repository needs. Added JooqOnlyTestConfig, a @SpringBootTest(classes = ...) root that imports only what these tests actually require: a DataSource, Flyway (to create the schema), Hibernate/JPA (for the EntityManager and transaction management the tests use to set up fixtures), and jOOQ's DSLContext - plus the two repository beans themselves via @import. Both test classes now use it and, since it's the same context, share one cached instance across them. Measured: both test classes together (21 tests, including a cold Postgres container start, Flyway migration, and context bootstrap) now run in 35s, down from over a minute of context startup alone for either one individually. Full suite: 1061/1061 passing, total runtime down from ~9-10 minutes to 8m1s. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR speeds up the server’s jOOQ repository integration tests by replacing full RegistryApplication bootstraps with a narrowly scoped Spring Boot test context that only includes the database, Flyway migrations, JPA/transactions for fixture setup, and jOOQ.
Changes:
- Added
JooqOnlyTestConfigto import a minimal set of auto-configurations and explicitly register the two jOOQ repository beans under test. - Updated
ExtensionVersionJooqRepositoryTestandExtensionJooqRepositoryTestto use the shared minimal context and disable the web environment.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| server/src/test/java/org/eclipse/openvsx/repositories/JooqOnlyTestConfig.java | New minimal Spring Boot test root configuration for jOOQ repository tests. |
| server/src/test/java/org/eclipse/openvsx/repositories/ExtensionVersionJooqRepositoryTest.java | Switched to JooqOnlyTestConfig and WebEnvironment.NONE. |
| server/src/test/java/org/eclipse/openvsx/repositories/ExtensionJooqRepositoryTest.java | Switched to JooqOnlyTestConfig and WebEnvironment.NONE. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Same rationale as the jOOQ repository tests: a bare @SpringBootTest boots the entire RegistryApplication regardless of what a test actually uses, paying for every Spring Data JPA repository (the dominant cost of a full context here), JobRunr, the web layer, and more. - ExtensionScanJobRecoveryServiceTest constructs the service under test by hand from plain Mockito mocks and only touches Spring for a real DataSource (to exercise the actual Postgres advisory lock through real connections) - no JPA or jOOQ involved at all. Narrowed to DataSourceAutoConfiguration alone. - NamespaceRepositoryTest needs exactly one Spring Data JPA repository interface, NamespaceRepository. @EnableJpaRepositories normally scans every repository interface in its base package - which for any repository in this project is the same org.eclipse.openvsx.repositories package all ~30 of them live in - so restricting basePackageClasses alone would not have helped; an explicit includeFilter scopes it to just this one interface. Measured: both together (10 tests, including a cold Postgres container start and two separate context bootstraps) run in 42.5s. Full suite: 1061/1061 passing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Follow-up: two more tests narrowed the same wayChecked the rest of the
Measured: both together (10 tests, including a cold Postgres container start and two separate context bootstraps) run in 42.5s. Full suite: 1061/1061 passing. 🤖 Generated with Claude Code |
Why
ExtensionVersionJooqRepositoryTestandExtensionJooqRepositoryTesttestExtensionVersionJooqRepository/ExtensionJooqRepository— plain@Componentclasses that talk to the database directly through jOOQ, not Spring Data JPA repositories. A bare@SpringBootTeststill boots the entireRegistryApplicationfor them regardless, pulling in every auto-configuration the app has — most notably all ~30 Spring Data JPA repository interfaces, each one's derived/@Querymethods individually parsed and validated against the Hibernate metamodel. That's the dominant cost of a full application context in this project: on the order of a minute, spent entirely between theQueryEnhancerFactorieslog line and whatever comes next, with nothing logged in between. On top of that: JobRunr's SQL storage provider, the full web/MVC layer, security, actuator — none of which either jOOQ repository needs.What
Adds
JooqOnlyTestConfig, a@SpringBootTest(classes = ...)root that imports only what these tests actually require:DataSourceAutoConfiguration— theDataSourceFlywayAutoConfiguration— creates the schemaHibernateJpaAutoConfiguration— theEntityManager/transaction management the tests use to set up fixturesTransactionAutoConfiguration—@Transactionalrollback-per-test supportJooqAutoConfiguration— jOOQ'sDSLContext@Import({ExtensionVersionJooqRepository.class, ExtensionJooqRepository.class})— the two repository beans themselvesBoth test classes switch to it. Since it's the identical context configuration, Spring's test context cache shares one instance across both.
Verification
🤖 Generated with Claude Code