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 @@ -21,7 +21,8 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractAppendTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
import org.junit.Assume;

import static org.junit.jupiter.api.Assumptions.assumeTrue;

/**
* Append test cases on obs file system.
Expand All @@ -35,6 +36,6 @@ protected AbstractFSContract createContract(final Configuration conf) {

@Override
public void testRenameFileBeingAppended() {
Assume.assumeTrue("unsupport.", false);
assumeTrue(false, "unsupport.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.io.File;

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

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.contract.AbstractContractCopyFromLocalTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;

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 All @@ -41,6 +42,7 @@ public abstract class AbstractContractAppendTest extends AbstractFSContractTestB
private Path testPath;
private Path target;

@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import java.util.Map;

import org.assertj.core.api.Assertions;
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 @@ -74,6 +75,7 @@ public abstract class AbstractContractBulkDeleteTest extends AbstractFSContractT
*/
private DynamicWrappedIO dynamicWrappedIO;

@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import org.apache.hadoop.fs.Path;

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 All @@ -44,6 +45,7 @@ public abstract class AbstractContractConcatTest extends AbstractFSContractTestB
private Path zeroByteFile;
private Path target;

@BeforeEach
@Override
public void setup() throws Exception {
super.setup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.hadoop.fs.Path;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

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

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
Expand All @@ -43,6 +44,7 @@ public abstract class AbstractContractCopyFromLocalTest extends
private static final Charset ASCII = StandardCharsets.US_ASCII;
private File file;

@AfterEach
@Override
public void teardown() throws Exception {
super.teardown();
Expand All @@ -65,12 +67,12 @@ public void testCopyFile() throws Throwable {
Path dest = copyFromLocal(file, true);

assertPathExists("uploaded file not found", dest);
assertTrue("source file deleted", Files.exists(file.toPath()));
assertTrue(Files.exists(file.toPath()), "source file deleted");

FileSystem fs = getFileSystem();
FileStatus status = fs.getFileStatus(dest);
assertEquals("File length not equal " + status,
message.getBytes(ASCII).length, status.getLen());
assertEquals(message.getBytes(ASCII).length, status.getLen(),
"File length not equal " + status);
assertFileTextEquals(dest, message);
}

Expand Down Expand Up @@ -109,7 +111,7 @@ public void testSourceIsFileAndDelSrcTrue() throws Throwable {
file = createTempFile("test");
copyFromLocal(file, false, true);

assertFalse("Source file not deleted", Files.exists(file.toPath()));
assertFalse(Files.exists(file.toPath()), "Source file not deleted");
}

@Test
Expand Down Expand Up @@ -215,7 +217,7 @@ public void testSrcIsDirWithDelSrcOptions() throws Throwable {
copyFromLocal(source, false, true);
Path dest = fileToPath(child, source.getParentFile());

assertFalse("Directory not deleted", Files.exists(source.toPath()));
assertFalse(Files.exists(source.toPath()), "Directory not deleted");
assertFileTextEquals(dest, contents);
}

Expand Down Expand Up @@ -258,8 +260,8 @@ public void testCopyDirectoryWithDelete() throws Throwable {
Path dst = path(srcDir.getFileName().toString());
getFileSystem().copyFromLocalFile(true, true, src, dst);

assertFalse("Source directory was not deleted",
Files.exists(srcDir));
assertFalse(Files.exists(srcDir),
"Source directory was not deleted");
}

@Test
Expand Down Expand Up @@ -330,7 +332,7 @@ protected File createTempDirectory(File parent, String name)

private void assertFileTextEquals(Path path, String expected)
throws IOException {
assertEquals("Wrong data in " + path,
expected, IOUtils.toString(getFileSystem().open(path), ASCII));
assertEquals(expected, IOUtils.toString(getFileSystem().open(path), ASCII),
"Wrong data in " + path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.StreamCapabilities;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.AssumptionViolatedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -278,8 +278,8 @@ public void testFileStatusBlocksizeNonEmptyFile() throws Throwable {
FileSystem fs = getFileSystem();

long rootPath = fs.getDefaultBlockSize(path("/"));
assertTrue("Root block size is invalid " + rootPath,
rootPath > 0);
assertTrue(rootPath > 0,
"Root block size is invalid " + rootPath);

Path path = path("testFileStatusBlocksizeNonEmptyFile");
byte[] data = dataset(256, 'a', 'z');
Expand All @@ -303,13 +303,13 @@ private void validateBlockSize(FileSystem fs, Path path, int minValue)
FileStatus status =
getFileStatusEventually(fs, path, CREATE_TIMEOUT);
String statusDetails = status.toString();
assertTrue("File status block size too low: " + statusDetails
+ " min value: " + minValue,
status.getBlockSize() >= minValue);
assertTrue(status.getBlockSize() >= minValue,
"File status block size too low: " + statusDetails
+ " min value: " + minValue);
long defaultBlockSize = fs.getDefaultBlockSize(path);
assertTrue("fs.getDefaultBlockSize(" + path + ") size " +
defaultBlockSize + " is below the minimum of " + minValue,
defaultBlockSize >= minValue);
assertTrue(defaultBlockSize >= minValue,
"fs.getDefaultBlockSize(" + path + ") size " +
defaultBlockSize + " is below the minimum of " + minValue);
}

@Test
Expand All @@ -320,14 +320,14 @@ public void testCreateMakesParentDirs() throws Throwable {
Path parent = new Path(grandparent, "parent");
Path child = new Path(parent, "child");
touch(fs, child);
assertEquals("List status of parent should include the 1 child file",
1, fs.listStatus(parent).length);
assertTrue("Parent directory does not appear to be a directory",
fs.getFileStatus(parent).isDirectory());
assertEquals("List status of grandparent should include the 1 parent dir",
1, fs.listStatus(grandparent).length);
assertTrue("Grandparent directory does not appear to be a directory",
fs.getFileStatus(grandparent).isDirectory());
assertEquals(1, fs.listStatus(parent).length,
"List status of parent should include the 1 child file");
assertTrue(fs.getFileStatus(parent).isDirectory(),
"Parent directory does not appear to be a directory");
assertEquals(1, fs.listStatus(grandparent).length,
"List status of grandparent should include the 1 parent dir");
assertTrue(fs.getFileStatus(grandparent).isDirectory(),
"Grandparent directory does not appear to be a directory");
}

@Test
Expand Down Expand Up @@ -531,8 +531,8 @@ protected void validateSyncableSemantics(final FileSystem fs,
final FileStatus st = fs.getFileStatus(path);
if (metadataUpdatedOnHSync) {
// not all stores reliably update it, HDFS/webHDFS in particular
assertEquals("Metadata not updated during write " + st,
2, st.getLen());
assertEquals(2, st.getLen(),
"Metadata not updated during write " + st);
}

// there's no way to verify durability, but we can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import org.apache.hadoop.fs.Path;

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

import java.io.IOException;

Expand Down Expand Up @@ -49,19 +49,19 @@ public void testDeleteNonexistentPathRecursive() throws Throwable {
Path path = path("testDeleteNonexistentPathRecursive");
assertPathDoesNotExist("leftover", path);
ContractTestUtils.rejectRootOperation(path);
assertFalse("Returned true attempting to recursively delete"
+ " a nonexistent path " + path,
getFileSystem().delete(path, true));
assertFalse(getFileSystem().delete(path, true),
"Returned true attempting to recursively delete"
+ " a nonexistent path " + path);
}

@Test
public void testDeleteNonexistentPathNonRecursive() throws Throwable {
Path path = path("testDeleteNonexistentPathNonRecursive");
assertPathDoesNotExist("leftover", path);
ContractTestUtils.rejectRootOperation(path);
assertFalse("Returned true attempting to non recursively delete"
+ " a nonexistent path " + path,
getFileSystem().delete(path, false));
assertFalse(getFileSystem().delete(path, false),
"Returned true attempting to non recursively delete"
+ " a nonexistent path " + path);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import org.assertj.core.api.Assertions;
import org.junit.Assume;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -36,23 +36,20 @@ public void testEnclosingRootEquivalence() throws IOException {
Path root = path("/");
Path foobar = path("/foo/bar");

assertEquals("Ensure getEnclosingRoot on the root directory returns the root directory",
root, fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot called on itself returns the root directory",
root, fs.getEnclosingRoot(fs.getEnclosingRoot(foobar)));
assertEquals(
assertEquals(root, fs.getEnclosingRoot(foobar),
"Ensure getEnclosingRoot on the root directory returns the root directory");
assertEquals(root, fs.getEnclosingRoot(fs.getEnclosingRoot(foobar)),
"Ensure getEnclosingRoot called on itself returns the root directory");
assertEquals(fs.getEnclosingRoot(root), fs.getEnclosingRoot(foobar),
"Ensure getEnclosingRoot for different paths in the same enclosing root "
+ "returns the same path",
fs.getEnclosingRoot(root), fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot on a path returns the root directory",
root, fs.getEnclosingRoot(methodPath()));
assertEquals("Ensure getEnclosingRoot called on itself on a path returns the root directory",
root, fs.getEnclosingRoot(fs.getEnclosingRoot(methodPath())));
assertEquals(
+ "returns the same path");
assertEquals(root, fs.getEnclosingRoot(methodPath()),
"Ensure getEnclosingRoot on a path returns the root directory");
assertEquals(root, fs.getEnclosingRoot(fs.getEnclosingRoot(methodPath())),
"Ensure getEnclosingRoot called on itself on a path returns the root directory");
assertEquals(fs.getEnclosingRoot(root), fs.getEnclosingRoot(methodPath()),
"Ensure getEnclosingRoot for different paths in the same enclosing root "
+ "returns the same path",
fs.getEnclosingRoot(root),
fs.getEnclosingRoot(methodPath()));
+ "returns the same path");
}


Expand All @@ -63,11 +60,12 @@ public void testEnclosingRootPathExists() throws Exception {
Path foobar = methodPath();
fs.mkdirs(foobar);

assertEquals(
"Ensure getEnclosingRoot returns the root directory when the root directory exists",
root, fs.getEnclosingRoot(foobar));
assertEquals("Ensure getEnclosingRoot returns the root directory when the directory exists",
root, fs.getEnclosingRoot(foobar));
assertEquals(root, fs.getEnclosingRoot(foobar),
"Ensure getEnclosingRoot returns the root directory " +
"when the root directory exists");
assertEquals(root, fs.getEnclosingRoot(foobar),
"Ensure getEnclosingRoot returns the root directory " +
"when the directory exists");
}

@Test
Expand All @@ -77,27 +75,29 @@ public void testEnclosingRootPathDNE() throws Exception {
Path root = path("/");

// .
assertEquals(
"Ensure getEnclosingRoot returns the root directory even when the path does not exist",
root, fs.getEnclosingRoot(foobar));
assertEquals(
"Ensure getEnclosingRoot returns the root directory even when the path does not exist",
root, fs.getEnclosingRoot(methodPath()));
assertEquals(root, fs.getEnclosingRoot(foobar),
"Ensure getEnclosingRoot returns the root directory " +
"even when the path does not exist");
assertEquals(root, fs.getEnclosingRoot(methodPath()),
"Ensure getEnclosingRoot returns the root directory " +
"even when the path does not exist");
}

@Test
public void testEnclosingRootWrapped() throws Exception {
FileSystem fs = getFileSystem();
Path root = path("/");

assertEquals("Ensure getEnclosingRoot returns the root directory when the directory exists",
root, fs.getEnclosingRoot(new Path("/foo/bar")));
assertEquals(root, fs.getEnclosingRoot(new Path("/foo/bar")),
"Ensure getEnclosingRoot returns the root directory " +
"when the directory exists");

UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo");
Path p = ugi.doAs((PrivilegedExceptionAction<Path>) () -> {
FileSystem wFs = getContract().getTestFileSystem();
return wFs.getEnclosingRoot(new Path("/foo/bar"));
});
assertEquals("Ensure getEnclosingRoot works correctly within a wrapped FileSystem", root, p);
assertEquals(root, p, "Ensure getEnclosingRoot works correctly " +
"within a wrapped FileSystem");
}
}
Loading