Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 0 additions & 5 deletions hadoop-hdfs-project/hadoop-hdfs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
</exclusions>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-minikdc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

package org.apache.hadoop;

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 org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
Expand All @@ -29,11 +29,11 @@

import org.apache.hadoop.ipc.RefreshRegistry;
import org.apache.hadoop.ipc.RefreshResponse;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterAll;
import org.mockito.Mockito;

/**
Expand All @@ -49,7 +49,7 @@ public class TestGenericRefresh {
private static RefreshHandler firstHandler;
private static RefreshHandler secondHandler;

@BeforeClass
@BeforeAll
public static void setUpBeforeClass() throws Exception {
config = new Configuration();
config.set("hadoop.security.authorization", "true");
Expand All @@ -59,14 +59,14 @@ public static void setUpBeforeClass() throws Exception {
cluster.waitActive();
}

@AfterClass
@AfterAll
public static void tearDownBeforeClass() throws Exception {
if (cluster != null) {
cluster.shutdown();
}
}

@Before
@BeforeEach
public void setUp() throws Exception {
// Register Handlers, first one just sends an ok response
firstHandler = Mockito.mock(RefreshHandler.class);
Expand All @@ -83,7 +83,7 @@ public void setUp() throws Exception {
RefreshRegistry.defaultRegistry().register("secondHandler", secondHandler);
}

@After
@AfterEach
public void tearDown() throws Exception {
RefreshRegistry.defaultRegistry().unregisterAll("firstHandler");
RefreshRegistry.defaultRegistry().unregisterAll("secondHandler");
Expand All @@ -94,7 +94,7 @@ public void testInvalidCommand() throws Exception {
DFSAdmin admin = new DFSAdmin(config);
String [] args = new String[]{"-refresh", "nn"};
int exitCode = admin.run(args);
assertEquals("DFSAdmin should fail due to bad args", -1, exitCode);
assertEquals(-1, exitCode, "DFSAdmin should fail due to bad args");
}

@Test
Expand All @@ -103,7 +103,7 @@ public void testInvalidIdentifier() throws Exception {
String [] args = new String[]{"-refresh", "localhost:" +
cluster.getNameNodePort(), "unregisteredIdentity"};
int exitCode = admin.run(args);
assertEquals("DFSAdmin should fail due to no handler registered", -1, exitCode);
assertEquals(-1, exitCode, "DFSAdmin should fail due to no handler registered");
}

@Test
Expand All @@ -112,7 +112,7 @@ public void testValidIdentifier() throws Exception {
String[] args = new String[]{"-refresh",
"localhost:" + cluster.getNameNodePort(), "firstHandler"};
int exitCode = admin.run(args);
assertEquals("DFSAdmin should succeed", 0, exitCode);
assertEquals(0, exitCode, "DFSAdmin should succeed");

Mockito.verify(firstHandler).handleRefresh("firstHandler", new String[]{});
// Second handler was never called
Expand All @@ -126,11 +126,11 @@ public void testVariableArgs() throws Exception {
String[] args = new String[]{"-refresh", "localhost:" +
cluster.getNameNodePort(), "secondHandler", "one"};
int exitCode = admin.run(args);
assertEquals("DFSAdmin should return 2", 2, exitCode);
assertEquals(2, exitCode, "DFSAdmin should return 2");

exitCode = admin.run(new String[]{"-refresh", "localhost:" +
cluster.getNameNodePort(), "secondHandler", "one", "two"});
assertEquals("DFSAdmin should now return 3", 3, exitCode);
assertEquals(3, exitCode, "DFSAdmin should now return 3");

Mockito.verify(secondHandler).handleRefresh("secondHandler", new String[]{"one"});
Mockito.verify(secondHandler).handleRefresh("secondHandler", new String[]{"one", "two"});
Expand All @@ -145,7 +145,7 @@ public void testUnregistration() throws Exception {
String[] args = new String[]{"-refresh", "localhost:" +
cluster.getNameNodePort(), "firstHandler"};
int exitCode = admin.run(args);
assertEquals("DFSAdmin should return -1", -1, exitCode);
assertEquals(-1, exitCode, "DFSAdmin should return -1");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

package org.apache.hadoop;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
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.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.net.BindException;
Expand All @@ -40,8 +40,8 @@
import org.apache.hadoop.ipc.FairCallQueue;
import org.apache.hadoop.metrics2.MetricsException;
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;

public class TestRefreshCallQueue {
private MiniDFSCluster cluster;
Expand Down Expand Up @@ -77,7 +77,7 @@ private void setUp(Class<?> queueClass) throws IOException {
}
}

@After
@AfterEach
public void tearDown() throws IOException {
if (cluster != null) {
cluster.shutdown();
Expand Down Expand Up @@ -115,23 +115,21 @@ public void testRefresh() throws Exception {
mockQueuePuts = 0;
setUp(MockCallQueue.class);

assertTrue("Mock queue should have been constructed",
mockQueueConstructions > 0);
assertTrue("Puts are routed through MockQueue", canPutInMockQueue());
assertTrue(mockQueueConstructions > 0, "Mock queue should have been constructed");
assertTrue(canPutInMockQueue(), "Puts are routed through MockQueue");
int lastMockQueueConstructions = mockQueueConstructions;

// Replace queue with the queue specified in core-site.xml, which would be
// the LinkedBlockingQueue
DFSAdmin admin = new DFSAdmin(config);
String [] args = new String[]{"-refreshCallQueue"};
int exitCode = admin.run(args);
assertEquals("DFSAdmin should return 0", 0, exitCode);
assertEquals(0, exitCode, "DFSAdmin should return 0");

assertEquals("Mock queue should have no additional constructions",
lastMockQueueConstructions, mockQueueConstructions);
assertEquals(lastMockQueueConstructions, mockQueueConstructions,
"Mock queue should have no additional constructions");
try {
assertFalse("Puts are routed through LBQ instead of MockQueue",
canPutInMockQueue());
assertFalse(canPutInMockQueue(), "Puts are routed through LBQ instead of MockQueue");
} catch (IOException ioe) {
fail("Could not put into queue at all");
}
Expand All @@ -149,8 +147,9 @@ public void testRefreshCallQueueWithFairCallQueue() throws Exception {
DFSConfigKeys.DFS_NAMENODE_SERVICE_HANDLER_COUNT_DEFAULT);
NameNodeRpcServer rpcServer = (NameNodeRpcServer) cluster.getNameNodeRpc();
// check callqueue size
assertEquals(CommonConfigurationKeys.IPC_SERVER_HANDLER_QUEUE_SIZE_DEFAULT
* serviceHandlerCount, rpcServer.getClientRpcServer().getMaxQueueSize());
assertEquals(
CommonConfigurationKeys.IPC_SERVER_HANDLER_QUEUE_SIZE_DEFAULT * serviceHandlerCount,
rpcServer.getClientRpcServer().getMaxQueueSize());
// Replace queue and update queue size
config.setInt(CommonConfigurationKeys.IPC_SERVER_HANDLER_QUEUE_SIZE_KEY,
150);
Expand All @@ -170,8 +169,7 @@ public void testRefreshCallQueueWithFairCallQueue() throws Exception {
DefaultMetricsSystem.setMiniClusterMode(oldValue);
}
// check callQueueSize has changed
assertEquals(150 * serviceHandlerCount, rpcServer.getClientRpcServer()
.getMaxQueueSize());
assertEquals(150 * serviceHandlerCount, rpcServer.getClientRpcServer().getMaxQueueSize());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.MiniDFSCluster;
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;

public class TestAclCLI extends CLITestHelperDFS {
private MiniDFSCluster cluster = null;
Expand All @@ -38,7 +38,7 @@ protected void initConf() {
DFSConfigKeys.DFS_NAMENODE_POSIX_ACL_INHERITANCE_ENABLED_KEY, false);
}

@Before
@BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
Expand All @@ -49,7 +49,7 @@ public void setUp() throws Exception {
username = System.getProperty("user.name");
}

@After
@AfterEach
@Override
public void tearDown() throws Exception {
super.tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_POSIX_ACL_INHERITANCE_ENABLED_KEY;

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

/**
* Test ACL CLI with POSIX ACL inheritance enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.cli;

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

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -37,9 +37,9 @@
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.hdfs.tools.CacheAdmin;
import org.apache.hadoop.security.authorize.PolicyProvider;
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.xml.sax.SAXException;

public class TestCacheAdminCLI extends CLITestHelper {
Expand All @@ -51,7 +51,7 @@ public class TestCacheAdminCLI extends CLITestHelper {
protected FileSystem fs = null;
protected String namenode = null;

@Before
@BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
Expand All @@ -68,11 +68,10 @@ public void setUp() throws Exception {
username = System.getProperty("user.name");

fs = dfsCluster.getFileSystem();
assertTrue("Not a HDFS: "+fs.getUri(),
fs instanceof DistributedFileSystem);
assertTrue(fs instanceof DistributedFileSystem, "Not a HDFS: " + fs.getUri());
}

@After
@AfterEach
@Override
public void tearDown() throws Exception {
if (fs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.security.NoSuchAlgorithmException;
import java.util.UUID;

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

import org.apache.hadoop.cli.util.CLICommand;
import org.apache.hadoop.cli.util.CLICommandCryptoAdmin;
Expand All @@ -45,9 +45,9 @@
import org.apache.hadoop.hdfs.tools.CryptoAdmin;
import org.apache.hadoop.security.authorize.PolicyProvider;
import org.apache.hadoop.test.GenericTestUtils;
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.xml.sax.SAXException;

public class TestCryptoAdminCLI extends CLITestHelperDFS {
Expand All @@ -56,7 +56,7 @@ public class TestCryptoAdminCLI extends CLITestHelperDFS {
protected String namenode = null;
private static File tmpDir;

@Before
@BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
Expand All @@ -78,11 +78,11 @@ public void setUp() throws Exception {
username = System.getProperty("user.name");

fs = dfsCluster.getFileSystem();
assertTrue("Not an HDFS: " + fs.getUri(),
fs instanceof DistributedFileSystem);
assertTrue(fs instanceof DistributedFileSystem,
"Not an HDFS: " + fs.getUri());
}

@After
@AfterEach
@Override
public void tearDown() throws Exception {
if (fs != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.hadoop.cli;

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

import org.apache.hadoop.cli.util.CLICommand;
import org.apache.hadoop.cli.util.CommandExecutor.Result;
Expand All @@ -27,16 +27,16 @@
import org.apache.hadoop.hdfs.DFSConfigKeys;
import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.hdfs.MiniDFSCluster;
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;

public class TestDeleteCLI extends CLITestHelperDFS {
protected MiniDFSCluster dfsCluster = null;
protected FileSystem fs = null;
protected String namenode = null;

@Before
@BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
Expand All @@ -49,11 +49,11 @@ public void setUp() throws Exception {
namenode = conf.get(DFSConfigKeys.FS_DEFAULT_NAME_KEY, "file:///");

fs = dfsCluster.getFileSystem();
assertTrue("Not an HDFS: " + fs.getUri(),
fs instanceof DistributedFileSystem);
assertTrue(fs instanceof DistributedFileSystem,
"Not an HDFS: " + fs.getUri());
}

@After
@AfterEach
@Override
public void tearDown() throws Exception {
if (fs != null) {
Expand Down
Loading