Skip to content

Commit 6d36008

Browse files
authored
HBASE-29938 Upgrade hbase-it to use junit5 (#7817)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 56c5c9e commit 6d36008

37 files changed

+304
-327
lines changed

hbase-it/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@
196196
<artifactId>junit-jupiter-params</artifactId>
197197
<scope>test</scope>
198198
</dependency>
199-
<dependency>
200-
<groupId>org.junit.vintage</groupId>
201-
<artifactId>junit-vintage-engine</artifactId>
202-
<scope>test</scope>
203-
</dependency>
204199
<dependency>
205200
<groupId>org.hamcrest</groupId>
206201
<artifactId>hamcrest-core</artifactId>

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestAcidGuarantees.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
2929
import org.apache.hadoop.hbase.util.Bytes;
3030
import org.apache.hadoop.util.ToolRunner;
31-
import org.junit.Test;
32-
import org.junit.experimental.categories.Category;
31+
import org.junit.jupiter.api.Tag;
32+
import org.junit.jupiter.api.Test;
3333

3434
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
3535

@@ -45,7 +45,7 @@
4545
* -DnumGetters=2 -DnumScanners=2 -DnumUniqueRows=5
4646
* </pre>
4747
*/
48-
@Category(IntegrationTests.class)
48+
@Tag(IntegrationTests.TAG)
4949
public class IntegrationTestAcidGuarantees extends IntegrationTestBase {
5050
private static final int SERVER_COUNT = 1; // number of slaves for the smallest cluster
5151

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBackupRestore.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
package org.apache.hadoop.hbase;
1919

2020
import static org.apache.hadoop.hbase.IntegrationTestingUtility.createPreSplitLoadTestTable;
21-
import static org.junit.Assert.assertTrue;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2223

2324
import java.io.IOException;
2425
import java.nio.charset.Charset;
@@ -52,11 +53,10 @@
5253
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
5354
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
5455
import org.apache.hadoop.util.ToolRunner;
55-
import org.junit.After;
56-
import org.junit.Assert;
57-
import org.junit.Before;
58-
import org.junit.Test;
59-
import org.junit.experimental.categories.Category;
56+
import org.junit.jupiter.api.AfterEach;
57+
import org.junit.jupiter.api.BeforeEach;
58+
import org.junit.jupiter.api.Tag;
59+
import org.junit.jupiter.api.Test;
6060
import org.slf4j.Logger;
6161
import org.slf4j.LoggerFactory;
6262

@@ -71,7 +71,7 @@
7171
* @see <a href="https://issues.apache.org/jira/browse/HBASE-7912">HBASE-7912</a>
7272
* @see <a href="https://issues.apache.org/jira/browse/HBASE-14123">HBASE-14123</a>
7373
*/
74-
@Category(IntegrationTests.class)
74+
@Tag(IntegrationTests.TAG)
7575
public class IntegrationTestBackupRestore extends IntegrationTestBase {
7676
private static final String CLASS_NAME = IntegrationTestBackupRestore.class.getSimpleName();
7777
protected static final Logger LOG = LoggerFactory.getLogger(IntegrationTestBackupRestore.class);
@@ -135,7 +135,7 @@ public void run() {
135135
}
136136

137137
@Override
138-
@Before
138+
@BeforeEach
139139
public void setUp() throws Exception {
140140
util = new IntegrationTestingUtility();
141141
Configuration conf = util.getConfiguration();
@@ -151,7 +151,7 @@ public void setUp() throws Exception {
151151
LOG.info("Cluster initialized and ready");
152152
}
153153

154-
@After
154+
@AfterEach
155155
public void tearDown() throws IOException {
156156
LOG.info("Cleaning up after test.");
157157
if (util.isDistributedCluster()) {
@@ -330,7 +330,7 @@ private void runTestSingle(TableName table) throws IOException {
330330
restore(createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tablesRestoreIncMultiple, null,
331331
true), client);
332332
Table hTable = conn.getTable(table);
333-
Assert.assertEquals(util.countRows(hTable), rowsInIteration * numIterations);
333+
assertEquals(util.countRows(hTable), rowsInIteration * numIterations);
334334
hTable.close();
335335
LOG.info("{} loop {} finished.", Thread.currentThread().getName(), (count - 1));
336336
}
@@ -343,7 +343,7 @@ private void restoreVerifyTable(Connection conn, BackupAdmin client, TableName t
343343
createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tablesRestoreIncMultiple, null, true),
344344
client);
345345
Table hTable = conn.getTable(table);
346-
Assert.assertEquals(expectedRows, util.countRows(hTable));
346+
assertEquals(expectedRows, util.countRows(hTable));
347347
hTable.close();
348348
}
349349

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import org.apache.hadoop.hbase.chaos.factories.MonkeyFactory;
2828
import org.apache.hadoop.hbase.chaos.monkies.ChaosMonkey;
2929
import org.apache.hadoop.hbase.util.AbstractHBaseTool;
30-
import org.junit.After;
31-
import org.junit.Before;
30+
import org.junit.jupiter.api.AfterEach;
31+
import org.junit.jupiter.api.BeforeEach;
3232
import org.slf4j.Logger;
3333
import org.slf4j.LoggerFactory;
3434

@@ -159,13 +159,13 @@ protected int doWork() throws Exception {
159159
return result;
160160
}
161161

162-
@Before
162+
@BeforeEach
163163
public void setUp() throws Exception {
164164
setUpCluster();
165165
setUpMonkey();
166166
}
167167

168-
@After
168+
@AfterEach
169169
public void cleanUp() throws Exception {
170170
cleanUpMonkey();
171171
cleanUpCluster();

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestDDLMasterFailover.java

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package org.apache.hadoop.hbase;
1919

20+
import static org.junit.jupiter.api.Assertions.assertTrue;
21+
2022
import java.io.IOException;
2123
import java.util.ArrayList;
2224
import java.util.List;
@@ -195,8 +197,8 @@ protected void verifyNamespaces() throws IOException {
195197
// iterating concurrent map
196198
for (String nsName : namespaceMap.keySet()) {
197199
try {
198-
Assert.assertTrue("Namespace: " + nsName + " in namespaceMap does not exist",
199-
admin.getNamespaceDescriptor(nsName) != null);
200+
assertTrue(admin.getNamespaceDescriptor(nsName) != null,
201+
"Namespace: " + nsName + " in namespaceMap does not exist");
200202
} catch (NamespaceNotFoundException nsnfe) {
201203
Assert
202204
.fail("Namespace: " + nsName + " in namespaceMap does not exist: " + nsnfe.getMessage());
@@ -210,12 +212,12 @@ protected void verifyTables() throws IOException {
210212
Admin admin = connection.getAdmin();
211213
// iterating concurrent map
212214
for (TableName tableName : enabledTables.keySet()) {
213-
Assert.assertTrue("Table: " + tableName + " in enabledTables is not enabled",
214-
admin.isTableEnabled(tableName));
215+
assertTrue(admin.isTableEnabled(tableName),
216+
"Table: " + tableName + " in enabledTables is not enabled");
215217
}
216218
for (TableName tableName : disabledTables.keySet()) {
217-
Assert.assertTrue("Table: " + tableName + " in disabledTables is not disabled",
218-
admin.isTableDisabled(tableName));
219+
assertTrue(admin.isTableDisabled(tableName),
220+
"Table: " + tableName + " in disabledTables is not disabled");
219221
}
220222
for (TableName tableName : deletedTables.keySet()) {
221223
Assert.assertFalse("Table: " + tableName + " in deletedTables is not deleted",
@@ -291,7 +293,7 @@ void perform() throws IOException {
291293
LOG.info("Creating namespace:" + nsd);
292294
admin.createNamespace(nsd);
293295
NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(nsd.getName());
294-
Assert.assertTrue("Namespace: " + nsd + " was not created", freshNamespaceDesc != null);
296+
assertTrue(freshNamespaceDesc != null, "Namespace: " + nsd + " was not created");
295297
namespaceMap.put(nsd.getName(), freshNamespaceDesc);
296298
LOG.info("Created namespace:" + freshNamespaceDesc);
297299
} catch (Exception e) {
@@ -333,10 +335,10 @@ void perform() throws IOException {
333335
modifiedNsd.setConfiguration(nsTestConfigKey, nsValueNew);
334336
admin.modifyNamespace(modifiedNsd);
335337
NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(namespaceName);
336-
Assert.assertTrue("Namespace: " + selected + " was not modified",
337-
freshNamespaceDesc.getConfigurationValue(nsTestConfigKey).equals(nsValueNew));
338-
Assert.assertTrue("Namespace: " + namespaceName + " does not exist",
339-
admin.getNamespaceDescriptor(namespaceName) != null);
338+
assertTrue(freshNamespaceDesc.getConfigurationValue(nsTestConfigKey).equals(nsValueNew),
339+
"Namespace: " + selected + " was not modified");
340+
assertTrue(admin.getNamespaceDescriptor(namespaceName) != null,
341+
"Namespace: " + namespaceName + " does not exist");
340342
namespaceMap.put(namespaceName, freshNamespaceDesc);
341343
LOG.info("Modified namespace :" + freshNamespaceDesc);
342344
} catch (Exception e) {
@@ -364,7 +366,7 @@ void perform() throws IOException {
364366
try {
365367
if (admin.getNamespaceDescriptor(namespaceName) != null) {
366368
// the namespace still exists.
367-
Assert.assertTrue("Namespace: " + selected + " was not deleted", false);
369+
assertTrue(false, "Namespace: " + selected + " was not deleted");
368370
} else {
369371
LOG.info("Deleted namespace :" + selected);
370372
}
@@ -415,10 +417,10 @@ void perform() throws IOException {
415417
byte[] endKey = Bytes.toBytes("row-" + Integer.MAX_VALUE);
416418
LOG.info("Creating table:" + td);
417419
admin.createTable(td, startKey, endKey, numRegions);
418-
Assert.assertTrue("Table: " + td + " was not created", admin.tableExists(tableName));
420+
assertTrue(admin.tableExists(tableName), "Table: " + td + " was not created");
419421
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
420-
Assert.assertTrue("After create, Table: " + tableName + " in not enabled",
421-
admin.isTableEnabled(tableName));
422+
assertTrue(admin.isTableEnabled(tableName),
423+
"After create, Table: " + tableName + " in not enabled");
422424
enabledTables.put(tableName, freshTableDesc);
423425
LOG.info("Created table:" + freshTableDesc);
424426
} catch (Exception e) {
@@ -453,11 +455,10 @@ void perform() throws IOException {
453455
TableName tableName = selected.getTableName();
454456
LOG.info("Disabling table :" + selected);
455457
admin.disableTable(tableName);
456-
Assert.assertTrue("Table: " + selected + " was not disabled",
457-
admin.isTableDisabled(tableName));
458+
assertTrue(admin.isTableDisabled(tableName), "Table: " + selected + " was not disabled");
458459
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
459-
Assert.assertTrue("After disable, Table: " + tableName + " is not disabled",
460-
admin.isTableDisabled(tableName));
460+
assertTrue(admin.isTableDisabled(tableName),
461+
"After disable, Table: " + tableName + " is not disabled");
461462
disabledTables.put(tableName, freshTableDesc);
462463
LOG.info("Disabled table :" + freshTableDesc);
463464
} catch (Exception e) {
@@ -501,11 +502,10 @@ void perform() throws IOException {
501502
TableName tableName = selected.getTableName();
502503
LOG.info("Enabling table :" + selected);
503504
admin.enableTable(tableName);
504-
Assert.assertTrue("Table: " + selected + " was not enabled",
505-
admin.isTableEnabled(tableName));
505+
assertTrue(admin.isTableEnabled(tableName), "Table: " + selected + " was not enabled");
506506
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
507-
Assert.assertTrue("After enable, Table: " + tableName + " in not enabled",
508-
admin.isTableEnabled(tableName));
507+
assertTrue(admin.isTableEnabled(tableName),
508+
"After enable, Table: " + tableName + " in not enabled");
509509
enabledTables.put(tableName, freshTableDesc);
510510
LOG.info("Enabled table :" + freshTableDesc);
511511
} catch (Exception e) {
@@ -598,10 +598,10 @@ void perform() throws IOException {
598598
admin.addColumnFamily(tableName, cfd);
599599
// assertion
600600
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
601-
Assert.assertTrue("Column family: " + cfd + " was not added",
602-
freshTableDesc.hasColumnFamily(cfd.getName()));
603-
Assert.assertTrue("After add column family, Table: " + tableName + " is not disabled",
604-
admin.isTableDisabled(tableName));
601+
assertTrue(freshTableDesc.hasColumnFamily(cfd.getName()),
602+
"Column family: " + cfd + " was not added");
603+
assertTrue(admin.isTableDisabled(tableName),
604+
"After add column family, Table: " + tableName + " is not disabled");
605605
disabledTables.put(tableName, freshTableDesc);
606606
LOG.info("Added column family: " + cfd + " to table: " + tableName);
607607
} catch (Exception e) {
@@ -652,9 +652,8 @@ void perform() throws IOException {
652652
freshColumnDesc.getMaxVersions(), versions);
653653
Assert.assertEquals("Column family: " + freshColumnDesc + " was not altered",
654654
freshColumnDesc.getMinVersions(), versions);
655-
Assert.assertTrue(
656-
"After alter versions of column family, Table: " + tableName + " is not disabled",
657-
admin.isTableDisabled(tableName));
655+
assertTrue(admin.isTableDisabled(tableName),
656+
"After alter versions of column family, Table: " + tableName + " is not disabled");
658657
disabledTables.put(tableName, freshTableDesc);
659658
LOG.info("Altered versions of column family: " + columnDesc + " to: " + versions
660659
+ " in table: " + tableName);

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818
package org.apache.hadoop.hbase;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.fail;
22+
2023
import java.io.IOException;
2124
import java.util.ArrayList;
2225
import java.util.List;
@@ -30,9 +33,8 @@
3033
import org.apache.hadoop.hbase.util.Threads;
3134
import org.apache.hadoop.util.StringUtils;
3235
import org.apache.hadoop.util.ToolRunner;
33-
import org.junit.Assert;
34-
import org.junit.Test;
35-
import org.junit.experimental.categories.Category;
36+
import org.junit.jupiter.api.Tag;
37+
import org.junit.jupiter.api.Test;
3638
import org.slf4j.Logger;
3739
import org.slf4j.LoggerFactory;
3840

@@ -43,7 +45,7 @@
4345
* A base class for tests that do something with the cluster while running {@link LoadTestTool} to
4446
* write and verify some data.
4547
*/
46-
@Category(IntegrationTests.class)
48+
@Tag(IntegrationTests.TAG)
4749
public class IntegrationTestIngest extends IntegrationTestBase {
4850
public static final char HIPHEN = '-';
4951
private static final int SERVER_COUNT = 1; // number of slaves for the smallest cluster
@@ -93,7 +95,7 @@ protected int getMinServerCount() {
9395

9496
protected void initTable() throws IOException {
9597
int ret = loadTool.run(getArgsForLoadTestToolInitTable());
96-
Assert.assertEquals("Failed to initialize LoadTestTool", 0, ret);
98+
assertEquals(0, ret, "Failed to initialize LoadTestTool");
9799
}
98100

99101
@Override
@@ -173,15 +175,15 @@ protected void runIngestTest(long defaultRunTime, long keysPerServerPerIter, int
173175
if (0 != ret) {
174176
String errorMsg = "Load failed with error code " + ret;
175177
LOG.error(errorMsg);
176-
Assert.fail(errorMsg);
178+
fail(errorMsg);
177179
}
178180

179181
ret = loadTool.run(getArgsForLoadTestTool("-update", String.format("60:%d:1", writeThreads),
180182
startKey, numKeys));
181183
if (0 != ret) {
182184
String errorMsg = "Update failed with error code " + ret;
183185
LOG.error(errorMsg);
184-
Assert.fail(errorMsg);
186+
fail(errorMsg);
185187
}
186188

187189
ret = loadTool.run(
@@ -195,7 +197,7 @@ protected void runIngestTest(long defaultRunTime, long keysPerServerPerIter, int
195197
if (0 != ret) {
196198
LOG.error("Rerun of Verification failed with error code " + ret);
197199
}
198-
Assert.fail(errorMsg);
200+
fail(errorMsg);
199201
}
200202
startKey += numKeys;
201203
}

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestStripeCompactions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
3232
import org.apache.hadoop.hbase.util.HFileTestUtil;
3333
import org.apache.hadoop.util.ToolRunner;
34-
import org.junit.experimental.categories.Category;
34+
import org.junit.jupiter.api.Tag;
3535

3636
/**
3737
* A test class that does the same things as IntegrationTestIngest but with stripe compactions. Can
3838
* be used with ChaosMonkey in the same manner.
3939
*/
40-
@Category(IntegrationTests.class)
40+
@Tag(IntegrationTests.TAG)
4141
public class IntegrationTestIngestStripeCompactions extends IntegrationTestIngest {
4242
@Override
4343
protected void initTable() throws IOException {

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithACL.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.hadoop.hbase.util.LoadTestTool;
3030
import org.apache.hadoop.hbase.util.test.LoadTestDataGeneratorWithACL;
3131
import org.apache.hadoop.util.ToolRunner;
32-
import org.junit.experimental.categories.Category;
32+
import org.junit.jupiter.api.Tag;
3333

3434
import org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine;
3535

@@ -39,7 +39,7 @@
3939
* WRITE permissions are not read back and cells with READ permissions are read back. Every
4040
* operation happens in the user's specific context
4141
*/
42-
@Category(IntegrationTests.class)
42+
@Tag(IntegrationTests.TAG)
4343
public class IntegrationTestIngestWithACL extends IntegrationTestIngest {
4444

4545
private static final char COLON = ':';

hbase-it/src/test/java/org/apache/hadoop/hbase/IntegrationTestIngestWithEncryption.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
3030
import org.apache.hadoop.hbase.util.EncryptionTest;
3131
import org.apache.hadoop.util.ToolRunner;
32-
import org.junit.Before;
33-
import org.junit.experimental.categories.Category;
32+
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.Tag;
3434
import org.slf4j.Logger;
3535
import org.slf4j.LoggerFactory;
3636

37-
@Category(IntegrationTests.class)
37+
@Tag(IntegrationTests.TAG)
3838
public class IntegrationTestIngestWithEncryption extends IntegrationTestIngest {
3939
private final static Logger LOG =
4040
LoggerFactory.getLogger(IntegrationTestIngestWithEncryption.class);
@@ -63,7 +63,7 @@ public void setUpCluster() throws Exception {
6363
initialized = true;
6464
}
6565

66-
@Before
66+
@BeforeEach
6767
@Override
6868
public void setUp() throws Exception {
6969
// Initialize the cluster. This invokes LoadTestTool -init_only, which

0 commit comments

Comments
 (0)