Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
import static org.apache.hadoop.security.SecurityUtilTestHelper.isExternalKdcRunning;
import org.junit.Assume;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -59,7 +60,7 @@ public class TestSecureNameNodeWithExternalKdc {
@BeforeEach
public void testExternalKdcRunning() {
// Tests are skipped if external KDC is not running.
Assume.assumeTrue(isExternalKdcRunning());
assumeTrue(isExternalKdcRunning());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.qjournal.MiniQJMHACluster;
import org.apache.hadoop.util.ToolRunner;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* To test {@link FSNLockBenchmarkThroughput}.
Expand Down Expand Up @@ -93,8 +94,8 @@ private void testBenchmarkThroughput(boolean enableFGL, int readWriteRatio,
String.valueOf(readWriteRatio), String.valueOf(testingCount),
String.valueOf(numClients)};

Assert.assertEquals(0, ToolRunner.run(conf,
new FSNLockBenchmarkThroughput(fileSystem), args));
assertEquals(0,
ToolRunner.run(conf, new FSNLockBenchmarkThroughput(fileSystem), args));
} finally {
if (qjmhaCluster != null) {
qjmhaCluster.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.apache.hadoop.hdfs.util.RwLockMode;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.concurrent.HadoopExecutors;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -44,7 +45,8 @@ private int getLoopNumber() {
/**
* Test read/write lock of Global, FS and BM model through multi-threading.
*/
@Test(timeout=120000)
@Test
@Timeout(value = 120)
public void testMultipleThreadsUsingLocks()
throws InterruptedException, ExecutionException {
FineGrainedFSNamesystemLock fsn = new FineGrainedFSNamesystemLock(new Configuration(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.net.MalformedURLException;
Expand All @@ -40,7 +40,7 @@
import org.apache.hadoop.hdfs.server.namenode.NameNode;
import org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

/**
Expand Down Expand Up @@ -107,8 +107,8 @@ public void testGetOtherNNHttpAddress() throws IOException {
NameNode.initializeGenericKeys(conf, "ns1", "nn1");

checkpointer = new StandbyCheckpointer(conf, fsn);
assertEquals("Got an unexpected number of possible active NNs", 2, checkpointer
.getActiveNNAddresses().size());
assertEquals(2, checkpointer.getActiveNNAddresses().size(),
"Got an unexpected number of possible active NNs");
assertEquals(new URL("http", "1.2.3.2", DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_DEFAULT, ""),
checkpointer.getActiveNNAddresses().get(0));
assertAddressMatches("1.2.3.2", checkpointer.getActiveNNAddresses().get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import org.apache.hadoop.hdfs.HdfsConfiguration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Test case for FilesInGetListingOps metric in Namenode
Expand All @@ -52,15 +52,15 @@ public class TestNNMetricFilesInGetListingOps {
private DistributedFileSystem fs;
private final Random rand = new Random();

@Before
@BeforeEach
public void setUp() throws Exception {
cluster = new MiniDFSCluster.Builder(CONF).build();
cluster.waitActive();
cluster.getNameNode();
fs = cluster.getFileSystem();
}

@After
@AfterEach
public void tearDown() throws Exception {
if (cluster != null) {
cluster.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import static org.apache.hadoop.test.MetricsAsserts.assertGauge;
import static org.apache.hadoop.test.MetricsAsserts.assertQuantileGauges;
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.DataInputStream;
import java.io.File;
Expand Down Expand Up @@ -94,9 +94,10 @@
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.MetricsAsserts;
import org.slf4j.event.Level;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

/**
* Test for metrics published by the Namenode
Expand Down Expand Up @@ -162,7 +163,7 @@ private static Path getTestPath(String fileName) {
return new Path(TEST_ROOT_DIR_PATH, fileName);
}

@Before
@BeforeEach
public void setUp() throws Exception {
hostsFileWriter = new HostsFileWriter();
hostsFileWriter.initialize(CONF, "temp/decommission");
Expand All @@ -178,7 +179,7 @@ public void setUp() throws Exception {
fs.setErasureCodingPolicy(ecDir, EC_POLICY.getName());
}

@After
@AfterEach
public void tearDown() throws Exception {
MetricsSource source = DefaultMetricsSystem.instance().getSource("UgiMetrics");
if (source != null) {
Expand Down Expand Up @@ -213,7 +214,8 @@ private void readFile(FileSystem fileSys,Path name) throws IOException {
* Test that capacity metrics are exported and pass
* basic sanity tests.
*/
@Test (timeout = 10000)
@Test
@Timeout(value = 10)
public void testCapacityMetrics() throws Exception {
MetricsRecordBuilder rb = getMetrics(NS_METRICS);
long capacityTotal = MetricsAsserts.getLongGauge("CapacityTotal", rb);
Expand Down Expand Up @@ -443,35 +445,34 @@ private void verifyZeroMetrics() throws Exception {
*/
private void verifyAggregatedMetricsTally() throws Exception {
BlockManagerTestUtil.updateState(bm);
assertEquals("Under replicated metrics not matching!",
namesystem.getLowRedundancyBlocks(),
namesystem.getUnderReplicatedBlocks());
assertEquals("Low redundancy metrics not matching!",
namesystem.getLowRedundancyBlocks(),
assertEquals(namesystem.getLowRedundancyBlocks(),
namesystem.getUnderReplicatedBlocks(),
"Under replicated metrics not matching!");
assertEquals(namesystem.getLowRedundancyBlocks(),
namesystem.getLowRedundancyReplicatedBlocks() +
namesystem.getLowRedundancyECBlockGroups());
assertEquals("Corrupt blocks metrics not matching!",
namesystem.getCorruptReplicaBlocks(),
namesystem.getLowRedundancyECBlockGroups(),
"Low redundancy metrics not matching!");
assertEquals(namesystem.getCorruptReplicaBlocks(),
namesystem.getCorruptReplicatedBlocks() +
namesystem.getCorruptECBlockGroups());
assertEquals("Missing blocks metrics not matching!",
namesystem.getMissingBlocksCount(),
namesystem.getCorruptECBlockGroups(),
"Corrupt blocks metrics not matching!");
assertEquals(namesystem.getMissingBlocksCount(),
namesystem.getMissingReplicatedBlocks() +
namesystem.getMissingECBlockGroups());
assertEquals("Missing blocks with replication factor one not matching!",
namesystem.getMissingReplOneBlocksCount(),
namesystem.getMissingReplicationOneBlocks());
assertEquals("Blocks with badly distributed are not matching!",
namesystem.getBadlyDistributedBlocksCount(),
namesystem.getBadlyDistributedBlocks());
assertEquals("Bytes in future blocks metrics not matching!",
namesystem.getBytesInFuture(),
namesystem.getMissingECBlockGroups(),
"Missing blocks metrics not matching!");
assertEquals(namesystem.getMissingReplOneBlocksCount(),
namesystem.getMissingReplicationOneBlocks(),
"Missing blocks with replication factor one not matching!");
assertEquals(namesystem.getBadlyDistributedBlocksCount(),
namesystem.getBadlyDistributedBlocks(), "Blocks with badly distributed are not matching!");
assertEquals(namesystem.getBytesInFuture(),
namesystem.getBytesInFutureReplicatedBlocks() +
namesystem.getBytesInFutureECBlockGroups());
assertEquals("Pending deletion blocks metrics not matching!",
namesystem.getPendingDeletionBlocks(),
namesystem.getBytesInFutureECBlockGroups(),
"Bytes in future blocks metrics not matching!");
assertEquals(namesystem.getPendingDeletionBlocks(),
namesystem.getPendingDeletionReplicatedBlocks() +
namesystem.getPendingDeletionECBlocks());
namesystem.getPendingDeletionECBlocks(),
"Pending deletion blocks metrics not matching!");
}

/** Corrupt a block and ensure metrics reflects it */
Expand Down Expand Up @@ -567,7 +568,8 @@ public void testCorruptBlock() throws Exception {
verifyAggregatedMetricsTally();
}

@Test (timeout = 90000L)
@Test
@Timeout(90)
public void testStripedFileCorruptBlocks() throws Exception {
final long fileLen = BLOCK_SIZE * 4;
final Path ecFile = new Path(ecDir, "ecFile.log");
Expand Down Expand Up @@ -810,7 +812,8 @@ public void testGetBlockLocationMetric() throws Exception {
* Testing TransactionsSinceLastCheckpoint. Need a new cluster as
* the other tests in here don't use HA. See HDFS-7501.
*/
@Test(timeout = 300000)
@Test
@Timeout(value = 300)
public void testTransactionSinceLastCheckpointMetrics() throws Exception {
Random random = new Random();
int retryCount = 0;
Expand Down Expand Up @@ -845,10 +848,10 @@ public void testTransactionSinceLastCheckpointMetrics() throws Exception {
HATestUtil.waitForStandbyToCatchUp(nn0, nn1);
// Test to ensure tracking works before the first-ever
// checkpoint.
assertEquals("SBN failed to track 2 transactions pre-checkpoint.",
4L, // 2 txns added further when catch-up is called.
assertEquals(4L, // 2 txns added further when catch-up is called.
cluster2.getNameNode(1).getNamesystem()
.getTransactionsSinceLastCheckpoint());
.getTransactionsSinceLastCheckpoint(),
"SBN failed to track 2 transactions pre-checkpoint.");
// Complete up to the boundary required for
// an auto-checkpoint. Using 94 to expect fsimage
// rounded at 100, as 4 + 94 + 2 (catch-up call) = 100.
Expand All @@ -861,19 +864,19 @@ public void testTransactionSinceLastCheckpointMetrics() throws Exception {
// Test to ensure number tracks the right state of
// uncheckpointed edits, and does not go negative
// (as fixed in HDFS-7501).
assertEquals("Should be zero right after the checkpoint.",
0L,
assertEquals(0L,
cluster2.getNameNode(1).getNamesystem()
.getTransactionsSinceLastCheckpoint());
.getTransactionsSinceLastCheckpoint(),
"Should be zero right after the checkpoint.");
fs2.mkdirs(new Path("/tmp-t3"));
fs2.mkdirs(new Path("/tmp-t4"));
HATestUtil.waitForStandbyToCatchUp(nn0, nn1);
// Test to ensure we track the right numbers after
// the checkpoint resets it to zero again.
assertEquals("SBN failed to track 2 added txns after the ckpt.",
4L,
assertEquals(4L,
cluster2.getNameNode(1).getNamesystem()
.getTransactionsSinceLastCheckpoint());
.getTransactionsSinceLastCheckpoint(),
"SBN failed to track 2 added txns after the ckpt.");
cluster2.shutdown();
break;
} catch (Exception e) {
Expand Down Expand Up @@ -966,7 +969,8 @@ public void testReadWriteOps() throws Exception {
* Test metrics indicating the number of active clients and the files under
* construction
*/
@Test(timeout = 60000)
@Test
@Timeout(value = 60)
public void testNumActiveClientsAndFilesUnderConstructionMetrics()
throws Exception {
final Path file1 = getTestPath("testFileAdd1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.hadoop.metrics2.MetricsCollector;
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
import org.apache.hadoop.metrics2.lib.Interns;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.apache.hadoop.hdfs.server.namenode.top.metrics.TopMetrics.TOPMETRICS_METRICS_SOURCE_NAME;
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.apache.log4j.LogManager;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.WriterAppender;
import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -59,8 +58,9 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Helper for writing snapshot related tests
Expand Down Expand Up @@ -210,7 +210,7 @@ Path mkdirs(Path dir) throws Exception {
final String label = "mkdirs " + dir;
LOG.info(label);
hdfs.mkdirs(dir);
Assert.assertTrue(label, hdfs.exists(dir));
assertTrue(hdfs.exists(dir), label);
return dir;
}

Expand All @@ -222,7 +222,7 @@ Path createFile(Path file) throws Exception {
final String label = "createFile " + file;
LOG.info(label);
DFSTestUtil.createFile(hdfs, file, 0, (short)1, 0L);
Assert.assertTrue(label, hdfs.exists(file));
assertTrue(hdfs.exists(file), label);
return file;
}

Expand All @@ -233,7 +233,7 @@ String rename(Path src, Path dst) throws Exception {
final String label = "rename " + src + " -> " + dst;
final boolean renamed = hdfs.rename(src, dst);
LOG.info("{}: success? {}", label, renamed);
Assert.assertTrue(label, renamed);
assertTrue(renamed, label);
return snapshot;
}

Expand Down Expand Up @@ -355,9 +355,9 @@ public static void checkSnapshotCreation(DistributedFileSystem hdfs,
// Compare the snapshot with the current dir
FileStatus[] currentFiles = hdfs.listStatus(snapshottedDir);
FileStatus[] snapshotFiles = hdfs.listStatus(snapshotRoot);
assertEquals("snapshottedDir=" + snapshottedDir
+ ", snapshotRoot=" + snapshotRoot,
currentFiles.length, snapshotFiles.length);
assertEquals(currentFiles.length, snapshotFiles.length,
"snapshottedDir=" + snapshottedDir
+ ", snapshotRoot=" + snapshotRoot);
}

/**
Expand Down Expand Up @@ -449,8 +449,8 @@ private static void compareDumpedTreeInFile(File file1, File file2,
}
assertEquals(line1.trim(), line2.trim());
}
Assert.assertNull(reader1.readLine());
Assert.assertNull(reader2.readLine());
assertNull(reader1.readLine());
assertNull(reader2.readLine());
} finally {
reader1.close();
reader2.close();
Expand Down
Loading