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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static org.apache.hadoop.fs.contract.ContractTestUtils.assertHasPathCapabilities;
import static org.apache.hadoop.fs.ozone.Constants.LISTING_PAGE_SIZE;
import static org.apache.hadoop.fs.ozone.Constants.OZONE_DEFAULT_USER;
import static org.apache.hadoop.fs.ozone.OzoneFileSystemTests.createKeyWithECReplicationConfiguration;
import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ACL_ENABLED;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE;
Expand Down Expand Up @@ -134,7 +133,7 @@
* Ozone file system tests that are not covered by contract tests.
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
abstract class AbstractOzoneFileSystemTest {
abstract class AbstractOzoneFileSystemTest extends OzoneFileSystemTestBase {

private static final float TRASH_INTERVAL = 0.05f; // 3 seconds

Expand Down Expand Up @@ -250,8 +249,9 @@ public MiniOzoneCluster getCluster() {
return cluster;
}

public FileSystem getFs() {
return fs;
@Override
public OzoneFileSystem getFs() {
return o3fs;
}

public String getBucketName() {
Expand Down Expand Up @@ -411,14 +411,6 @@ private void checkInvalidPath(Path path) {
assertThat(pathException.getMessage()).contains("Invalid path Name");
}

@Test
public void testOzoneFsServiceLoader() throws IOException {
assumeFalse(FILE_SYSTEM_OPTIMIZED.equals(getBucketLayout()));

assertEquals(OzoneFileSystem.class,
FileSystem.getFileSystemClass(OzoneConsts.OZONE_URI_SCHEME, null));
}

@Test
public void testCreateDoesNotAddParentDirKeys() throws Exception {
Path grandparent = new Path("/testCreateDoesNotAddParentDirKeys");
Expand All @@ -444,14 +436,7 @@ public void testCreateDoesNotAddParentDirKeys() throws Exception {
@Test
public void testCreateKeyWithECReplicationConfig() throws Exception {
Path root = new Path("/" + volumeName + "/" + bucketName);
Path testKeyPath = new Path(root, "testKey");
createKeyWithECReplicationConfiguration(cluster.getConf(), testKeyPath);

OzoneKeyDetails key = getKey(testKeyPath, false);
assertEquals(HddsProtos.ReplicationType.EC,
key.getReplicationConfig().getReplicationType());
assertEquals("rs-3-2-1024k",
key.getReplicationConfig().getReplication());
createKeyWithECReplicationConfig(root, cluster.getConf());
}

@Test
Expand Down Expand Up @@ -977,54 +962,7 @@ public void testListStatusOnSubDirs() throws Exception {
*/
@Test
public void testListStatusIteratorWithDir() throws Exception {
Path parent = new Path(ROOT, "testListStatus");
Path file1 = new Path(parent, "key1");
Path file2 = new Path(parent, "key2");
try {
// Iterator should have no items when dir is empty
RemoteIterator<FileStatus> it = o3fs.listStatusIterator(ROOT);
assertFalse(it.hasNext());

ContractTestUtils.touch(fs, file1);
ContractTestUtils.touch(fs, file2);
// Iterator should have an item when dir is not empty
it = o3fs.listStatusIterator(ROOT);
while (it.hasNext()) {
FileStatus fileStatus = it.next();
assertNotNull(fileStatus);
assertEquals(fileStatus.getPath().toUri().getPath(), parent.toString(), "Parent path doesn't match");
}
// Iterator on a directory should return all subdirs along with
// files, even if there exists a file and sub-dir with the same name.
it = o3fs.listStatusIterator(parent);
int iCount = 0;
while (it.hasNext()) {
iCount++;
FileStatus fileStatus = it.next();
assertNotNull(fileStatus);
}
assertEquals(2, iCount, "Iterator did not return all the file status");
// Iterator should return file status for only the
// immediate children of a directory.
Path file3 = new Path(parent, "dir1/key3");
Path file4 = new Path(parent, "dir1/key4");
ContractTestUtils.touch(fs, file3);
ContractTestUtils.touch(fs, file4);
it = o3fs.listStatusIterator(parent);
iCount = 0;

while (it.hasNext()) {
iCount++;
FileStatus fileStatus = it.next();
assertNotNull(fileStatus);
}
assertEquals(3, iCount, "Iterator did not return file status " +
"of all the children of the directory");

} finally {
// Cleanup
fs.delete(parent, true);
}
listStatusIteratorWithDir(ROOT);
}

/**
Expand Down Expand Up @@ -1062,7 +1000,7 @@ public void testListStatusIteratorOnRoot() throws Exception {

@Test
public void testListStatusIteratorOnPageSize() throws Exception {
OzoneFileSystemTests.listStatusIteratorOnPageSize(cluster.getConf(),
listStatusIteratorOnPageSize(cluster.getConf(),
"/" + volumeName + "/" + bucketName);
}

Expand Down Expand Up @@ -1497,7 +1435,8 @@ public void testRenameDir() throws Exception {
assertThat(exception.getMessage()).contains("Wrong FS");
}

private OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
@Override
protected OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
throws IOException {
String key = o3fs.pathToKey(keyPath);
if (isDirectory) {
Expand Down Expand Up @@ -2149,7 +2088,7 @@ public void testOzoneManagerListLocatedStatusForZeroByteFile() throws IOExceptio
String filePath = RandomStringUtils.secure().nextAlphanumeric(5);
Path path = createPath("/" + directory + "/" + filePath);

OzoneFileSystemTests.listLocatedStatusForZeroByteFile(fs, path);
listLocatedStatusForZeroByteFile(fs, path);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.apache.hadoop.fs.FileSystem.TRASH_PREFIX;
import static org.apache.hadoop.fs.contract.ContractTestUtils.assertHasPathCapabilities;
import static org.apache.hadoop.fs.ozone.Constants.LISTING_PAGE_SIZE;
import static org.apache.hadoop.fs.ozone.OzoneFileSystemTests.createKeyWithECReplicationConfiguration;
import static org.apache.hadoop.hdds.client.ECReplicationConfig.EcCodec.RS;
import static org.apache.hadoop.ozone.OzoneAcl.AclScope.ACCESS;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE;
Expand Down Expand Up @@ -144,7 +143,7 @@
* TODO: Refactor this and TestOzoneFileSystem to reduce duplication.
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
abstract class AbstractRootedOzoneFileSystemTest {
abstract class AbstractRootedOzoneFileSystemTest extends OzoneFileSystemTestBase {

private static final Logger LOG = LoggerFactory.getLogger(AbstractRootedOzoneFileSystemTest.class);

Expand Down Expand Up @@ -213,8 +212,9 @@ void cleanup() throws IOException {
fs.delete(volumePath, false);
}

public FileSystem getFs() {
return fs;
@Override
public RootedOzoneFileSystem getFs() {
return ofs;
}

public Path getBucketPath() {
Expand Down Expand Up @@ -278,16 +278,6 @@ protected OMMetrics getOMMetrics() {
return cluster.getOzoneManager().getMetrics();
}

@Test
void testOzoneFsServiceLoader() throws IOException {
assumeFalse(isBucketFSOptimized);

OzoneConfiguration confTestLoader = new OzoneConfiguration();
// fs.ofs.impl should be loaded from META-INF, no need to explicitly set it
assertEquals(FileSystem.getFileSystemClass(
OzoneConsts.OZONE_OFS_URI_SCHEME, confTestLoader), RootedOzoneFileSystem.class);
}

@Test
void testUserHomeDirectory() {
assertEquals(new Path(rootPath + "user/" + USER1),
Expand Down Expand Up @@ -323,15 +313,7 @@ void testCreateDoesNotAddParentDirKeys() throws Exception {

@Test
public void testCreateKeyWithECReplicationConfig() throws Exception {
String testKeyName = "testKey";
Path testKeyPath = new Path(bucketPath, testKeyName);
createKeyWithECReplicationConfiguration(cluster.getConf(), testKeyPath);

OzoneKeyDetails key = getKey(testKeyPath, false);
assertEquals(HddsProtos.ReplicationType.EC,
key.getReplicationConfig().getReplicationType());
assertEquals("rs-3-2-1024k",
key.getReplicationConfig().getReplication());
createKeyWithECReplicationConfig(bucketPath, cluster.getConf());
}

@Test
Expand Down Expand Up @@ -410,7 +392,7 @@ void testListLocatedStatusForZeroByteFile() throws Exception {
Path path = new Path(parent, "key1");

try {
OzoneFileSystemTests.listLocatedStatusForZeroByteFile(fs, path);
listLocatedStatusForZeroByteFile(fs, path);
} finally {
// Cleanup
fs.delete(parent, true);
Expand Down Expand Up @@ -457,51 +439,7 @@ void testListStatus() throws Exception {
*/
@Test
void testListStatusIteratorWithDir() throws Exception {
Path parent = new Path(bucketPath, "testListStatus");
Path file1 = new Path(parent, "key1");
Path file2 = new Path(parent, "key2");
try {
// Iterator should have no items when dir is empty
RemoteIterator<FileStatus> it = ofs.listStatusIterator(bucketPath);
assertFalse(it.hasNext());
ContractTestUtils.touch(fs, file1);
ContractTestUtils.touch(fs, file2);
// Iterator should have an item when dir is not empty
it = ofs.listStatusIterator(bucketPath);
while (it.hasNext()) {
FileStatus fileStatus = it.next();
assertNotNull(fileStatus);
assertEquals(fileStatus.getPath().toUri().getPath(), parent.toString(), "Parent path doesn't match");
}
// Iterator on a directory should return all subdirs along with
// files.
it = ofs.listStatusIterator(parent);
int iCount = 0;
while (it.hasNext()) {
iCount++;
FileStatus fileStatus = it.next();
assertNotNull(fileStatus);
}
assertEquals(2, iCount, "Iterator did not return all the file status");
// Iterator should return file status for only the
// immediate children of a directory.
Path file3 = new Path(parent, "dir1/key3");
Path file4 = new Path(parent, "dir1/key4");
ContractTestUtils.touch(fs, file3);
ContractTestUtils.touch(fs, file4);
it = ofs.listStatusIterator(parent);
iCount = 0;
while (it.hasNext()) {
iCount++;
FileStatus fileStatus = it.next();
assertNotNull(fileStatus);
}
assertEquals(3, iCount, "Iterator did not return file status " +
"of all the children of the directory");
} finally {
// Cleanup
fs.delete(parent, true);
}
listStatusIteratorWithDir(bucketPath);
}

/**
Expand Down Expand Up @@ -556,7 +494,7 @@ void testListStatusIteratorWithPathNotFound() throws Exception {
*/
@Test
void testListStatusIteratorOnPageSize() throws Exception {
OzoneFileSystemTests.listStatusIteratorOnPageSize(conf,
listStatusIteratorOnPageSize(conf,
"/" + volumeName + "/" + bucketName);
}

Expand Down Expand Up @@ -910,7 +848,8 @@ void testRenameToDifferentBucket() throws IOException {
fs.delete(source, true);
}

private OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
@Override
protected OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
throws IOException {
String key = ofs.pathToKey(keyPath);
if (isDirectory) {
Expand Down
Loading