Skip to content

Commit

Permalink
Merge branch 'apache:trunk' into HADOOP-19415-PART6
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 authored Feb 13, 2025
2 parents 77cf275 + 19bd575 commit 6712621
Show file tree
Hide file tree
Showing 110 changed files with 1,413 additions and 1,326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.TextOutputFormat;
import org.apache.hadoop.mapred.Utils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.BufferedReader;
import java.io.IOException;
Expand All @@ -39,8 +39,10 @@
import java.io.OutputStreamWriter;
import java.io.Writer;

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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* This testcase tests that a JobConf without default values submits jobs
Expand All @@ -56,10 +58,10 @@ public TestNoDefaultsJobConf() throws IOException {
@Test
public void testNoDefaults() throws Exception {
JobConf configuration = new JobConf();
assertTrue(configuration.get("hadoop.tmp.dir", null) != null);
assertNotNull(configuration.get("hadoop.tmp.dir", null));

configuration = new JobConf(false);
assertTrue(configuration.get("hadoop.tmp.dir", null) == null);
assertNull(configuration.get("hadoop.tmp.dir", null));


Path inDir = new Path("testing/jobconf/input");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.SequenceFile.CompressionType;
import org.apache.hadoop.mapred.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -66,7 +66,7 @@
* <li>standard i/o rate deviation</li>
* </ul>
*/
@Ignore
@Disabled
public class DFSCIOTest {
// Constants
private static final Logger LOG = LoggerFactory.getLogger(DFSCIOTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -226,7 +227,7 @@ private static Path getDataDir(Configuration conf) {
private static MiniDFSCluster cluster;
private static TestDFSIO bench;

@BeforeClass
@BeforeAll
public static void beforeClass() throws Exception {
bench = new TestDFSIO();
bench.getConf().setInt(DFSConfigKeys.DFS_HEARTBEAT_INTERVAL_KEY, 1);
Expand All @@ -241,7 +242,7 @@ public static void beforeClass() throws Exception {
testWrite();
}

@AfterClass
@AfterAll
public static void afterClass() throws Exception {
if(cluster == null)
return;
Expand All @@ -256,45 +257,51 @@ public static void testWrite() throws Exception {
bench.analyzeResult(fs, TestType.TEST_TYPE_WRITE, execTime);
}

@Test (timeout = 10000)
@Test
@Timeout(value = 10)
public void testRead() throws Exception {
FileSystem fs = cluster.getFileSystem();
long execTime = bench.readTest(fs);
bench.analyzeResult(fs, TestType.TEST_TYPE_READ, execTime);
}

@Test (timeout = 10000)
@Test
@Timeout(value = 10)
public void testReadRandom() throws Exception {
FileSystem fs = cluster.getFileSystem();
bench.getConf().setLong("test.io.skip.size", 0);
long execTime = bench.randomReadTest(fs);
bench.analyzeResult(fs, TestType.TEST_TYPE_READ_RANDOM, execTime);
}

@Test (timeout = 10000)
@Test
@Timeout(value = 10)
public void testReadBackward() throws Exception {
FileSystem fs = cluster.getFileSystem();
bench.getConf().setLong("test.io.skip.size", -DEFAULT_BUFFER_SIZE);
long execTime = bench.randomReadTest(fs);
bench.analyzeResult(fs, TestType.TEST_TYPE_READ_BACKWARD, execTime);
}

@Test (timeout = 10000)
@Test
@Timeout(value = 10)
public void testReadSkip() throws Exception {
FileSystem fs = cluster.getFileSystem();
bench.getConf().setLong("test.io.skip.size", 1);
long execTime = bench.randomReadTest(fs);
bench.analyzeResult(fs, TestType.TEST_TYPE_READ_SKIP, execTime);
}

@Test (timeout = 10000)
@Test
@Timeout(value = 10)
public void testAppend() throws Exception {
FileSystem fs = cluster.getFileSystem();
long execTime = bench.appendTest(fs);
bench.analyzeResult(fs, TestType.TEST_TYPE_APPEND, execTime);
}

@Test (timeout = 60000)
@Test
@Timeout(value = 60)
public void testTruncate() throws Exception {
FileSystem fs = cluster.getFileSystem();
bench.createControlFile(fs, DEFAULT_NR_BYTES / 2, DEFAULT_NR_FILES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@
import org.apache.hadoop.mapred.lib.LongSumReducer;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.StringUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;


public class TestFileSystem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import java.io.OutputStreamWriter;
import java.io.File;

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.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -40,7 +40,7 @@ public class TestJHLA {
private String historyLog = System.getProperty("test.build.data",
"build/test/data") + "/history/test.log";

@Before
@BeforeEach
public void setUp() throws Exception {
File logFile = new File(historyLog);
if(!logFile.getParentFile().exists())
Expand Down Expand Up @@ -121,7 +121,7 @@ public void setUp() throws Exception {
writer.close();
}

@After
@AfterEach
public void tearDown() throws Exception {
File logFile = new File(historyLog);
if(!logFile.delete())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package org.apache.hadoop.fs.slive;

import static org.assertj.core.api.Assertions.assertThat;
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 All @@ -40,8 +40,8 @@
import org.apache.hadoop.fs.slive.DataVerifier.VerifyOutput;
import org.apache.hadoop.fs.slive.DataWriter.GenerateOutput;
import org.apache.hadoop.util.ToolRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -194,7 +194,7 @@ private ConfigExtractor getTestConfig(boolean sleep) throws Exception {
return extractor;
}

@Before
@BeforeEach
public void ensureDeleted() throws Exception {
rDelete(getTestFile());
rDelete(getTestDir());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
package org.apache.hadoop.hdfs;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
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 java.io.File;
import java.io.IOException;
Expand All @@ -31,8 +31,9 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.util.Time;
import org.apache.hadoop.util.ToolRunner;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

public class TestNNBench extends HadoopTestCase {
private static final String BASE_DIR =
Expand All @@ -45,39 +46,39 @@ public TestNNBench() throws IOException {
super(LOCAL_MR, LOCAL_FS, 1, 1);
}

@After
@AfterEach
public void tearDown() throws Exception {
getFileSystem().delete(new Path(BASE_DIR), true);
getFileSystem().delete(new Path(NNBench.DEFAULT_RES_FILE_NAME), true);
super.tearDown();
}

@Test(timeout = 30000)
@Test
@Timeout(value = 30)
public void testNNBenchCreateReadAndDelete() throws Exception {
runNNBench(createJobConf(), "create_write");
Path path = new Path(BASE_DIR + "/data/file_0_0");
assertTrue("create_write should create the file",
getFileSystem().exists(path));
assertTrue(getFileSystem().exists(path), "create_write should create the file");
runNNBench(createJobConf(), "open_read");
runNNBench(createJobConf(), "delete");
assertFalse("Delete operation should delete the file",
getFileSystem().exists(path));
assertFalse(getFileSystem().exists(path),
"Delete operation should delete the file");
}

@Test(timeout = 30000)
@Test
@Timeout(value = 30)
public void testNNBenchCreateAndRename() throws Exception {
runNNBench(createJobConf(), "create_write");
Path path = new Path(BASE_DIR + "/data/file_0_0");
assertTrue("create_write should create the file",
getFileSystem().exists(path));
assertTrue(getFileSystem().exists(path), "create_write should create the file");
runNNBench(createJobConf(), "rename");
Path renamedPath = new Path(BASE_DIR + "/data/file_0_r_0");
assertFalse("Rename should rename the file", getFileSystem().exists(path));
assertTrue("Rename should rename the file",
getFileSystem().exists(renamedPath));
assertFalse(getFileSystem().exists(path), "Rename should rename the file");
assertTrue(getFileSystem().exists(renamedPath), "Rename should rename the file");
}

@Test(timeout = 30000)
@Test
@Timeout(value = 30)
public void testNNBenchCreateControlFilesWithPool() throws Exception {
runNNBench(createJobConf(), "create_write", BASE_DIR, "5");
Path path = new Path(BASE_DIR, CONTROL_DIR_NAME);
Expand All @@ -86,7 +87,8 @@ public void testNNBenchCreateControlFilesWithPool() throws Exception {
assertEquals(5, fileStatuses.length);
}

@Test(timeout = 30000)
@Test
@Timeout(value = 30)
public void testNNBenchCrossCluster() throws Exception {
MiniDFSCluster dfsCluster = new MiniDFSCluster.Builder(new JobConf())
.numDataNodes(1).build();
Expand All @@ -96,8 +98,8 @@ public void testNNBenchCrossCluster() throws Exception {
runNNBench(createJobConf(), "create_write", baseDir);

Path path = new Path(BASE_DIR + "/data/file_0_0");
assertTrue("create_write should create the file",
dfsCluster.getFileSystem().exists(path));
assertTrue(dfsCluster.getFileSystem().exists(path),
"create_write should create the file");
dfsCluster.shutdown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.apache.hadoop.mapred.*;

import org.slf4j.Logger;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestSequenceFileMergeProgress {
private static final Logger LOG = FileInputFormat.LOG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
import org.apache.hadoop.net.StandardSocketFactory;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

/**
* This class checks that RPCs can use specialized socket factories.
Expand All @@ -56,13 +58,13 @@ public void testSocketFactory() throws IOException {

// Get a reference to its DFS directly
FileSystem fs = cluster.getFileSystem();
Assert.assertTrue(fs instanceof DistributedFileSystem);
assertTrue(fs instanceof DistributedFileSystem);
DistributedFileSystem directDfs = (DistributedFileSystem) fs;

Configuration cconf = getCustomSocketConfigs(nameNodePort);

fs = FileSystem.get(cconf);
Assert.assertTrue(fs instanceof DistributedFileSystem);
assertTrue(fs instanceof DistributedFileSystem);
DistributedFileSystem dfs = (DistributedFileSystem) fs;

JobClient client = null;
Expand All @@ -72,12 +74,12 @@ public void testSocketFactory() throws IOException {
// could we test Client-DataNode connections?
Path filePath = new Path("/dir");

Assert.assertFalse(directDfs.exists(filePath));
Assert.assertFalse(dfs.exists(filePath));
assertFalse(directDfs.exists(filePath));
assertFalse(dfs.exists(filePath));

directDfs.mkdirs(filePath);
Assert.assertTrue(directDfs.exists(filePath));
Assert.assertTrue(dfs.exists(filePath));
assertTrue(directDfs.exists(filePath));
assertTrue(dfs.exists(filePath));

// This will test RPC to a Resource Manager
fs = FileSystem.get(sconf);
Expand All @@ -95,7 +97,7 @@ public void testSocketFactory() throws IOException {
client = new JobClient(jconf);

JobStatus[] jobs = client.jobsToComplete();
Assert.assertTrue(jobs.length == 0);
assertTrue(jobs.length == 0);

} finally {
closeClient(client);
Expand Down
Loading

0 comments on commit 6712621

Please sign in to comment.