Skip to content

HADOOP-19431. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-distcp Part2. #7747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
import org.apache.hadoop.tools.util.DistCpUtils;
import org.apache.hadoop.tools.util.TestDistCpUtils;
import org.apache.hadoop.security.Credentials;
import org.junit.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.*;
Expand Down Expand Up @@ -82,7 +86,7 @@ private static Job getJobForClient() throws IOException {
return job;
}

@BeforeClass
@BeforeAll
public static void create() throws IOException {
clusterConfig = getJobForClient().getConfiguration();
clusterConfig.setLong(
Expand All @@ -97,27 +101,27 @@ public static void create() throws IOException {
.build();
}

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

@Before
@BeforeEach
public void createMetaFolder() throws IOException {
config = new Configuration(clusterConfig);
config.set(DistCpConstants.CONF_LABEL_META_FOLDER, "/meta");
Path meta = new Path("/meta");
cluster.getFileSystem().mkdirs(meta);
}

@After
@AfterEach
public void cleanupMetaFolder() throws IOException {
Path meta = new Path("/meta");
if (cluster.getFileSystem().exists(meta)) {
cluster.getFileSystem().delete(meta, true);
Assert.fail("Expected meta folder to be deleted");
fail("Expected meta folder to be deleted");
}
}

Expand All @@ -129,11 +133,11 @@ public void testNoCommitAction() throws IOException {
taskAttemptContext.getTaskAttemptID().getJobID());
OutputCommitter committer = new CopyCommitter(null, taskAttemptContext);
committer.commitJob(jobContext);
Assert.assertEquals("Commit Successful", taskAttemptContext.getStatus());
assertEquals("Commit Successful", taskAttemptContext.getStatus());

//Test for idempotent commit
committer.commitJob(jobContext);
Assert.assertEquals("Commit Successful", taskAttemptContext.getStatus());
assertEquals("Commit Successful", taskAttemptContext.getStatus());
}

@Test
Expand Down Expand Up @@ -412,12 +416,12 @@ public void testDeleteMissingFlatInterleavedFiles() throws IOException {

committer.commitJob(jobContext);
verifyFoldersAreInSync(fs, targetBase, sourceBase);
Assert.assertEquals(4, fs.listStatus(new Path(targetBase)).length);
assertEquals(4, fs.listStatus(new Path(targetBase)).length);

//Test for idempotent commit
committer.commitJob(jobContext);
verifyFoldersAreInSync(fs, targetBase, sourceBase);
Assert.assertEquals(4, fs.listStatus(new Path(targetBase)).length);
assertEquals(4, fs.listStatus(new Path(targetBase)).length);
} finally {
TestDistCpUtils.delete(fs, "/tmp1");
conf.set(DistCpConstants.CONF_LABEL_DELETE_MISSING, "false");
Expand Down Expand Up @@ -486,7 +490,7 @@ public void testAtomicCommitExistingFinal() throws IOException {
assertPathExists(fs, "Final path", new Path(finalPath));
try {
committer.commitJob(jobContext);
Assert.fail("Should not be able to atomic-commit to pre-existing path.");
fail("Should not be able to atomic-commit to pre-existing path.");
} catch(Exception exception) {
assertPathExists(fs, "Work path", new Path(workPath));
assertPathExists(fs, "Final path", new Path(finalPath));
Expand Down Expand Up @@ -558,17 +562,17 @@ private void testCommitWithChecksumMismatch(boolean skipCrc)
try {
committer.commitJob(jobContext);
if (!skipCrc) {
Assert.fail("Expected commit to fail");
fail("Expected commit to fail");
}
Path sourcePath = new Path(sourceBase + srcFilename);
CopyListingFileStatus sourceCurrStatus =
new CopyListingFileStatus(fs.getFileStatus(sourcePath));
Assert.assertEquals("Checksum should not be equal",
CopyMapper.ChecksumComparison.FALSE,
new CopyListingFileStatus(fs.getFileStatus(sourcePath));
assertEquals(CopyMapper.ChecksumComparison.FALSE,
DistCpUtils.checksumsAreEqual(
fs, new Path(sourceBase + srcFilename), null,
fs, new Path(targetBase + srcFilename),
sourceCurrStatus.getLen()));
sourceCurrStatus.getLen()),
"Checksum should not be equal");
} catch(IOException exception) {
if (skipCrc) {
LOG.error("Unexpected exception is found", exception);
Expand Down Expand Up @@ -729,7 +733,7 @@ private void checkDirectoryPermissions(FileSystem fs, String targetBase,
for (FileStatus status : fStatus) {
if (status.isDirectory()) {
stack.push(status.getPath());
Assert.assertEquals(sourcePerm, status.getPermission());
assertEquals(sourcePerm, status.getPermission());
}
}
}
Expand All @@ -746,10 +750,10 @@ private void checkDirectoryTimes(
while (sourceReader.next(srcRelPath, srcFileStatus)) {
Path targetFile = new Path(targetRoot.toString() + "/" + srcRelPath);
FileStatus targetStatus = fs.getFileStatus(targetFile);
Assert.assertEquals(srcFileStatus.getModificationTime(),
targetStatus.getModificationTime());
Assert.assertEquals(srcFileStatus.getAccessTime(),
targetStatus.getAccessTime());
assertEquals(srcFileStatus.getModificationTime(),
targetStatus.getModificationTime());
assertEquals(srcFileStatus.getAccessTime(),
targetStatus.getAccessTime());
}
} finally {
IOUtils.closeStream(sourceReader);
Expand Down