HBASE-30039 Upgrade hbase-server to use junit5 Part3#7999
HBASE-30039 Upgrade hbase-server to use junit5 Part3#7999liuxiaocs7 wants to merge 1 commit intoapache:masterfrom
Conversation
liuxiaocs7
commented
Mar 28, 2026
- see: HBASE-30039
There was a problem hiding this comment.
Pull request overview
Upgrades a large set of hbase-server quota-related unit/integration tests from JUnit 4 to JUnit 5 (Jupiter), aligning with the ongoing HBASE-30039 migration work.
Changes:
- Replaced JUnit4 annotations/rules (
@Before,@After,@Category,@Rule TestName,@Ignore, expected-exception@Test) with JUnit5 equivalents (@BeforeEach,@AfterEach,@Tag,TestInfo,@Disabled,assertThrows, etc.). - Updated assertion imports/usages to
org.junit.jupiter.api.Assertions(including message-parameter ordering). - Updated
SpaceQuotaHelperForTeststo accept aSupplier<String>for test naming (to replace JUnit4TestName).
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesViolationPolicyEnforcement.java | JUnit5 migration (annotations/tags/assertThrows). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoWritesCompactionsViolationPolicyEnforcement.java | JUnit5 migration (annotations/tags/assertThrows). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestNoInsertsViolationPolicyEnforcement.java | JUnit5 migration (annotations/tags/assertThrows). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestDisableTableViolationPolicyEnforcement.java | JUnit5 migration (annotations/tags/assertThrows). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/policies/TestBulkLoadCheckingViolationPolicyEnforcement.java | JUnit5 migration (annotations/tags/assertThrows). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTablesWithQuotas.java | JUnit5 migration (Assertions + @Tag/@beforeeach). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableSpaceQuotaViolationNotifier.java | JUnit5 migration (setup + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTableQuotaViolationStore.java | JUnit5 migration (Assertions + setup + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSuperUserQuotaPermissions.java | JUnit5 migration (TestInfo + @BeforeAll/@afterall). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithSnapshots.java | JUnit5 migration (TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotasWithRegionReplicas.java | JUnit5 migration (TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaViolationPolicyRefresherChore.java | JUnit5 migration (setup + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaSwitchPolicies.java | JUnit5 migration (TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaRemoval.java | JUnit5 migration (TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnNonExistingTables.java | JUnit5 migration (TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaOnBulkLoad.java | JUnit5 migration (TestInfo + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaIncrease.java | JUnit5 migration (TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaDropTable.java | JUnit5 migration (Assertions + TestInfo + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotaBasicFunctioning.java | JUnit5 migration (TestInfo + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSnapshotQuotaObserverChore.java | JUnit5 migration (TestInfo + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeUse.java | JUnit5 migration (TestInfo injection + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeStoreImpl.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeReportingChore.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionSizeImpl.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRegionServerSpaceQuotaManager.java | JUnit5 migration (setup + @Tag + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestRateLimiter.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaUserOverride.java | JUnit5 migration (@BeforeAll/@afterall + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java | JUnit5 migration (@Disabled/@tag + lifecycle annotations). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java | JUnit5 migration (TestInfo + lifecycle annotations + naming updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaStatusRPCs.java | JUnit5 migration (TestInfo + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaState.java | JUnit5 migration (TestInfo + @Tag + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java | JUnit5 migration (TestInfo + lifecycle annotations + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreRegionReports.java | JUnit5 migration (@BeforeEach/@AfterEach + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChore.java | JUnit5 migration (setup + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache2.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaCache.java | JUnit5 migration (@BeforeEach/@AfterEach + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java | JUnit5 migration (@BeforeAll/@AfterAll/@AfterEach + @Tag + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestNamespaceQuotaViolationStore.java | JUnit5 migration (setup + @Tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserverWithMocks.java | JUnit5 migration (setup + @Tag + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java | JUnit5 migration (TestInfo + lifecycle annotations + table-name generation updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotaManager.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestLowLatencySpaceQuotas.java | JUnit5 migration (TestInfo + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestGlobalQuotaSettingsImpl.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileSystemUtilizationChore.java | JUnit5 migration (@tag + Assertions). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFileArchiverNotifierImpl.java | JUnit5 migration (TestInfo + lifecycle annotations + naming updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestFeedbackAdaptiveRateLimiter.java | JUnit5 migration (@BeforeEach/@AfterEach + @Tag + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultQuota.java | JUnit5 migration (@BeforeEach/@AfterEach + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultOperationQuota.java | JUnit5 migration (@tag + Assertions/assertThrows). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestDefaultAtomicQuota.java | JUnit5 migration (@BeforeAll/@afterall + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestClusterScopeQuotaThrottle.java | JUnit5 migration (@BeforeAll/@AfterAll/@AfterEach + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestBlockBytesScannedQuota.java | JUnit5 migration (@BeforeAll/@AfterAll/@AfterEach + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestAtomicReadQuota.java | JUnit5 migration (@BeforeAll/@afterall + @tag). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestActivePolicyEnforcement.java | JUnit5 migration (setup + @Tag + assertion updates). |
| hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java | Refactor to accept Supplier<String> test name; assertion message ordering updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (helper == null) { | ||
| helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong()); | ||
| helper = new SpaceQuotaHelperForTests(TEST_UTIL, | ||
| () -> testInfo.getTestMethod().get().getName(), new AtomicLong()); | ||
| } |
There was a problem hiding this comment.
helper is static and only initialized once, but the supplied test-name lambda captures the testInfo from the first @BeforeEach invocation. Later tests will still use the first test method name when generating tables/paths, which can cause collisions and incorrect cleanup. Prefer initializing helper per-test, or store the current method name in a mutable field updated each @BeforeEach and pass () -> field to the helper.
| if (helper == null) { | ||
| helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER); | ||
| helper = new SpaceQuotaHelperForTests(TEST_UTIL, | ||
| () -> testInfo.getTestMethod().get().getName(), COUNTER); | ||
| } |
There was a problem hiding this comment.
SpaceQuotaHelperForTests is only initialized once (when helper == null), but the Supplier<String> you pass captures the current testInfo instance. On subsequent tests, the supplier will still return the first test method name, which can cause table/file name collisions and make later tests operate on the wrong resources. Consider either re-initializing helper in every @BeforeEach, or store the current method name in a field updated per-test and pass a supplier that reads that field (e.g., set this.testName = ... then pass () -> this.testName).
| if (helper == null) { | ||
| helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER); | ||
| helper = new SpaceQuotaHelperForTests(TEST_UTIL, | ||
| () -> testInfo.getTestMethod().get().getName(), COUNTER); | ||
| } |
There was a problem hiding this comment.
helper is cached after the first test run, but the Supplier<String> you pass closes over that first testInfo parameter. This means helper will keep generating names based on the first test method for all subsequent tests, which can lead to resource/name collisions and flaky behavior. Recreate helper every @BeforeEach, or update a per-test field (e.g., this.testName) and use a supplier that reads that field.