This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new c9b052ad15d HDDS-14608. Convert OzoneFileSystemTests to abstract class 
(#9750)
c9b052ad15d is described below

commit c9b052ad15d9ae347c6045a9f7ed6f3951958ad8
Author: len548 <[email protected]>
AuthorDate: Thu Feb 19 10:39:01 2026 +0100

    HDDS-14608. Convert OzoneFileSystemTests to abstract class (#9750)
---
 .../fs/ozone/AbstractOzoneFileSystemTest.java      |  81 +++--------------
 .../ozone/AbstractRootedOzoneFileSystemTest.java   |  81 +++--------------
 ...stemTests.java => OzoneFileSystemTestBase.java} | 100 +++++++++++++++------
 .../hadoop/fs/ozone/OzoneFileSystemTestUtils.java  |  47 ++++++++++
 .../ozone/freon/TestHadoopDirTreeGenerator.java    |   4 +-
 5 files changed, 143 insertions(+), 170 deletions(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
index 4a4d744446c..931b2eb81ab 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
@@ -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;
@@ -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
 
@@ -250,8 +249,9 @@ public MiniOzoneCluster getCluster() {
     return cluster;
   }
 
-  public FileSystem getFs() {
-    return fs;
+  @Override
+  public OzoneFileSystem getFs() {
+    return o3fs;
   }
 
   public String getBucketName() {
@@ -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");
@@ -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
@@ -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);
   }
 
   /**
@@ -1062,7 +1000,7 @@ public void testListStatusIteratorOnRoot() throws 
Exception {
 
   @Test
   public void testListStatusIteratorOnPageSize() throws Exception {
-    OzoneFileSystemTests.listStatusIteratorOnPageSize(cluster.getConf(),
+    listStatusIteratorOnPageSize(cluster.getConf(),
         "/" + volumeName + "/" + bucketName);
   }
 
@@ -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) {
@@ -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
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
index ae04aca3564..e03327632a2 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
@@ -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;
@@ -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);
 
@@ -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() {
@@ -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),
@@ -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
@@ -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);
@@ -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);
   }
 
   /**
@@ -556,7 +494,7 @@ void testListStatusIteratorWithPathNotFound() throws 
Exception {
    */
   @Test
   void testListStatusIteratorOnPageSize() throws Exception {
-    OzoneFileSystemTests.listStatusIteratorOnPageSize(conf,
+    listStatusIteratorOnPageSize(conf,
         "/" + volumeName + "/" + bucketName);
   }
 
@@ -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) {
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTests.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestBase.java
similarity index 61%
rename from 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTests.java
rename to 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestBase.java
index b4fa56fc79f..807dbc2b8dd 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTests.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestBase.java
@@ -17,11 +17,8 @@
 
 package org.apache.hadoop.fs.ozone;
 
-import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_LISTING_PAGE_SIZE;
 import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_REPLICATION;
 import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_REPLICATION_TYPE;
-import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
-import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -39,35 +36,19 @@
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.RemoteIterator;
 import org.apache.hadoop.fs.contract.ContractTestUtils;
-import org.apache.hadoop.hdds.conf.ConfigurationTarget;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.ratis.util.Preconditions;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.ozone.client.OzoneKeyDetails;
 
 /**
  * Common test cases for Ozone file systems.
  */
-public final class OzoneFileSystemTests {
-
-  private OzoneFileSystemTests() {
-    // no instances
-  }
-
-  /**
-   * Set file system listing page size.  Also disable the file system cache to
-   * ensure new {@link FileSystem} instance reflects the updated page size.
-   */
-  public static void setPageSize(ConfigurationTarget conf, int pageSize) {
-    Preconditions.assertTrue(pageSize > 0, () -> "pageSize=" + pageSize + " <= 
0");
-    conf.setInt(OZONE_FS_LISTING_PAGE_SIZE, pageSize);
-    conf.setBoolean(String.format("fs.%s.impl.disable.cache", 
OZONE_URI_SCHEME), true);
-    conf.setBoolean(String.format("fs.%s.impl.disable.cache", 
OZONE_OFS_URI_SCHEME), true);
-  }
-
+public abstract class OzoneFileSystemTestBase {
   /**
    * Tests listStatusIterator operation on directory with different
    * numbers of child directories.
    */
-  public static void listStatusIteratorOnPageSize(OzoneConfiguration conf,
+  static void listStatusIteratorOnPageSize(OzoneConfiguration conf,
       String rootPath) throws IOException {
     final int pageSize = 32;
     int[] dirCounts = {
@@ -79,7 +60,7 @@ public static void 
listStatusIteratorOnPageSize(OzoneConfiguration conf,
         pageSize + pageSize
     };
     OzoneConfiguration config = new OzoneConfiguration(conf);
-    setPageSize(config, pageSize);
+    OzoneFileSystemTestUtils.setPageSize(config, pageSize);
     URI uri = FileSystem.getDefaultUri(config);
     try (FileSystem subject = FileSystem.get(uri, config)) {
       Path dir = new Path(Objects.requireNonNull(rootPath),
@@ -117,7 +98,7 @@ private static void listStatusIterator(FileSystem subject,
     assertEquals(total, iCount);
   }
 
-  static void createKeyWithECReplicationConfiguration(OzoneConfiguration 
inputConf, Path keyPath)
+  private void createKeyWithECReplicationConfiguration(OzoneConfiguration 
inputConf, Path keyPath)
       throws IOException {
     OzoneConfiguration conf = new OzoneConfiguration(inputConf);
     conf.set(OZONE_REPLICATION, "rs-3-2-1024k");
@@ -130,7 +111,7 @@ static void 
createKeyWithECReplicationConfiguration(OzoneConfiguration inputConf
     }
   }
 
-  public static void listLocatedStatusForZeroByteFile(FileSystem fs, Path 
path) throws IOException {
+  static void listLocatedStatusForZeroByteFile(FileSystem fs, Path path) 
throws IOException {
     // create empty file
     ContractTestUtils.touch(fs, path);
 
@@ -162,4 +143,71 @@ public static void 
listLocatedStatusForZeroByteFile(FileSystem fs, Path path) th
     assertEquals(1, fileStatuses.length);
     assertFalse(fileStatuses[0] instanceof LocatedFileStatus);
   }
+
+  void createKeyWithECReplicationConfig(Path root, OzoneConfiguration conf) 
throws IOException {
+    Path testKeyPath = new Path(root, "testKey");
+    createKeyWithECReplicationConfiguration(conf, testKeyPath);
+
+    OzoneKeyDetails key = getKey(testKeyPath, false);
+    assertEquals(HddsProtos.ReplicationType.EC,
+        key.getReplicationConfig().getReplicationType());
+    assertEquals("rs-3-2-1024k",
+        key.getReplicationConfig().getReplication());
+  }
+
+  void listStatusIteratorWithDir(Path root) throws Exception {
+    Path parent = new Path(root, "testListStatus");
+    Path file1 = new Path(parent, "key1");
+    Path file2 = new Path(parent, "key2");
+    FileSystem fs = getFs();
+    try {
+      // Iterator should have no items when dir is empty
+      RemoteIterator<FileStatus> it = fs.listStatusIterator(root);
+      assertFalse(it.hasNext());
+
+      ContractTestUtils.touch(fs, file1);
+      ContractTestUtils.touch(fs, file2);
+      // Iterator should have an item when dir is not empty
+      it = fs.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 = fs.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 = fs.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);
+    }
+  }
+
+  abstract OzoneKeyDetails getKey(Path keyPath, boolean isDirectory) throws 
IOException;
+
+  abstract FileSystem getFs();
 }
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestUtils.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestUtils.java
new file mode 100644
index 00000000000..83d3557a96d
--- /dev/null
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/OzoneFileSystemTestUtils.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.fs.ozone;
+
+import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_LISTING_PAGE_SIZE;
+import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
+import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_SCHEME;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.hdds.conf.ConfigurationTarget;
+import org.apache.ratis.util.Preconditions;
+
+/**
+ * Utility methods for Ozone file system tests.
+ */
+public final class OzoneFileSystemTestUtils {
+
+  private OzoneFileSystemTestUtils() {
+    // no instances
+  }
+
+  /**
+   * Set file system listing page size.  Also disable the file system cache to
+   * ensure new {@link FileSystem} instance reflects the updated page size.
+   */
+  public static void setPageSize(ConfigurationTarget conf, int pageSize) {
+    Preconditions.assertTrue(pageSize > 0, () -> "pageSize=" + pageSize + " <= 
0");
+    conf.setInt(OZONE_FS_LISTING_PAGE_SIZE, pageSize);
+    conf.setBoolean(String.format("fs.%s.impl.disable.cache", 
OZONE_URI_SCHEME), true);
+    conf.setBoolean(String.format("fs.%s.impl.disable.cache", 
OZONE_OFS_URI_SCHEME), true);
+  }
+}
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
index 483107af462..7bc95274f55 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestHadoopDirTreeGenerator.java
@@ -32,7 +32,7 @@
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.ozone.OzoneFileSystemTests;
+import org.apache.hadoop.fs.ozone.OzoneFileSystemTestUtils;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.conf.StorageSize;
 import org.apache.hadoop.hdds.conf.StorageUnit;
@@ -107,7 +107,7 @@ private void verifyDirTree(String volumeName, String 
bucketName, int depth,
     // verify the directory structure
     LOG.info("Started verifying the directory structure...");
     OzoneConfiguration conf = new OzoneConfiguration(cluster().getConf());
-    OzoneFileSystemTests.setPageSize(conf, PAGE_SIZE);
+    OzoneFileSystemTestUtils.setPageSize(conf, PAGE_SIZE);
     try (FileSystem fileSystem = FileSystem.get(URI.create(rootPath), conf)) {
       Path rootDir = new Path(rootPath.concat("/"));
       // verify root path details


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to