Skip to content

Commit 3d6d37f

Browse files
committed
HBASE-29938 Upgrade hbase-it to use junit5
1 parent 5603af2 commit 3d6d37f

37 files changed

+304
-325
lines changed

hbase-it/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@
200200
<artifactId>junit-jupiter-params</artifactId>
201201
<scope>test</scope>
202202
</dependency>
203-
<dependency>
204-
<groupId>org.junit.vintage</groupId>
205-
<artifactId>junit-vintage-engine</artifactId>
206-
<scope>test</scope>
207-
</dependency>
208203
<dependency>
209204
<groupId>org.hamcrest</groupId>
210205
<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: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
*/
1818
package org.apache.hadoop.hbase;
1919

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

2224
import java.io.IOException;
2325
import java.nio.charset.Charset;
@@ -51,11 +53,10 @@
5153
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
5254
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
5355
import org.apache.hadoop.util.ToolRunner;
54-
import org.junit.After;
55-
import org.junit.Assert;
56-
import org.junit.Before;
57-
import org.junit.Test;
58-
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;
5960
import org.slf4j.Logger;
6061
import org.slf4j.LoggerFactory;
6162

@@ -70,7 +71,7 @@
7071
* @see <a href="https://issues.apache.org/jira/browse/HBASE-7912">HBASE-7912</a>
7172
* @see <a href="https://issues.apache.org/jira/browse/HBASE-14123">HBASE-14123</a>
7273
*/
73-
@Category(IntegrationTests.class)
74+
@Tag(IntegrationTests.TAG)
7475
public class IntegrationTestBackupRestore extends IntegrationTestBase {
7576
private static final String CLASS_NAME = IntegrationTestBackupRestore.class.getSimpleName();
7677
protected static final Logger LOG = LoggerFactory.getLogger(IntegrationTestBackupRestore.class);
@@ -134,7 +135,7 @@ public void run() {
134135
}
135136

136137
@Override
137-
@Before
138+
@BeforeEach
138139
public void setUp() throws Exception {
139140
util = new IntegrationTestingUtility();
140141
Configuration conf = util.getConfiguration();
@@ -150,7 +151,7 @@ public void setUp() throws Exception {
150151
LOG.info("Cluster initialized and ready");
151152
}
152153

153-
@After
154+
@AfterEach
154155
public void tearDown() throws IOException {
155156
LOG.info("Cleaning up after test.");
156157
if (util.isDistributedCluster()) {
@@ -330,7 +331,7 @@ private void runTestSingle(TableName table) throws IOException {
330331
restore(createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tablesRestoreIncMultiple, null,
331332
true), client);
332333
Table hTable = conn.getTable(table);
333-
Assert.assertEquals(util.countRows(hTable), rowsInIteration * numIterations);
334+
assertEquals(util.countRows(hTable), rowsInIteration * numIterations);
334335
hTable.close();
335336
LOG.info("{} loop {} finished.", Thread.currentThread().getName(), (count - 1));
336337
}
@@ -343,7 +344,7 @@ private void restoreVerifyTable(Connection conn, BackupAdmin client, TableName t
343344
createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tablesRestoreIncMultiple, null, true),
344345
client);
345346
Table hTable = conn.getTable(table);
346-
Assert.assertEquals(expectedRows, util.countRows(hTable));
347+
assertEquals(expectedRows, util.countRows(hTable));
347348
hTable.close();
348349
}
349350

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;
@@ -191,8 +193,8 @@ protected void verifyNamespaces() throws IOException {
191193
// iterating concurrent map
192194
for (String nsName : namespaceMap.keySet()) {
193195
try {
194-
Assert.assertTrue("Namespace: " + nsName + " in namespaceMap does not exist",
195-
admin.getNamespaceDescriptor(nsName) != null);
196+
assertTrue(admin.getNamespaceDescriptor(nsName) != null,
197+
"Namespace: " + nsName + " in namespaceMap does not exist");
196198
} catch (NamespaceNotFoundException nsnfe) {
197199
Assert
198200
.fail("Namespace: " + nsName + " in namespaceMap does not exist: " + nsnfe.getMessage());
@@ -206,12 +208,12 @@ protected void verifyTables() throws IOException {
206208
Admin admin = connection.getAdmin();
207209
// iterating concurrent map
208210
for (TableName tableName : enabledTables.keySet()) {
209-
Assert.assertTrue("Table: " + tableName + " in enabledTables is not enabled",
210-
admin.isTableEnabled(tableName));
211+
assertTrue(admin.isTableEnabled(tableName),
212+
"Table: " + tableName + " in enabledTables is not enabled");
211213
}
212214
for (TableName tableName : disabledTables.keySet()) {
213-
Assert.assertTrue("Table: " + tableName + " in disabledTables is not disabled",
214-
admin.isTableDisabled(tableName));
215+
assertTrue(admin.isTableDisabled(tableName),
216+
"Table: " + tableName + " in disabledTables is not disabled");
215217
}
216218
for (TableName tableName : deletedTables.keySet()) {
217219
Assert.assertFalse("Table: " + tableName + " in deletedTables is not deleted",
@@ -287,7 +289,7 @@ void perform() throws IOException {
287289
LOG.info("Creating namespace:" + nsd);
288290
admin.createNamespace(nsd);
289291
NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(nsd.getName());
290-
Assert.assertTrue("Namespace: " + nsd + " was not created", freshNamespaceDesc != null);
292+
assertTrue(freshNamespaceDesc != null, "Namespace: " + nsd + " was not created");
291293
namespaceMap.put(nsd.getName(), freshNamespaceDesc);
292294
LOG.info("Created namespace:" + freshNamespaceDesc);
293295
} catch (Exception e) {
@@ -329,10 +331,10 @@ void perform() throws IOException {
329331
modifiedNsd.setConfiguration(nsTestConfigKey, nsValueNew);
330332
admin.modifyNamespace(modifiedNsd);
331333
NamespaceDescriptor freshNamespaceDesc = admin.getNamespaceDescriptor(namespaceName);
332-
Assert.assertTrue("Namespace: " + selected + " was not modified",
333-
freshNamespaceDesc.getConfigurationValue(nsTestConfigKey).equals(nsValueNew));
334-
Assert.assertTrue("Namespace: " + namespaceName + " does not exist",
335-
admin.getNamespaceDescriptor(namespaceName) != null);
334+
assertTrue(freshNamespaceDesc.getConfigurationValue(nsTestConfigKey).equals(nsValueNew),
335+
"Namespace: " + selected + " was not modified");
336+
assertTrue(admin.getNamespaceDescriptor(namespaceName) != null,
337+
"Namespace: " + namespaceName + " does not exist");
336338
namespaceMap.put(namespaceName, freshNamespaceDesc);
337339
LOG.info("Modified namespace :" + freshNamespaceDesc);
338340
} catch (Exception e) {
@@ -360,7 +362,7 @@ void perform() throws IOException {
360362
try {
361363
if (admin.getNamespaceDescriptor(namespaceName) != null) {
362364
// the namespace still exists.
363-
Assert.assertTrue("Namespace: " + selected + " was not deleted", false);
365+
assertTrue(false, "Namespace: " + selected + " was not deleted");
364366
} else {
365367
LOG.info("Deleted namespace :" + selected);
366368
}
@@ -411,10 +413,10 @@ void perform() throws IOException {
411413
byte[] endKey = Bytes.toBytes("row-" + Integer.MAX_VALUE);
412414
LOG.info("Creating table:" + td);
413415
admin.createTable(td, startKey, endKey, numRegions);
414-
Assert.assertTrue("Table: " + td + " was not created", admin.tableExists(tableName));
416+
assertTrue(admin.tableExists(tableName), "Table: " + td + " was not created");
415417
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
416-
Assert.assertTrue("After create, Table: " + tableName + " in not enabled",
417-
admin.isTableEnabled(tableName));
418+
assertTrue(admin.isTableEnabled(tableName),
419+
"After create, Table: " + tableName + " in not enabled");
418420
enabledTables.put(tableName, freshTableDesc);
419421
LOG.info("Created table:" + freshTableDesc);
420422
} catch (Exception e) {
@@ -449,11 +451,10 @@ void perform() throws IOException {
449451
TableName tableName = selected.getTableName();
450452
LOG.info("Disabling table :" + selected);
451453
admin.disableTable(tableName);
452-
Assert.assertTrue("Table: " + selected + " was not disabled",
453-
admin.isTableDisabled(tableName));
454+
assertTrue(admin.isTableDisabled(tableName), "Table: " + selected + " was not disabled");
454455
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
455-
Assert.assertTrue("After disable, Table: " + tableName + " is not disabled",
456-
admin.isTableDisabled(tableName));
456+
assertTrue(admin.isTableDisabled(tableName),
457+
"After disable, Table: " + tableName + " is not disabled");
457458
disabledTables.put(tableName, freshTableDesc);
458459
LOG.info("Disabled table :" + freshTableDesc);
459460
} catch (Exception e) {
@@ -497,11 +498,10 @@ void perform() throws IOException {
497498
TableName tableName = selected.getTableName();
498499
LOG.info("Enabling table :" + selected);
499500
admin.enableTable(tableName);
500-
Assert.assertTrue("Table: " + selected + " was not enabled",
501-
admin.isTableEnabled(tableName));
501+
assertTrue(admin.isTableEnabled(tableName), "Table: " + selected + " was not enabled");
502502
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
503-
Assert.assertTrue("After enable, Table: " + tableName + " in not enabled",
504-
admin.isTableEnabled(tableName));
503+
assertTrue(admin.isTableEnabled(tableName),
504+
"After enable, Table: " + tableName + " in not enabled");
505505
enabledTables.put(tableName, freshTableDesc);
506506
LOG.info("Enabled table :" + freshTableDesc);
507507
} catch (Exception e) {
@@ -594,10 +594,10 @@ void perform() throws IOException {
594594
admin.addColumnFamily(tableName, cfd);
595595
// assertion
596596
TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
597-
Assert.assertTrue("Column family: " + cfd + " was not added",
598-
freshTableDesc.hasColumnFamily(cfd.getName()));
599-
Assert.assertTrue("After add column family, Table: " + tableName + " is not disabled",
600-
admin.isTableDisabled(tableName));
597+
assertTrue(freshTableDesc.hasColumnFamily(cfd.getName()),
598+
"Column family: " + cfd + " was not added");
599+
assertTrue(admin.isTableDisabled(tableName),
600+
"After add column family, Table: " + tableName + " is not disabled");
601601
disabledTables.put(tableName, freshTableDesc);
602602
LOG.info("Added column family: " + cfd + " to table: " + tableName);
603603
} catch (Exception e) {
@@ -648,9 +648,8 @@ void perform() throws IOException {
648648
freshColumnDesc.getMaxVersions(), versions);
649649
Assert.assertEquals("Column family: " + freshColumnDesc + " was not altered",
650650
freshColumnDesc.getMinVersions(), versions);
651-
Assert.assertTrue(
652-
"After alter versions of column family, Table: " + tableName + " is not disabled",
653-
admin.isTableDisabled(tableName));
651+
assertTrue(admin.isTableDisabled(tableName),
652+
"After alter versions of column family, Table: " + tableName + " is not disabled");
654653
disabledTables.put(tableName, freshTableDesc);
655654
LOG.info("Altered versions of column family: " + columnDesc + " to: " + versions
656655
+ " 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
@@ -95,7 +97,7 @@ protected int getMinServerCount() {
9597

9698
protected void initTable() throws IOException {
9799
int ret = loadTool.run(getArgsForLoadTestToolInitTable());
98-
Assert.assertEquals("Failed to initialize LoadTestTool", 0, ret);
100+
assertEquals(0, ret, "Failed to initialize LoadTestTool");
99101
}
100102

101103
@Override
@@ -175,15 +177,15 @@ protected void runIngestTest(long defaultRunTime, long keysPerServerPerIter, int
175177
if (0 != ret) {
176178
String errorMsg = "Load failed with error code " + ret;
177179
LOG.error(errorMsg);
178-
Assert.fail(errorMsg);
180+
fail(errorMsg);
179181
}
180182

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

189191
ret = loadTool.run(
@@ -197,7 +199,7 @@ protected void runIngestTest(long defaultRunTime, long keysPerServerPerIter, int
197199
if (0 != ret) {
198200
LOG.error("Rerun of Verification failed with error code " + ret);
199201
}
200-
Assert.fail(errorMsg);
202+
fail(errorMsg);
201203
}
202204
startKey += numKeys;
203205
}

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
@@ -25,13 +25,13 @@
2525
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
2626
import org.apache.hadoop.hbase.util.HFileTestUtil;
2727
import org.apache.hadoop.util.ToolRunner;
28-
import org.junit.experimental.categories.Category;
28+
import org.junit.jupiter.api.Tag;
2929

3030
/**
3131
* A test class that does the same things as IntegrationTestIngest but with stripe compactions. Can
3232
* be used with ChaosMonkey in the same manner.
3333
*/
34-
@Category(IntegrationTests.class)
34+
@Tag(IntegrationTests.TAG)
3535
public class IntegrationTestIngestStripeCompactions extends IntegrationTestIngest {
3636
@Override
3737
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)