Re: [PR] HBASE-30039 Upgrade hbase-server to use junit5 Part3 [hbase]
liuxiaocs7 merged PR #8090: URL: https://github.com/apache/hbase/pull/8090 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] HBASE-30039 Upgrade hbase-server to use junit5 Part3 [hbase]
liuxiaocs7 merged PR #8086: URL: https://github.com/apache/hbase/pull/8086 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] HBASE-30039 Upgrade hbase-server to use junit5 Part3 [hbase]
liuxiaocs7 merged PR #7999: URL: https://github.com/apache/hbase/pull/7999 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] HBASE-30039 Upgrade hbase-server to use junit5 Part3 [hbase]
liuxiaocs7 commented on PR #7999: URL: https://github.com/apache/hbase/pull/7999#issuecomment-4162494212 I have checked before and after the patch, we have the same ut ``` 8897 before 8897 after ``` The diff are only params UT Diff details ### before only ```text org.apache.hadoop.hbase.io.hfile.bucket.TestPrefetchPersistence#testPrefetchPersistence[0: blockSize=16,384, bucketSizes=[I@5be067de] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testBucketCacheRecovery[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testCompletelyFilledChunks[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testModifiedBucketCacheFileData[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testModifiedBucketCacheFileTime[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testPartiallyFilledChunks[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testRetrieveFromFile[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testRetrieveFromFileAfterDelete[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.io.hfile.bucket.TestVerifyBucketCacheFile#testSingleChunk[1: blockSize=16,384, bucketSizes=[I@7a560583] org.apache.hadoop.hbase.quotas.TestLowLatencySpaceQuotas#testBulkLoading org.apache.hadoop.hbase.quotas.TestMasterQuotasObserver#testNamespaceRPCQuotaRemoved org.apache.hadoop.hbase.quotas.TestMasterQuotasObserver#testNamespaceSpaceAndRPCQuotaRemoved org.apache.hadoop.hbase.quotas.TestMasterQuotasObserver#testNamespaceSpaceQuotaRemoved org.apache.hadoop.hbase.quotas.TestMasterQuotasObserver#testTableRPCQuotaRemoved org.apache.hadoop.hbase.quotas.TestMasterQuotasObserver#testTableSpaceAndRPCQuotaRemoved org.apache.hadoop.hbase.quotas.TestMasterQuotasObserver#testTableSpaceQuotaRemoved org.apache.hadoop.hbase.quotas.TestQuotaObserverChoreWithMiniCluster#testNamespaceViolatesQuota org.apache.hadoop.hbase.quotas.TestQuotaObserverChoreWithMiniCluster#testTableQuotaOverridesNamespaceQuota org.apache.hadoop.hbase.quotas.TestQuotaState#testQuotaStateUpdateTableThrottle org.apache.hadoop.hbase.quotas.TestQuotaState#testSimpleQuotaStateOperation org.apache.hadoop.hbase.quotas.TestQuotaTableUtil#testDeleteSnapshots org.apache.hadoop.hbase.quotas.TestQuotaTableUtil#testSerDeViolationPolicies org.apache.hadoop.hbase.quotas.TestQuotaTableUtil#testTableQuotaUtil org.apache.hadoop.hbase.quotas.TestQuotaTableUtil#testUserQuotaUtil org.apache.hadoop.hbase.quotas.TestRegionSizeUse#testBasicRegionSizeReports org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[0: caKeyType=RSA, certKeyType=RSA, keyPassword=[C@7ea9e1e2] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[1: caKeyType=RSA, certKeyType=RSA, keyPassword=[C@1e683a3e] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[2: caKeyType=RSA, certKeyType=EC, keyPassword=[C@2053d869] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[3: caKeyType=RSA, certKeyType=EC, keyPassword=[C@7a419da4] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[4: caKeyType=EC, certKeyType=RSA, keyPassword=[C@14555e0a] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[5: caKeyType=EC, certKeyType=RSA, keyPassword=[C@4bb33f74] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[6: caKeyType=EC, certKeyType=EC, keyPassword=[C@759d26fb] org.apache.hadoop.hbase.security.TestNettyTlsIPCRejectPlainText#testReject[7: caKeyType=EC, certKeyType=EC, keyPassword=[C@3c73951] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[0: caKeyType=RSA, certKeyType=RSA, keyPassword=[C@759d26fb] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[1: caKeyType=RSA, certKeyType=RSA, keyPassword=[C@4d5b6aac] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[2: caKeyType=RSA, certKeyType=EC, keyPassword=[C@3e84448c] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[3: caKeyType=RSA, certKeyType=EC, keyPassword=[C@4a7f959b] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[4: caKeyType=EC, certKeyType=RSA, keyPassword=[C@429bffaa] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[5: caKeyType=EC, certKeyType=RSA, keyPassword=[C@5403f35f] org.apache.hadoop.hbase.security.TestSaslTlsIPCRejectPlainText#testReject[6: caKeyType=EC,
Re: [PR] HBASE-30039 Upgrade hbase-server to use junit5 Part3 [hbase]
Copilot commented on code in PR #7999:
URL: https://github.com/apache/hbase/pull/7999#discussion_r3005146571
##
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSuperUserQuotaPermissions.java:
##
@@ -96,16 +87,17 @@ public static void setupMiniCluster() throws Exception {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
if (helper == null) {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL,
+() -> testInfo.getTestMethod().get().getName(), COUNTER);
}
Review Comment:
`SpaceQuotaHelperForTests` is only initialized once (when `helper == null`),
but the `Supplier` 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`).
##
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaObserverChoreWithMiniCluster.java:
##
@@ -92,16 +82,17 @@ public static void setUp() throws Exception {
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
final Connection conn = TEST_UTIL.getConnection();
if (helper == null) {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER);
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL,
+() -> testInfo.getTestMethod().get().getName(), COUNTER);
}
Review Comment:
`helper` is cached after the first test run, but the `Supplier` 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.
##
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestMasterQuotasObserver.java:
##
@@ -38,47 +37,39 @@
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
/**
* Test class for {@link MasterQuotasObserver}.
*/
-@Category(MediumTests.class)
+@Tag(MediumTests.TAG)
public class TestMasterQuotasObserver {
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
-HBaseClassTestRule.forClass(TestMasterQuotasObserver.class);
-
private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static SpaceQuotaHelperForTests helper;
- @Rule
- public TestName testName = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
conf.setBoolean(QuotaUtil.QUOTA_CONF_KEY, true);
TEST_UTIL.startMiniCluster(1);
}
- @AfterClass
+ @AfterAll
public static void tearDown() throws Exception {
TEST_UTIL.shutdownMiniCluster();
}
- @Before
- public void removeAllQuotas() throws Exception {
+ @BeforeEach
+ public void removeAllQuotas(TestInfo testInfo) throws Exception {
if (helper == null) {
- helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new
AtomicLong());
+ helper = new SpaceQuotaHelperForTests(TEST_UTIL,
+() -> testInfo.getTestMethod().get().getName(), new AtomicLong());
}
Review 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
