Skip to content

test: migrate extension-core catalog stats and security tests to JUnit 5 - #19877

Merged
FrankChen021 merged 5 commits into
apache:masterfrom
FrankChen021:codex/junit5-migration-ext-core-3
Aug 6, 2026
Merged

test: migrate extension-core catalog stats and security tests to JUnit 5#19877
FrankChen021 merged 5 commits into
apache:masterfrom
FrankChen021:codex/junit5-migration-ext-core-3

Conversation

@FrankChen021

Copy link
Copy Markdown
Member

Part of #13948.

Builds on PR #19876.

Description

This PR migrates the JUnit 4 tests in the third extension-core batch to JUnit 5:

  • druid-catalog
  • stats
  • druid-basic-security

The migration replaces JUnit 4 assertions, lifecycle annotations, rules, expected-exception tests, categories, and Mockito runners with Jupiter equivalents. Converted Derby fixtures now preserve the original per-test database lifecycle, and polling tests use synchronization latches instead of timing sleeps.

The direct JUnit 4 test dependencies remain temporarily because shared test-jar utilities such as TestDerbyConnector and MockServiceClient still execute JUnit 4 assertions. They can be removed after those shared fixtures are migrated.

Validation

Ran the complete changed-test set for all three modules with Maven: 356 tests passed with zero failures, errors, or flakes.

Related migration PRs

public void authorizerUpdateListenerShouldReturnExpectedResult()
{
Assert.assertNotNull(target.authorizerUpdateListener(req, AUTHORIZER_NAME, SERIALIZED_ROLE_MAP));
Assertions.assertNotNull(target.authorizerUpdateListener(req, AUTHORIZER_NAME, SERIALIZED_ROLE_MAP));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. The deprecated BasicAuthorizerResource.authorizerUpdateListener call is already present on master; this PR only changes the surrounding JUnit assertions and exception handling. I’m leaving the existing API-deprecation cleanup out of this JUnit migration and will track it separately.

{
target.authorizerUpdateListener(req, INVALID_AUTHORIZER_NAME, SERIALIZED_ROLE_MAP);
assertThrows(IllegalArgumentException.class, () ->
target.authorizerUpdateListener(req, INVALID_AUTHORIZER_NAME, SERIALIZED_ROLE_MAP));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. The deprecated BasicAuthorizerResource.authorizerUpdateListener call is already present on master; this PR only changes the surrounding JUnit assertions and exception handling. I’m leaving the existing API-deprecation cleanup out of this JUnit migration and will track it separately.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the code for correctness, edge cases, concurrency, and integration risks; no issues found.

Reviewed 46 of 46 changed files.


This is an automated review by Codex GPT-5.6-Sol

@FrankChen021
FrankChen021 marked this pull request as ready for review August 5, 2026 01:55
Copilot AI lite review requested due to automatic review settings August 5, 2026 01:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues Druid’s extension-core JUnit 4 → JUnit 5 migration (part of #13948), updating tests in druid-catalog, stats, and druid-basic-security to run on Jupiter and modernizing related test utilities and dependencies.

Changes:

  • Migrated JUnit 4 annotations/assertions/runners/rules to JUnit 5 equivalents across the three extensions.
  • Introduced JUnit 5-friendly Derby connector extensions for catalog and basic-security tests.
  • Updated module POMs to use Jupiter/Mockito-Jupiter and cleaned up now-unneeded JUnit migration/vintage dependencies where applicable.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceTopNQueryTest.java Converted parameterized TopN variance test to Jupiter parameterization.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceTimeseriesQueryTest.java Converted parameterized timeseries variance tests to Jupiter parameterization.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceSerdeTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceObjectVectorAggregatorTest.java Switched Mockito runner to MockitoExtension and Jupiter lifecycle/assertions.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceLongVectorAggregatorTest.java Switched Mockito runner to MockitoExtension and Jupiter lifecycle/assertions.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceFloatVectorAggregatorTest.java Switched Mockito runner to MockitoExtension and Jupiter lifecycle/assertions.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceDoubleVectorAggregatorTest.java Switched Mockito runner to MockitoExtension and Jupiter lifecycle/assertions.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceGroupByQueryTest.java Converted parameterized groupBy variance tests to Jupiter parameterization.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorTest.java Migrated lifecycle and assertions to JUnit Jupiter.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactoryUnitTest.java Migrated Mockito runner/expected-exception patterns to MockitoExtension + assertThrows.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorFactoryTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorCollectorTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/StandardDeviationPostAggregatorTest.java Migrated Mockito runner + assertions to Jupiter/MockitoExtension.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/teststats/ZtestPostAggregatorTest.java Migrated lifecycle/assertions to JUnit Jupiter.
extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/teststats/PvaluefromZscorePostAggregatorTest.java Migrated ExpectedException rule usage to Jupiter assertions.
extensions-core/stats/pom.xml Dropped vintage/migrationsupport deps and added Mockito-Jupiter + hamcrest for tests.
extensions-core/druid-catalog/src/test/java/org/apache/druid/server/http/catalog/EditorTest.java Migrated to Jupiter and switched Derby rule to JUnit 5 extension.
extensions-core/druid-catalog/src/test/java/org/apache/druid/server/http/catalog/CatalogResourceTest.java Migrated to Jupiter and switched Derby rule to JUnit 5 extension.
extensions-core/druid-catalog/src/test/java/org/apache/druid/metadata/JUnit5TestDerbyConnector.java Added JUnit 5 extension wrapper around existing DerbyConnectorRule.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sync/CatalogSyncTest.java Migrated to Jupiter and switched Derby rule to JUnit 5 extension.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sync/CatalogCacheTest.java Migrated to Jupiter and switched Derby rule to JUnit 5 extension.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sync/CacheNotifierTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/storage/TableManagerTest.java Migrated to Jupiter; replaced Category with Tag; switched Derby rule to JUnit 5 extension.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sql/LiveCatalogTest.java Migrated to Jupiter and switched Derby rule to JUnit 5 extension.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sql/CatalogReplaceTest.java Migrated fail/assert imports to Jupiter.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sql/CatalogQueryTest.java Migrated fail/assert imports to Jupiter.
extensions-core/druid-catalog/src/test/java/org/apache/druid/catalog/sql/CatalogInsertTest.java Migrated fail/assert imports to Jupiter.
extensions-core/druid-catalog/pom.xml Dropped vintage/migrationsupport deps while retaining transitional JUnit4 dep for shared helpers.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/BasicAuthUtilsTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authorization/endpoint/BasicAuthorizerResourceTest.java Migrated Mockito runner + expected-exception patterns to MockitoExtension + assertThrows.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authorization/db/cache/CoordinatorPollingBasicAuthorizerCacheManagerTest.java Replaced sleeps with latches; migrated TemporaryFolder to @TempDir; Jupiter assertions.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authentication/validator/PasswordHashGeneratorTest.java Migrated timeout and assertions to JUnit Jupiter (@Timeout).
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authentication/validator/MetadataStoreCredentialsValidatorTest.java Migrated assertions/assertThrows usage to Jupiter.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authentication/LdapUserPrincipalTest.java Migrated off JUnit3 TestCase; added JUnit5 @Test methods.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authentication/endpoint/BasicAuthenticatorResourceTest.java Migrated Mockito runner + expected-exception patterns to MockitoExtension + assertThrows.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authentication/db/cache/CoordinatorPollingBasicAuthenticatorCacheManagerTest.java Replaced sleeps with latches; migrated TemporaryFolder to @TempDir; Jupiter assertions.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authorization/ReadOnlyAuthorizerTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authorization/CoordinatorBasicAuthorizerResourceTest.java Migrated to Jupiter/MockitoExtension and switched Derby rule to JUnit 5 extension.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authorization/CoordinatorBasicAuthorizerMetadataStorageUpdaterTest.java Migrated ExpectedException rules to Jupiter assertThrows; switched Derby rule to JUnit 5 extension.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authorization/BasicRoleBasedAuthorizerTest.java Migrated lifecycle/assertions to Jupiter and switched Derby rule to JUnit 5 extension.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/validator/LDAPCredentialsValidatorTest.java Migrated assertions/imports to JUnit Jupiter.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/CoordinatorBasicAuthenticatorResourceTest.java Migrated to Jupiter/MockitoExtension and switched Derby rule to JUnit 5 extension.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/CoordinatorBasicAuthenticatorMetadataStorageUpdaterTest.java Migrated ExpectedException rules to Jupiter assertThrows; switched Derby rule to JUnit 5 extension.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/authentication/BasicHTTPAuthenticatorTest.java Migrated @Test import to JUnit Jupiter.
extensions-core/druid-basic-security/src/test/java/org/apache/druid/metadata/JUnit5TestDerbyConnector.java Added JUnit 5 extension wrapper around existing DerbyConnectorRule.
extensions-core/druid-basic-security/pom.xml Added Jupiter API/engine + Mockito-Jupiter and retained transitional JUnit4 dep for shared helpers.
Suppressed comments (1)

extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceTimeseriesQueryTest.java:138

  • After removing the unused runner/aggregatorFactories parameters from initVarianceTimeseriesQueryTest, this call should pass only the values actually used to initialize the test state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public void testGroupByVarianceOnly()
{
final QueryRunner<ResultRow> mergedRunner =
factory.mergeRunners(Execs.directExecutor(), ImmutableList.of(runner));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a baseline/intentional use. The corresponding QueryRunnerFactory.mergeRunners call already existed in offical/master inside the old parameterized constructor; the JUnit 5 migration moved equivalent setup into each parameterized test. I verified the master version before this follow-up. I am leaving the deprecated API unchanged because no safe, narrowly scoped replacement was established and changing it would expand this migration cleanup. The test behavior is preserved. Validation after the related parameter cleanup: 264 focused variance tests passed; Checkstyle reported 0 violations and SpotBugs reported 0 bugs/errors.

@MethodSource("constructorFeeder")
@ParameterizedTest(name = "{0}")
public void testGroupBy(
String testName,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional rather than an unused parameter. JUnit 5 uses @ParameterizedTest(name = "{0}") to consume the first argument as the per-configuration display name. Removing testName would break that display-name mapping, so it is retained. This finding is a false positive.

)
{
final QueryRunner<ResultRow> mergedRunner =
factory.mergeRunners(Execs.directExecutor(), ImmutableList.of(runner));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a baseline/intentional use. The corresponding QueryRunnerFactory.mergeRunners call already existed in offical/master inside the old parameterized constructor; the JUnit 5 migration moved equivalent setup into each parameterized test. I verified the master version before this follow-up. I am leaving the deprecated API unchanged because no safe, narrowly scoped replacement was established and changing it would expand this migration cleanup. The test behavior is preserved. Validation after the related parameter cleanup: 264 focused variance tests passed; Checkstyle reported 0 violations and SpotBugs reported 0 bugs/errors.

@MethodSource("constructorFeeder")
@ParameterizedTest(name = "{0}")
public void testPostAggHavingSpec(
String testName,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional rather than an unused parameter. JUnit 5 uses @ParameterizedTest(name = "{0}") to consume the first argument as the per-configuration display name. Removing testName would break that display-name mapping, so it is retained. This finding is a false positive.

)
{
final QueryRunner<ResultRow> mergedRunner =
factory.mergeRunners(Execs.directExecutor(), ImmutableList.of(runner));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a baseline/intentional use. The corresponding QueryRunnerFactory.mergeRunners call already existed in offical/master inside the old parameterized constructor; the JUnit 5 migration moved equivalent setup into each parameterized test. I verified the master version before this follow-up. I am leaving the deprecated API unchanged because no safe, narrowly scoped replacement was established and changing it would expand this migration cleanup. The test behavior is preserved. Validation after the related parameter cleanup: 264 focused variance tests passed; Checkstyle reported 0 violations and SpotBugs reported 0 bugs/errors.

)
{
final QueryRunner<ResultRow> mergedRunner =
factory.mergeRunners(Execs.directExecutor(), ImmutableList.of(runner));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a baseline/intentional use. The corresponding QueryRunnerFactory.mergeRunners call already existed in offical/master inside the old parameterized constructor; the JUnit 5 migration moved equivalent setup into each parameterized test. I verified the master version before this follow-up. I am leaving the deprecated API unchanged because no safe, narrowly scoped replacement was established and changing it would expand this migration cleanup. The test behavior is preserved. Validation after the related parameter cleanup: 264 focused variance tests passed; Checkstyle reported 0 violations and SpotBugs reported 0 bugs/errors.

@MethodSource("constructorFeeder")
@ParameterizedTest(name = "{0}")
public void testGroupByTestPvalueZscorePostAgg(
String testName,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional rather than an unused parameter. JUnit 5 uses @ParameterizedTest(name = "{0}") to consume the first argument as the per-configuration display name. Removing testName would break that display-name mapping, so it is retained. This finding is a false positive.

)
{
final QueryRunner<ResultRow> mergedRunner =
factory.mergeRunners(Execs.directExecutor(), ImmutableList.of(runner));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a baseline/intentional use. The corresponding QueryRunnerFactory.mergeRunners call already existed in offical/master inside the old parameterized constructor; the JUnit 5 migration moved equivalent setup into each parameterized test. I verified the master version before this follow-up. I am leaving the deprecated API unchanged because no safe, narrowly scoped replacement was established and changing it would expand this migration cleanup. The test behavior is preserved. Validation after the related parameter cleanup: 264 focused variance tests passed; Checkstyle reported 0 violations and SpotBugs reported 0 bugs/errors.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the updated code for correctness, edge cases, concurrency, and integration risks; no issues found.

Reviewed 46 of 46 changed files. The incremental commits correctly localize parameterized-test state and preserve unique temporary directories.


This is an automated review by Codex GPT-5.6-Sol

@FrankChen021
FrankChen021 merged commit 594b169 into apache:master Aug 6, 2026
44 of 45 checks passed
@FrankChen021
FrankChen021 deleted the codex/junit5-migration-ext-core-3 branch August 6, 2026 12:44
@github-actions github-actions Bot added this to the 39.0.0 milestone Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants