Skip to content

Commit eef5d6f

Browse files
committed
address review comments.
1 parent 9b2c5b6 commit eef5d6f

29 files changed

+229
-240
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNStorageRetentionManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getFinalizedEditsFileName;
2121
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getImageFileName;
2222
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getInProgressEditsFileName;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
2324
import static org.mockito.ArgumentMatchers.any;
2425

2526
import java.io.File;
@@ -45,7 +46,6 @@
4546
import org.apache.hadoop.hdfs.server.namenode.NNStorageRetentionManager.StoragePurger;
4647
import org.apache.hadoop.util.Lists;
4748

48-
import org.junit.jupiter.api.Assertions;
4949
import org.junit.jupiter.api.BeforeEach;
5050
import org.junit.jupiter.api.Test;
5151
import org.mockito.ArgumentCaptor;
@@ -310,23 +310,23 @@ private void runTest(TestCaseDescription tc) throws IOException {
310310
for (FSImageFile captured : imagesPurgedCaptor.getAllValues()) {
311311
capturedPaths.add(fileToPath(captured.getFile()));
312312
}
313-
Assertions.assertEquals(Joiner.on(",").join(filesToPaths(tc.expectedPurgedImages)),
313+
assertEquals(Joiner.on(",").join(filesToPaths(tc.expectedPurgedImages)),
314314
Joiner.on(",").join(capturedPaths), "Image file check.");
315315

316316
capturedPaths.clear();
317317
// Check edit logs, and also in progress edits older than minTxIdToKeep
318318
for (EditLogFile captured : logsPurgedCaptor.getAllValues()) {
319319
capturedPaths.add(fileToPath(captured.getFile()));
320320
}
321-
Assertions.assertEquals(Joiner.on(",").join(filesToPaths(tc.expectedPurgedLogs)),
321+
assertEquals(Joiner.on(",").join(filesToPaths(tc.expectedPurgedLogs)),
322322
Joiner.on(",").join(capturedPaths), "Check old edits are removed.");
323323

324324
capturedPaths.clear();
325325
// Check in progress edits to keep are marked as stale
326326
for (EditLogFile captured : staleLogsCaptor.getAllValues()) {
327327
capturedPaths.add(fileToPath(captured.getFile()));
328328
}
329-
Assertions.assertEquals(Joiner.on(",").join(filesToPaths(tc.expectedStaleLogs)),
329+
assertEquals(Joiner.on(",").join(filesToPaths(tc.expectedStaleLogs)),
330330
Joiner.on(",").join(capturedPaths), "Check unnecessary but kept edits are marked stale");
331331
}
332332

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNNThroughputBenchmark.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@
3232
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
3333
import org.apache.hadoop.util.ExitUtil;
3434
import org.junit.jupiter.api.AfterEach;
35-
import org.junit.jupiter.api.Assertions;
3635
import org.junit.jupiter.api.BeforeAll;
3736
import org.junit.jupiter.api.Test;
3837
import org.junit.jupiter.api.Timeout;
3938

39+
import static org.junit.jupiter.api.Assertions.assertEquals;
40+
import static org.junit.jupiter.api.Assertions.assertFalse;
41+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
42+
import static org.junit.jupiter.api.Assertions.assertTrue;
43+
4044
public class TestNNThroughputBenchmark {
4145

42-
@BeforeAll
43-
public static void setUp() {
46+
@BeforeAll
47+
public static void setUp() {
4448
ExitUtil.disableSystemExit();
4549
}
4650

@@ -184,10 +188,10 @@ public void testNNThroughputForAppendOp() throws Exception {
184188
listing = fsNamesystem.getListing("/", HdfsFileStatus.EMPTY_NAME, false);
185189
HdfsFileStatus[] partialListingAfter = listing.getPartialListing();
186190

187-
Assertions.assertEquals(partialListing.length, partialListingAfter.length);
191+
assertEquals(partialListing.length, partialListingAfter.length);
188192
for (int i = 0; i < partialListing.length; i++) {
189193
//Check the modification time after append operation
190-
Assertions.assertNotEquals(partialListing[i].getModificationTime(),
194+
assertNotEquals(partialListing[i].getModificationTime(),
191195
partialListingAfter[i].getModificationTime());
192196
}
193197

@@ -241,13 +245,13 @@ public void testNNThroughputWithBaseDir() throws Exception {
241245
NNThroughputBenchmark.runBenchmark(benchConf,
242246
new String[] {"-op", "create", "-keepResults", "-files", "3", "-baseDirName",
243247
"/nnThroughputBenchmark1", "-close"});
244-
Assertions.assertTrue(fs.exists(new Path("/nnThroughputBenchmark1")));
245-
Assertions.assertFalse(fs.exists(new Path("/nnThroughputBenchmark")));
248+
assertTrue(fs.exists(new Path("/nnThroughputBenchmark1")));
249+
assertFalse(fs.exists(new Path("/nnThroughputBenchmark")));
246250

247251
NNThroughputBenchmark.runBenchmark(benchConf,
248252
new String[] {"-op", "all", "-baseDirName", "/nnThroughputBenchmark1"});
249-
Assertions.assertTrue(fs.exists(new Path("/nnThroughputBenchmark1")));
250-
Assertions.assertFalse(fs.exists(new Path("/nnThroughputBenchmark")));
253+
assertTrue(fs.exists(new Path("/nnThroughputBenchmark1")));
254+
assertFalse(fs.exists(new Path("/nnThroughputBenchmark")));
251255
} finally {
252256
if (cluster != null) {
253257
cluster.shutdown();

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeOptionParsing.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import static org.junit.jupiter.api.Assertions.assertEquals;
2222
import static org.junit.jupiter.api.Assertions.assertNull;
2323
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.fail;
2425

2526
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
2627
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.RollingUpgradeStartupOption;
2728
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption;
28-
import org.junit.jupiter.api.Assertions;
2929
import org.junit.jupiter.api.Test;
3030
import org.junit.jupiter.api.Timeout;
3131

@@ -135,7 +135,7 @@ public void testRollingUpgrade() {
135135
final String[] args = {"-rollingUpgrade", "foo"};
136136
try {
137137
NameNode.parseArguments(args);
138-
Assertions.fail();
138+
fail();
139139
} catch(IllegalArgumentException iae) {
140140
// the exception is expected.
141141
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_READ_LOCK_REPORTING_THRESHOLD_MS_KEY;
4040
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SLOWPEER_COLLECT_INTERVAL_KEY;
4141
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_WRITE_LOCK_REPORTING_THRESHOLD_MS_KEY;
42-
import static org.junit.jupiter.api.Assertions.*;
4342

4443
import org.slf4j.Logger;
4544
import org.slf4j.LoggerFactory;
@@ -76,6 +75,12 @@
7675
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_LIMIT;
7776
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_DECOMMISSION_BACKOFF_MONITOR_PENDING_BLOCKS_PER_LOCK;
7877
import static org.apache.hadoop.fs.CommonConfigurationKeys.IPC_BACKOFF_ENABLE_DEFAULT;
78+
import static org.junit.jupiter.api.Assertions.assertEquals;
79+
import static org.junit.jupiter.api.Assertions.assertFalse;
80+
import static org.junit.jupiter.api.Assertions.assertNotNull;
81+
import static org.junit.jupiter.api.Assertions.assertNull;
82+
import static org.junit.jupiter.api.Assertions.assertTrue;
83+
import static org.junit.jupiter.api.Assertions.fail;
7984

8085
public class TestNameNodeReconfigure {
8186

@@ -514,9 +519,9 @@ public void testSlowPeerTrackerEnabled() throws Exception {
514519
nameNode.reconfigurePropertyImpl(DFS_DATANODE_PEER_STATS_ENABLED_KEY, "non-boolean");
515520
fail("should not reach here");
516521
} catch (ReconfigurationException e) {
517-
assertEquals(
518-
"Could not change property dfs.datanode.peer.stats.enabled from 'false' to 'non-boolean'",
519-
e.getMessage());
522+
assertEquals(
523+
"Could not change property dfs.datanode.peer.stats.enabled from 'false' to 'non-boolean'",
524+
e.getMessage());
520525
}
521526

522527
nameNode.reconfigurePropertyImpl(DFS_DATANODE_PEER_STATS_ENABLED_KEY, "True");

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRecovery.java

Lines changed: 28 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151
import org.apache.hadoop.test.GenericTestUtils;
5252
import org.apache.hadoop.test.PathUtils;
5353
import org.apache.hadoop.util.StringUtils;
54+
import org.junit.jupiter.api.Test;
5455
import org.junit.jupiter.api.Timeout;
55-
import org.junit.jupiter.params.ParameterizedTest;
56+
import org.junit.jupiter.params.ParameterizedClass;
5657
import org.junit.jupiter.params.provider.MethodSource;
5758
import org.slf4j.Logger;
5859
import org.slf4j.LoggerFactory;
@@ -61,6 +62,8 @@
6162
* This tests data recovery mode for the NameNode.
6263
*/
6364

65+
@MethodSource("data")
66+
@ParameterizedClass
6467
public class TestNameNodeRecovery {
6568

6669
public static Collection<Object[]> data() {
@@ -71,8 +74,8 @@ public static Collection<Object[]> data() {
7174
}
7275

7376
private static boolean useAsyncEditLog;
74-
public void initTestNameNodeRecovery(Boolean pAsync) {
75-
useAsyncEditLog = pAsync;
77+
public TestNameNodeRecovery(Boolean async) {
78+
useAsyncEditLog = async;
7679
}
7780

7881
private static Configuration getConf() {
@@ -256,30 +259,24 @@ public Set<Long> getValidTxIds() {
256259
}
257260

258261
/** Test an empty edit log */
259-
@MethodSource("data")
260-
@ParameterizedTest
262+
@Test
261263
@Timeout(value = 180)
262-
public void testEmptyLog(Boolean pAsync) throws IOException {
263-
initTestNameNodeRecovery(pAsync);
264+
public void testEmptyLog() throws IOException {
264265
runEditLogTest(new EltsTestEmptyLog(0));
265266
}
266267

267268
/** Test an empty edit log with padding */
268-
@MethodSource("data")
269-
@ParameterizedTest
269+
@Test
270270
@Timeout(value = 180)
271-
public void testEmptyPaddedLog(Boolean pAsync) throws IOException {
272-
initTestNameNodeRecovery(pAsync);
271+
public void testEmptyPaddedLog() throws IOException {
273272
runEditLogTest(new EltsTestEmptyLog(
274273
EditLogFileOutputStream.MIN_PREALLOCATION_LENGTH));
275274
}
276275

277276
/** Test an empty edit log with extra-long padding */
278-
@MethodSource("data")
279-
@ParameterizedTest
277+
@Test
280278
@Timeout(value = 180)
281-
public void testEmptyExtraPaddedLog(Boolean pAsync) throws IOException {
282-
initTestNameNodeRecovery(pAsync);
279+
public void testEmptyExtraPaddedLog() throws IOException {
283280
runEditLogTest(new EltsTestEmptyLog(
284281
3 * EditLogFileOutputStream.MIN_PREALLOCATION_LENGTH));
285282
}
@@ -315,11 +312,9 @@ public int getMaxOpSize() {
315312
}
316313

317314
/** Test an empty edit log with extra-long padding */
318-
@MethodSource("data")
319-
@ParameterizedTest
315+
@Test
320316
@Timeout(value = 180)
321-
public void testNonDefaultMaxOpSize(Boolean pAsync) throws IOException {
322-
initTestNameNodeRecovery(pAsync);
317+
public void testNonDefaultMaxOpSize() throws IOException {
323318
runEditLogTest(new EltsTestNonDefaultMaxOpSize());
324319
}
325320

@@ -355,20 +350,16 @@ public Set<Long> getValidTxIds() {
355350
}
356351
}
357352

358-
@MethodSource("data")
359-
@ParameterizedTest
353+
@Test
360354
@Timeout(value = 180)
361-
public void testOpcodesAfterPadding(Boolean pAsync) throws IOException {
362-
initTestNameNodeRecovery(pAsync);
355+
public void testOpcodesAfterPadding() throws IOException {
363356
runEditLogTest(new EltsTestOpcodesAfterPadding(
364357
EditLogFileOutputStream.MIN_PREALLOCATION_LENGTH));
365358
}
366359

367-
@MethodSource("data")
368-
@ParameterizedTest
360+
@Test
369361
@Timeout(value = 180)
370-
public void testOpcodesAfterExtraPadding(Boolean pAsync) throws IOException {
371-
initTestNameNodeRecovery(pAsync);
362+
public void testOpcodesAfterExtraPadding() throws IOException {
372363
runEditLogTest(new EltsTestOpcodesAfterPadding(
373364
3 * EditLogFileOutputStream.MIN_PREALLOCATION_LENGTH));
374365
}
@@ -409,11 +400,9 @@ public Set<Long> getValidTxIds() {
409400

410401
/** Test that we can successfully recover from a situation where there is
411402
* garbage in the middle of the edit log file output stream. */
412-
@MethodSource("data")
413-
@ParameterizedTest
403+
@Test
414404
@Timeout(value = 180)
415-
public void testSkipEdit(Boolean pAsync) throws IOException {
416-
initTestNameNodeRecovery(pAsync);
405+
public void testSkipEdit() throws IOException {
417406
runEditLogTest(new EltsTestGarbageInEditLog());
418407
}
419408

@@ -673,44 +662,36 @@ static void testNameNodeRecoveryImpl(Corruptor corruptor, boolean finalize)
673662

674663
/** Test that we can successfully recover from a situation where the last
675664
* entry in the edit log has been truncated. */
676-
@MethodSource("data")
677-
@ParameterizedTest
665+
@Test
678666
@Timeout(value = 180)
679-
public void testRecoverTruncatedEditLog(Boolean pAsync) throws IOException {
680-
initTestNameNodeRecovery(pAsync);
667+
public void testRecoverTruncatedEditLog() throws IOException {
681668
testNameNodeRecoveryImpl(new TruncatingCorruptor(), true);
682669
testNameNodeRecoveryImpl(new TruncatingCorruptor(), false);
683670
}
684671

685672
/** Test that we can successfully recover from a situation where the last
686673
* entry in the edit log has been padded with garbage. */
687-
@MethodSource("data")
688-
@ParameterizedTest
674+
@Test
689675
@Timeout(value = 180)
690-
public void testRecoverPaddedEditLog(Boolean pAsync) throws IOException {
691-
initTestNameNodeRecovery(pAsync);
676+
public void testRecoverPaddedEditLog() throws IOException {
692677
testNameNodeRecoveryImpl(new PaddingCorruptor(), true);
693678
testNameNodeRecoveryImpl(new PaddingCorruptor(), false);
694679
}
695680

696681
/** Test that don't need to recover from a situation where the last
697682
* entry in the edit log has been padded with 0. */
698-
@MethodSource("data")
699-
@ParameterizedTest
683+
@Test
700684
@Timeout(value = 180)
701-
public void testRecoverZeroPaddedEditLog(Boolean pAsync) throws IOException {
702-
initTestNameNodeRecovery(pAsync);
685+
public void testRecoverZeroPaddedEditLog() throws IOException {
703686
testNameNodeRecoveryImpl(new SafePaddingCorruptor((byte)0), true);
704687
testNameNodeRecoveryImpl(new SafePaddingCorruptor((byte)0), false);
705688
}
706689

707690
/** Test that don't need to recover from a situation where the last
708691
* entry in the edit log has been padded with 0xff bytes. */
709-
@MethodSource("data")
710-
@ParameterizedTest
692+
@Test
711693
@Timeout(value = 180)
712-
public void testRecoverNegativeOnePaddedEditLog(Boolean pAsync) throws IOException {
713-
initTestNameNodeRecovery(pAsync);
694+
public void testRecoverNegativeOnePaddedEditLog() throws IOException {
714695
testNameNodeRecoveryImpl(new SafePaddingCorruptor((byte)-1), true);
715696
testNameNodeRecoveryImpl(new SafePaddingCorruptor((byte)-1), false);
716697
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRetryCacheMetrics.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public void testRetryCacheMetrics() throws IOException {
9898
}
9999

100100
private void checkMetrics(long hit, long cleared, long updated) {
101-
assertEquals(hit, metrics.getCacheHit(), "CacheHit");
102-
assertEquals(cleared, metrics.getCacheCleared(), "CacheCleared");
103-
assertEquals(updated, metrics.getCacheUpdated(), "CacheUpdated");
101+
assertEquals(hit, metrics.getCacheHit(), "CacheHit");
102+
assertEquals(cleared, metrics.getCacheCleared(), "CacheCleared");
103+
assertEquals(updated, metrics.getCacheUpdated(), "CacheUpdated");
104104
}
105105

106106
private void trySaveNamespace() throws IOException {

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public void testNamenodeRpcClientIpProxy() throws IOException {
240240
// found some other host, so things are good
241241
break;
242242
} else if (trial == ITERATIONS_TO_USE - 1) {
243-
assertNotEquals(hosts[0], host, "Failed to get non-node1");
243+
assertNotEquals(hosts[0], host, "Failed to get non-node1");
244244
}
245245
}
246246
// Run as fake joe to authorize the test

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeRpcServerMethods.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
import org.apache.hadoop.security.AccessControlException;
3333
import org.apache.hadoop.test.GenericTestUtils;
3434
import org.junit.jupiter.api.AfterEach;
35-
import org.junit.jupiter.api.Assertions;
3635
import org.junit.jupiter.api.BeforeEach;
3736
import org.junit.jupiter.api.Test;
3837

3938
import static org.junit.jupiter.api.Assertions.assertEquals;
39+
import static org.junit.jupiter.api.Assertions.fail;
4040

4141
public class TestNameNodeRpcServerMethods {
4242
private static NamenodeProtocols nnRpc;
@@ -73,15 +73,15 @@ public void testDeleteSnapshotWhenSnapshotNameIsEmpty() throws Exception {
7373
String dir = "/testNamenodeRetryCache/testDelete";
7474
try {
7575
nnRpc.deleteSnapshot(dir, null);
76-
Assertions.fail("testdeleteSnapshot is not thrown expected exception ");
76+
fail("testdeleteSnapshot is not thrown expected exception ");
7777
} catch (IOException e) {
7878
// expected
7979
GenericTestUtils.assertExceptionContains(
8080
"The snapshot name is null or empty.", e);
8181
}
8282
try {
8383
nnRpc.deleteSnapshot(dir, "");
84-
Assertions.fail("testdeleteSnapshot is not thrown expected exception");
84+
fail("testdeleteSnapshot is not thrown expected exception");
8585
} catch (IOException e) {
8686
// expected
8787
GenericTestUtils.assertExceptionContains(

0 commit comments

Comments
 (0)