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 9b864d4f4f6 HDDS-14683. Remove redundant FileSystem field from 
Abstract*OzoneFileSystemTest (#9797)
9b864d4f4f6 is described below

commit 9b864d4f4f6435100a38f94ccf4029515db5d91d
Author: len548 <[email protected]>
AuthorDate: Sat Feb 21 05:43:31 2026 +0100

    HDDS-14683. Remove redundant FileSystem field from 
Abstract*OzoneFileSystemTest (#9797)
---
 .../fs/ozone/AbstractOzoneFileSystemTest.java      | 124 ++++++++++-----------
 .../ozone/AbstractRootedOzoneFileSystemTest.java   | 104 +++++++++--------
 2 files changed, 112 insertions(+), 116 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 931b2eb81ab..d1d5976097e 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
@@ -156,8 +156,7 @@ abstract class AbstractOzoneFileSystemTest extends 
OzoneFileSystemTestBase {
   private MiniOzoneCluster cluster;
   private OzoneClient client;
   private OzoneManagerProtocol writeClient;
-  private FileSystem fs;
-  private OzoneFileSystem o3fs;
+  private OzoneFileSystem fs;
   private OzoneFSStorageStatistics statistics;
   private OzoneBucket ozoneBucket;
   private String volumeName;
@@ -214,10 +213,9 @@ void init() throws Exception {
     // Set the number of keys to be processed during batch operate.
     conf.setInt(OZONE_FS_ITERATE_BATCH_SIZE, 5);
 
-    fs = FileSystem.get(conf);
     trash = new Trash(conf);
-    o3fs = assertInstanceOf(OzoneFileSystem.class, fs);
-    statistics = (OzoneFSStorageStatistics) 
o3fs.getOzoneFSOpsCountStatistics();
+    fs = assertInstanceOf(OzoneFileSystem.class, FileSystem.get(conf));
+    statistics = (OzoneFSStorageStatistics) fs.getOzoneFSOpsCountStatistics();
     assertEquals(OzoneConsts.OZONE_URI_SCHEME, fs.getUri().getScheme());
     assertEquals(OzoneConsts.OZONE_URI_SCHEME, statistics.getScheme());
 
@@ -251,7 +249,7 @@ public MiniOzoneCluster getCluster() {
 
   @Override
   public OzoneFileSystem getFs() {
-    return o3fs;
+    return fs;
   }
 
   public String getBucketName() {
@@ -419,7 +417,7 @@ public void testCreateDoesNotAddParentDirKeys() throws 
Exception {
     ContractTestUtils.touch(fs, child);
 
     OzoneKeyDetails key = getKey(child, false);
-    assertEquals(key.getName(), o3fs.pathToKey(child));
+    assertEquals(key.getName(), fs.pathToKey(child));
 
     // Creating a child should not add parent keys to the bucket
     try {
@@ -459,7 +457,7 @@ public void testDeleteCreatesFakeParentDir() throws 
Exception {
 
     // Deleting the only child should create the parent dir key if it does
     // not exist
-    FileStatus fileStatus = o3fs.getFileStatus(parent);
+    FileStatus fileStatus = fs.getFileStatus(parent);
     assertTrue(fileStatus.isDirectory());
     assertEquals(parent.toString(), fileStatus.getPath().toUri().getPath());
 
@@ -576,16 +574,16 @@ public void testFileDelete() throws Exception {
     assertEquals(8, fs.listStatus(childFolder).length);
 
     assertTrue(fs.delete(grandparent, true));
-    assertFalse(o3fs.exists(grandparent));
+    assertFalse(fs.exists(grandparent));
     for (int i = 0; i < 8; i++) {
       Path childFile = new Path(parent, "child" + i);
       // Make sure all keys under testBatchDelete/parent should be deleted
-      assertFalse(o3fs.exists(childFile));
+      assertFalse(fs.exists(childFile));
 
       // Test to recursively delete child folder, make sure all keys under
       // testBatchDelete/parent/childFolder should be deleted.
       Path childFolderFile = new Path(childFolder, "child" + i);
-      assertFalse(o3fs.exists(childFolderFile));
+      assertFalse(fs.exists(childFolderFile));
     }
     // Will get: WARN  ozone.BasicOzoneFileSystem delete: Path does not exist.
     // This will return false.
@@ -598,19 +596,19 @@ public void testListStatus() throws Exception {
     Path file1 = new Path(parent, "key1");
     Path file2 = new Path(parent, "key2");
 
-    FileStatus[] fileStatuses = o3fs.listStatus(ROOT, EXCLUDE_TRASH);
+    FileStatus[] fileStatuses = fs.listStatus(ROOT, EXCLUDE_TRASH);
     assertEquals(0, fileStatuses.length, "Should be empty");
 
     ContractTestUtils.touch(fs, file1);
     ContractTestUtils.touch(fs, file2);
 
-    fileStatuses = o3fs.listStatus(ROOT, EXCLUDE_TRASH);
+    fileStatuses = fs.listStatus(ROOT, EXCLUDE_TRASH);
     assertEquals(1, fileStatuses.length, "Should have created parent");
     assertEquals(fileStatuses[0].getPath().toUri().getPath(), 
parent.toString(), "Parent path doesn't match");
 
     // ListStatus on a directory should return all subdirs along with
     // files, even if there exists a file and sub-dir with the same name.
-    fileStatuses = o3fs.listStatus(parent);
+    fileStatuses = fs.listStatus(parent);
     assertEquals(2, fileStatuses.length, "FileStatus did not return all 
children of the directory");
 
     // ListStatus should return only the immediate children of a directory.
@@ -618,7 +616,7 @@ public void testListStatus() throws Exception {
     Path file4 = new Path(parent, "dir1/key4");
     ContractTestUtils.touch(fs, file3);
     ContractTestUtils.touch(fs, file4);
-    fileStatuses = o3fs.listStatus(parent);
+    fileStatuses = fs.listStatus(parent);
     assertEquals(3, fileStatuses.length, "FileStatus did not return all 
children of the directory");
   }
 
@@ -640,21 +638,21 @@ public void testObjectOwner() throws Exception {
       Path file1 = new Path(root, "file1");
       Path dir1 = new Path(root, "dir1");
       Path file2 = new Path(dir1, "file2");
-      FileStatus[] fileStatuses = o3fs.listStatus(root);
+      FileStatus[] fileStatuses = fs.listStatus(root);
       assertEquals(0, fileStatuses.length);
 
       UserGroupInformation.setLoginUser(user1);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
       ContractTestUtils.touch(fs, file1);
       UserGroupInformation.setLoginUser(user2);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
       fs.mkdirs(dir1);
       UserGroupInformation.setLoginUser(user3);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
       ContractTestUtils.touch(fs, file2);
 
-      assertEquals(2, o3fs.listStatus(root).length);
-      assertEquals(1, o3fs.listStatus(dir1).length);
+      assertEquals(2, fs.listStatus(root).length);
+      assertEquals(1, fs.listStatus(dir1).length);
       assertEquals(user1.getShortUserName(),
           fs.getFileStatus(file1).getOwner());
       assertEquals(user2.getShortUserName(),
@@ -663,7 +661,7 @@ public void testObjectOwner() throws Exception {
           fs.getFileStatus(file2).getOwner());
     } finally {
       UserGroupInformation.setLoginUser(oldUser);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
     }
   }
 
@@ -689,21 +687,21 @@ public void testObjectProxyUser() throws Exception {
           UserGroupInformation.createProxyUser("user2", proxyuser);
       UserGroupInformation user3ProxyUser =
           UserGroupInformation.createProxyUser("user3", proxyuser);
-      FileStatus[] fileStatuses = o3fs.listStatus(root);
+      FileStatus[] fileStatuses = fs.listStatus(root);
       assertEquals(0, fileStatuses.length);
 
       UserGroupInformation.setLoginUser(user1ProxyUser);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
       ContractTestUtils.touch(fs, file1);
       UserGroupInformation.setLoginUser(user2ProxyUser);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
       fs.mkdirs(dir1);
       UserGroupInformation.setLoginUser(user3ProxyUser);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
       ContractTestUtils.touch(fs, file2);
 
-      assertEquals(2, o3fs.listStatus(root).length);
-      assertEquals(1, o3fs.listStatus(dir1).length);
+      assertEquals(2, fs.listStatus(root).length);
+      assertEquals(1, fs.listStatus(dir1).length);
       assertEquals(user1ProxyUser.getShortUserName(),
           fs.getFileStatus(file1).getOwner());
       assertEquals(user2ProxyUser.getShortUserName(),
@@ -712,7 +710,7 @@ public void testObjectProxyUser() throws Exception {
           fs.getFileStatus(file2).getOwner());
     } finally {
       UserGroupInformation.setLoginUser(oldUser);
-      fs = FileSystem.get(cluster.getConf());
+      fs = (OzoneFileSystem) FileSystem.get(cluster.getConf());
     }
   }
 
@@ -807,7 +805,7 @@ public void testListStatusOnRoot() throws Exception {
     // ListStatus on root should return dir1 (even though /dir1 key does not
     // exist) and dir2 only. dir12 is not an immediate child of root and
     // hence should not be listed.
-    FileStatus[] fileStatuses = o3fs.listStatus(ROOT, EXCLUDE_TRASH);
+    FileStatus[] fileStatuses = fs.listStatus(ROOT, EXCLUDE_TRASH);
     assertEquals(2, fileStatuses.length, "FileStatus should return only the 
immediate children");
 
     // Verify that dir12 is not included in the result of the listStatus on 
root
@@ -833,7 +831,7 @@ public void testListStatusOnLargeDirectory() throws 
Exception {
       paths.add(p.getName());
     }
 
-    FileStatus[] fileStatuses = o3fs.listStatus(ROOT, EXCLUDE_TRASH);
+    FileStatus[] fileStatuses = fs.listStatus(ROOT, EXCLUDE_TRASH);
     // Added logs for debugging failures, to check any sub-path mismatches.
     Set<String> actualPaths = new TreeSet<>();
     ArrayList<String> actualPathList = new ArrayList<>();
@@ -944,7 +942,7 @@ public void testListStatusOnSubDirs() throws Exception {
     ContractTestUtils.touch(fs, file121);
     fs.mkdirs(dir2);
 
-    FileStatus[] fileStatuses = o3fs.listStatus(dir1);
+    FileStatus[] fileStatuses = fs.listStatus(dir1);
     assertEquals(2, fileStatuses.length, "FileStatus should return only the 
immediate children");
 
     // Verify that the two children of /dir1 returned by listStatus operation
@@ -980,7 +978,7 @@ public void testListStatusIteratorOnRoot() throws Exception 
{
       // ListStatusIterator on root should return dir1
       // (even though /dir1 key does not exist)and dir2 only.
       // dir12 is not an immediate child of root and hence should not be 
listed.
-      RemoteIterator<FileStatus> it = o3fs.listStatusIterator(ROOT);
+      RemoteIterator<FileStatus> it = fs.listStatusIterator(ROOT);
       int iCount = 0;
       while (it.hasNext()) {
         iCount++;
@@ -1031,7 +1029,7 @@ public void testListStatusIteratorOnSubDirs() throws 
Exception {
       ContractTestUtils.touch(fs, file121);
       fs.mkdirs(dir2);
 
-      RemoteIterator<FileStatus> it = o3fs.listStatusIterator(dir1);
+      RemoteIterator<FileStatus> it = fs.listStatusIterator(dir1);
       int iCount = 0;
       while (it.hasNext()) {
         iCount++;
@@ -1438,7 +1436,7 @@ public void testRenameDir() throws Exception {
   @Override
   protected OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
       throws IOException {
-    String key = o3fs.pathToKey(keyPath);
+    String key = fs.pathToKey(keyPath);
     if (isDirectory) {
       key = key + "/";
     }
@@ -1457,7 +1455,7 @@ public void testGetDirectoryModificationTime()
     fs.mkdirs(mdir111);
 
     // Case 1: Dir key exist on server
-    FileStatus[] fileStatuses = o3fs.listStatus(mdir11);
+    FileStatus[] fileStatuses = fs.listStatus(mdir11);
     // Above listStatus result should only have one entry: mdir111
     assertEquals(1, fileStatuses.length);
     assertEquals(mdir111.toString(), 
fileStatuses[0].getPath().toUri().getPath());
@@ -1468,12 +1466,12 @@ public void testGetDirectoryModificationTime()
     // Check modification time in a small loop, it should always be the same
     for (int i = 0; i < 5; i++) {
       Thread.sleep(10);
-      fileStatuses = o3fs.listStatus(mdir11);
+      fileStatuses = fs.listStatus(mdir11);
       assertEquals(modificationTime, fileStatuses[0].getModificationTime());
     }
 
     // Case 2: Dir key doesn't exist on server
-    fileStatuses = o3fs.listStatus(mdir1);
+    fileStatuses = fs.listStatus(mdir1);
     // Above listStatus result should only have one entry: mdir11
     assertEquals(1, fileStatuses.length);
     assertEquals(mdir11.toString(), 
fileStatuses[0].getPath().toUri().getPath());
@@ -1485,7 +1483,7 @@ public void testGetDirectoryModificationTime()
     // each time
     for (int i = 0; i < 5; i++) {
       Thread.sleep(10);
-      fileStatuses = o3fs.listStatus(mdir1);
+      fileStatuses = fs.listStatus(mdir1);
       
assertThat(modificationTime).isLessThanOrEqualTo(fileStatuses[0].getModificationTime());
     }
   }
@@ -1496,8 +1494,8 @@ public void testGetTrashRoot() throws IOException {
     // Input path doesn't matter, o3fs.getTrashRoot() only cares about username
     Path inPath1 = new Path("o3fs://bucket2.volume1/path/to/key");
     // Test with current user
-    Path outPath1 = o3fs.getTrashRoot(inPath1);
-    Path expectedOutPath1 = o3fs.makeQualified(new Path(TRASH_ROOT, username));
+    Path outPath1 = fs.getTrashRoot(inPath1);
+    Path expectedOutPath1 = fs.makeQualified(new Path(TRASH_ROOT, username));
     assertEquals(expectedOutPath1, outPath1);
   }
 
@@ -1567,15 +1565,15 @@ public void testGetTrashRoots() throws IOException {
     String username = UserGroupInformation.getCurrentUser().getShortUserName();
     Path userTrash = new Path(TRASH_ROOT, username);
 
-    Collection<FileStatus> res = o3fs.getTrashRoots(false);
+    Collection<FileStatus> res = fs.getTrashRoots(false);
     assertEquals(0, res.size());
 
     fs.mkdirs(userTrash);
-    res = o3fs.getTrashRoots(false);
+    res = fs.getTrashRoots(false);
     assertEquals(1, res.size());
     res.forEach(e -> assertEquals(userTrash.toString(), 
e.getPath().toUri().getPath()));
     // Only have one user trash for now
-    res = o3fs.getTrashRoots(true);
+    res = fs.getTrashRoots(true);
     assertEquals(1, res.size());
 
     // Create a few more random user trash dir
@@ -1588,11 +1586,11 @@ public void testGetTrashRoots() throws IOException {
     fs.create(new Path(TRASH_ROOT, "trashuser99"));
 
     // allUsers = false should still return current user trash
-    res = o3fs.getTrashRoots(false);
+    res = fs.getTrashRoots(false);
     assertEquals(1, res.size());
     res.forEach(e -> assertEquals(userTrash.toString(), 
e.getPath().toUri().getPath()));
     // allUsers = true should return all user trash
-    res = o3fs.getTrashRoots(true);
+    res = fs.getTrashRoots(true);
     assertEquals(6, res.size());
   }
 
@@ -1632,19 +1630,19 @@ public void testTrash() throws Exception {
     Path userTrash = new Path(TRASH_ROOT, username);
     Path userTrashCurrent = new Path(userTrash, "Current");
     Path trashPath = new Path(userTrashCurrent, testKeyName);
-    assertFalse(o3fs.exists(userTrash));
+    assertFalse(fs.exists(userTrash));
 
     // Call moveToTrash. We can't call protected fs.rename() directly
     trash.moveToTrash(path);
 
-    assertTrue(o3fs.exists(userTrash));
-    assertTrue(o3fs.exists(trashPath) || o3fs.listStatus(
-        o3fs.listStatus(userTrash)[0].getPath()).length > 0);
+    assertTrue(fs.exists(userTrash));
+    assertTrue(fs.exists(trashPath) || fs.listStatus(
+        fs.listStatus(userTrash)[0].getPath()).length > 0);
 
     // Wait until the TrashEmptier purges the key
     GenericTestUtils.waitFor(() -> {
       try {
-        return !o3fs.exists(trashPath);
+        return !fs.exists(trashPath);
       } catch (IOException e) {
         LOG.error("Delete from Trash Failed");
         fail("Delete from Trash Failed");
@@ -1655,7 +1653,7 @@ public void testTrash() throws Exception {
     // wait for deletion of checkpoint dir
     GenericTestUtils.waitFor(() -> {
       try {
-        return o3fs.listStatus(userTrash).length == 0;
+        return fs.listStatus(userTrash).length == 0;
       } catch (IOException e) {
         LOG.error("Delete from Trash Failed", e);
         fail("Delete from Trash Failed");
@@ -1860,18 +1858,18 @@ public void testOzFsReadWrite() throws IOException {
     String lev1dir = "l1dir";
     Path lev1path = createPath("/" + lev1dir);
     String lev1key = metadataManager.getOzoneDirKey(volumeName, bucketName,
-        o3fs.pathToKey(lev1path));
+        fs.pathToKey(lev1path));
     String lev2dir = "l2dir";
     Path lev2path = createPath("/" + lev1dir + "/" + lev2dir);
     String lev2key = metadataManager.getOzoneDirKey(volumeName, bucketName,
-        o3fs.pathToKey(lev2path));
+        fs.pathToKey(lev2path));
 
     String data = RandomStringUtils.secure().nextAlphanumeric(stringLen);
     String filePath = RandomStringUtils.secure().nextAlphanumeric(5);
 
     Path path = createPath("/" + lev1dir + "/" + lev2dir + "/" + filePath);
     String fileKey = metadataManager.getOzoneDirKey(volumeName, bucketName,
-        o3fs.pathToKey(path));
+        fs.pathToKey(path));
 
     // verify prefix directories and the file, do not already exist
     assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev1key));
@@ -1969,15 +1967,15 @@ public void testDirectory() throws IOException {
     String lev1dir = "abc";
     Path lev1path = createPath("/" + lev1dir);
     String lev1key = metadataManager.getOzoneDirKey(volumeName, bucketName,
-        o3fs.pathToKey(lev1path));
+        fs.pathToKey(lev1path));
     String lev2dir = "def";
     Path lev2path = createPath("/" + lev1dir + "/" + lev2dir);
     String lev2key = metadataManager.getOzoneDirKey(volumeName, bucketName,
-        o3fs.pathToKey(lev2path));
+        fs.pathToKey(lev2path));
 
     Path leaf = createPath("/" + lev1dir + "/" + lev2dir + "/" + leafName);
     String leafKey = metadataManager.getOzoneDirKey(volumeName, bucketName,
-        o3fs.pathToKey(leaf));
+        fs.pathToKey(leaf));
 
     // verify prefix directories and the leaf, do not already exist
     assertNull(metadataManager.getKeyTable(getBucketLayout()).get(lev1key));
@@ -2112,7 +2110,7 @@ void testOzoneManagerFileSystemInterface() throws 
IOException {
     OmKeyArgs keyArgs = new OmKeyArgs.Builder()
         .setVolumeName(volumeName)
         .setBucketName(bucketName)
-        .setKeyName(o3fs.pathToKey(path))
+        .setKeyName(fs.pathToKey(path))
         .build();
     OzoneFileStatus omStatus =
         cluster.getOzoneManager().getFileStatus(keyArgs);
@@ -2127,7 +2125,7 @@ void testOzoneManagerFileSystemInterface() throws 
IOException {
     assertEquals(0, omStatus.getKeyInfo().getDataSize());
     
assertThat(omStatus.getKeyInfo().getModificationTime()).isLessThanOrEqualTo(currentTime);
     assertEquals(new Path(omStatus.getPath()).getName(),
-        o3fs.pathToKey(path));
+        fs.pathToKey(path));
   }
 
   @Test
@@ -2179,13 +2177,13 @@ void testBlockOffsetsWithMultiBlockFile() throws 
Exception {
   void testPathToKey() {
     assumeFalse(FILE_SYSTEM_OPTIMIZED.equals(getBucketLayout()));
 
-    assertEquals("a/b/1", o3fs.pathToKey(new Path("/a/b/1")));
+    assertEquals("a/b/1", fs.pathToKey(new Path("/a/b/1")));
 
     assertEquals("user/" + getCurrentUser() + "/key1/key2",
-        o3fs.pathToKey(new Path("key1/key2")));
+        fs.pathToKey(new Path("key1/key2")));
 
     assertEquals("key1/key2",
-        o3fs.pathToKey(new Path("o3fs://test1/key1/key2")));
+        fs.pathToKey(new Path("o3fs://test1/key1/key2")));
   }
 
 
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 e03327632a2..926e323583f 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
@@ -160,8 +160,7 @@ abstract class AbstractRootedOzoneFileSystemTest extends 
OzoneFileSystemTestBase
 
   private OzoneConfiguration conf;
   private MiniOzoneCluster cluster;
-  private FileSystem fs;
-  private RootedOzoneFileSystem ofs;
+  private RootedOzoneFileSystem fs;
   private ObjectStore objectStore;
   private BasicRootedOzoneClientAdapterImpl adapter;
   private Trash trash;
@@ -214,7 +213,7 @@ void cleanup() throws IOException {
 
   @Override
   public RootedOzoneFileSystem getFs() {
-    return ofs;
+    return fs;
   }
 
   public Path getBucketPath() {
@@ -264,10 +263,9 @@ void initClusterAndEnv() throws IOException, 
InterruptedException, TimeoutExcept
     conf.setInt(OZONE_FS_ITERATE_BATCH_SIZE, 5);
     conf.setInt(OZONE_OM_SNAPSHOT_DIFF_REPORT_MAX_PAGE_SIZE, 4);
     // fs.ofs.impl would be loaded from META-INF, no need to manually set it
-    fs = FileSystem.get(conf);
     trash = new Trash(conf);
-    ofs = (RootedOzoneFileSystem) fs;
-    adapter = (BasicRootedOzoneClientAdapterImpl) ofs.getAdapter();
+    fs = (RootedOzoneFileSystem) FileSystem.get(conf);
+    adapter = (BasicRootedOzoneClientAdapterImpl) fs.getAdapter();
 
     userOfs = UGI_USER1.doAs(
         (PrivilegedExceptionAction<RootedOzoneFileSystem>)()
@@ -405,19 +403,19 @@ void testListStatus() throws Exception {
     Path file1 = new Path(parent, "key1");
     Path file2 = new Path(parent, "key2");
 
-    FileStatus[] fileStatuses = ofs.listStatus(bucketPath);
+    FileStatus[] fileStatuses = fs.listStatus(bucketPath);
     assertEquals(0, fileStatuses.length, "Should be empty");
 
     ContractTestUtils.touch(fs, file1);
     ContractTestUtils.touch(fs, file2);
 
-    fileStatuses = ofs.listStatus(bucketPath);
+    fileStatuses = fs.listStatus(bucketPath);
     assertEquals(1, fileStatuses.length, "Should have created parent");
     assertEquals(fileStatuses[0].getPath().toUri().getPath(), 
parent.toString(), "Parent path doesn't match");
 
     // ListStatus on a directory should return all subdirs along with
     // files, even if there exists a file and sub-dir with the same name.
-    fileStatuses = ofs.listStatus(parent);
+    fileStatuses = fs.listStatus(parent);
     assertEquals(2, fileStatuses.length, "FileStatus did not return all 
children of the directory");
 
     // ListStatus should return only the immediate children of a directory.
@@ -425,7 +423,7 @@ void testListStatus() throws Exception {
     Path file4 = new Path(parent, "dir1/key4");
     ContractTestUtils.touch(fs, file3);
     ContractTestUtils.touch(fs, file4);
-    fileStatuses = ofs.listStatus(parent);
+    fileStatuses = fs.listStatus(parent);
     assertEquals(3, fileStatuses.length, "FileStatus did not return all 
children of" +
         " the directory : Got " + Arrays.toString(
         fileStatuses));
@@ -458,7 +456,7 @@ void testListStatusIteratorInBucket() throws Exception {
       // ListStatus on root should return dir1 (even though /dir1 key does not
       // exist) and dir2 only. dir12 is not an immediate child of root and
       // hence should not be listed.
-      RemoteIterator<FileStatus> it = ofs.listStatusIterator(root);
+      RemoteIterator<FileStatus> it = fs.listStatusIterator(root);
       // Verify that dir12 is not included in the result of the listStatus on
       // root
       int iCount = 0;
@@ -481,7 +479,7 @@ void testListStatusIteratorInBucket() throws Exception {
   void testListStatusIteratorWithPathNotFound() throws Exception {
     Path path = new Path("/test/test1/test2");
     try {
-      ofs.listStatusIterator(path);
+      fs.listStatusIterator(path);
       fail("Should have thrown OMException");
     } catch (OMException omEx) {
       assertEquals(VOLUME_NOT_FOUND, omEx.getResult(), "Volume test is not 
found");
@@ -524,7 +522,7 @@ void testListStatusIteratorOnSubDirs() throws Exception {
       ContractTestUtils.touch(fs, file121);
       fs.mkdirs(dir2);
 
-      RemoteIterator<FileStatus> it = ofs.listStatusIterator(dir1);
+      RemoteIterator<FileStatus> it = fs.listStatusIterator(dir1);
       int iCount = 0;
       while (it.hasNext()) {
         iCount++;
@@ -600,15 +598,15 @@ void testMkdirOnNonExistentVolumeBucketDir() throws 
Exception {
     assertEquals(key, ozoneKeyDetails.getName());
 
     // Verify that directories are created.
-    FileStatus[] fileStatuses = ofs.listStatus(root);
+    FileStatus[] fileStatuses = fs.listStatus(root);
     assertEquals(fileStatuses[0].getPath().toUri().getPath(), dir1.toString());
     assertEquals(fileStatuses[1].getPath().toUri().getPath(), dir2.toString());
 
-    fileStatuses = ofs.listStatus(dir1);
+    fileStatuses = fs.listStatus(dir1);
     assertEquals(fileStatuses[0].getPath().toUri().getPath(), 
dir12.toString());
-    fileStatuses = ofs.listStatus(dir12);
+    fileStatuses = fs.listStatus(dir12);
     assertEquals(fileStatuses.length, 0);
-    fileStatuses = ofs.listStatus(dir2);
+    fileStatuses = fs.listStatus(dir2);
     assertEquals(fileStatuses.length, 0);
 
     // Cleanup
@@ -702,7 +700,7 @@ void testListStatusInBucket() throws Exception {
       // ListStatus on root should return dir1 (even though /dir1 key does not
       // exist) and dir2 only. dir12 is not an immediate child of root and
       // hence should not be listed.
-      FileStatus[] fileStatuses = ofs.listStatus(root);
+      FileStatus[] fileStatuses = fs.listStatus(root);
       assertEquals(2, fileStatuses.length, "FileStatus should return only the 
immediate children");
 
       // Verify that dir12 is not included in the result of the listStatus on
@@ -733,7 +731,7 @@ void testListStatusOnLargeDirectory() throws Exception {
         paths.add(p.getName());
       }
 
-      FileStatus[] fileStatuses = ofs.listStatus(root);
+      FileStatus[] fileStatuses = fs.listStatus(root);
       assertEquals(numDirs, fileStatuses.length, "Total directories listed do 
not match the existing directories");
 
       for (int i = 0; i < numDirs; i++) {
@@ -773,7 +771,7 @@ void testListStatusOnSubDirs() throws Exception {
     ContractTestUtils.touch(fs, file121);
     fs.mkdirs(dir2);
 
-    FileStatus[] fileStatuses = ofs.listStatus(dir1);
+    FileStatus[] fileStatuses = fs.listStatus(dir1);
     assertEquals(2, fileStatuses.length, "FileStatus should return only the 
immediate children");
 
     // Verify that the two children of /dir1 returned by listStatus operation
@@ -851,7 +849,7 @@ void testRenameToDifferentBucket() throws IOException {
   @Override
   protected OzoneKeyDetails getKey(Path keyPath, boolean isDirectory)
       throws IOException {
-    String key = ofs.pathToKey(keyPath);
+    String key = fs.pathToKey(keyPath);
     if (isDirectory) {
       key = key + OZONE_URI_DELIMITER;
     }
@@ -881,7 +879,7 @@ private Path createRandomVolumeBucketWithDirs() throws 
IOException {
     fs.mkdirs(dir2);
 
     try (FSDataOutputStream stream =
-        ofs.create(new Path(dir2, "file1"))) {
+        fs.create(new Path(dir2, "file1"))) {
       stream.write(1);
     }
 
@@ -920,7 +918,7 @@ void testListStatusWithDifferentBucketOwner() throws 
IOException {
 
     OzoneBucket ozoneBucket = ozoneVolume.getBucket(buckName);
 
-    FileStatus[] fileStatusVolume = ofs.listStatus(volPath);
+    FileStatus[] fileStatusVolume = fs.listStatus(volPath);
     assertEquals(1, fileStatusVolume.length);
     // FileStatus owner is different from the volume owner.
     // Owner is the same as the bucket owner returned by the ObjectStore.
@@ -944,19 +942,19 @@ void testListStatusRootAndVolumeNonRecursive() throws 
Exception {
     Path bucketPath1 = createRandomVolumeBucketWithDirs();
     Path bucketPath2 = createRandomVolumeBucketWithDirs();
     // listStatus("/volume/bucket")
-    FileStatus[] fileStatusBucket = ofs.listStatus(bucketPath1);
+    FileStatus[] fileStatusBucket = fs.listStatus(bucketPath1);
     assertEquals(2, fileStatusBucket.length);
     // listStatus("/volume")
     Path volume = new Path(
         OZONE_URI_DELIMITER + new OFSPath(bucketPath1, conf).getVolumeName());
-    FileStatus[] fileStatusVolume = ofs.listStatus(volume);
+    FileStatus[] fileStatusVolume = fs.listStatus(volume);
     assertEquals(1, fileStatusVolume.length);
     assertEquals(ownerShort, fileStatusVolume[0].getOwner());
     assertEquals(group, fileStatusVolume[0].getGroup());
 
     // listStatus("/")
     Path root = new Path(OZONE_URI_DELIMITER);
-    FileStatus[] fileStatusRoot = ofs.listStatus(root);
+    FileStatus[] fileStatusRoot = fs.listStatus(root);
 
     // When ACL is enabled, listStatus root will see a 4th volume created by
     //  userXXXXX as the result of createVolumeAndBucket in initClusterAndEnv.
@@ -990,7 +988,7 @@ void testListStatusRootAndVolumeNonRecursive() throws 
Exception {
    */
   private void listStatusRecursiveHelper(Path curPath, List<FileStatus> result)
       throws IOException {
-    FileStatus[] startList = ofs.listStatus(curPath);
+    FileStatus[] startList = fs.listStatus(curPath);
     for (FileStatus fileStatus : startList) {
       result.add(fileStatus);
       if (fileStatus.isDirectory()) {
@@ -1006,8 +1004,8 @@ private void listStatusRecursiveHelper(Path curPath, 
List<FileStatus> result)
   private List<FileStatus> callAdapterListStatus(String pathStr,
       boolean recursive, String startPath, long numEntries) throws IOException 
{
     return adapter.listStatus(pathStr, recursive, startPath, numEntries,
-        ofs.getUri(), ofs.getWorkingDirectory(), ofs.getUsername(), false)
-        .stream().map(ofs::convertFileStatus).collect(Collectors.toList());
+        fs.getUri(), fs.getWorkingDirectory(), fs.getUsername(), false)
+        .stream().map(fs::convertFileStatus).collect(Collectors.toList());
   }
 
   /**
@@ -1281,7 +1279,7 @@ void testTempMount() throws IOException {
     Path dir1 = new Path("/tmp/dir1");
     fs.mkdirs(dir1);
 
-    try (FSDataOutputStream stream = ofs.create(new Path("/tmp/dir1/file1"))) {
+    try (FSDataOutputStream stream = fs.create(new Path("/tmp/dir1/file1"))) {
       stream.write(1);
     }
 
@@ -1786,16 +1784,16 @@ void testFileDelete() throws Exception {
     assertEquals(8, fs.listStatus(childFolder).length);
 
     assertTrue(fs.delete(grandparent, true));
-    assertFalse(ofs.exists(grandparent));
+    assertFalse(fs.exists(grandparent));
     for (int i = 0; i < 8; i++) {
       Path childFile = new Path(parent, "child" + i);
       // Make sure all keys under testBatchDelete/parent should be deleted
-      assertFalse(ofs.exists(childFile));
+      assertFalse(fs.exists(childFile));
 
       // Test to recursively delete child folder, make sure all keys under
       // testBatchDelete/parent/childFolder should be deleted.
       Path childFolderFile = new Path(childFolder, "child" + i);
-      assertFalse(ofs.exists(childFolderFile));
+      assertFalse(fs.exists(childFolderFile));
     }
     // Will get: WARN  ozone.BasicOzoneFileSystem delete: Path does not exist.
     // This will return false.
@@ -1859,14 +1857,14 @@ void testTrash() throws Exception {
     trash.moveToTrash(keyPath2);
 
     // key should either be present in Current or checkpointDir
-    assertTrue(ofs.exists(trashPath)
-        || ofs.listStatus(ofs.listStatus(userTrash)[0].getPath()).length > 0);
+    assertTrue(fs.exists(trashPath)
+        || fs.listStatus(fs.listStatus(userTrash)[0].getPath()).length > 0);
 
 
     // Wait until the TrashEmptier purges the keys
     GenericTestUtils.waitFor(() -> {
       try {
-        return !ofs.exists(trashPath) && !ofs.exists(trashPath2);
+        return !fs.exists(trashPath) && !fs.exists(trashPath2);
       } catch (IOException e) {
         LOG.error("Delete from Trash Failed", e);
         fail("Delete from Trash Failed");
@@ -1889,8 +1887,8 @@ void testTrash() throws Exception {
     // wait for deletion of checkpoint dir
     GenericTestUtils.waitFor(() -> {
       try {
-        return ofs.listStatus(userTrash).length == 0 &&
-            ofs.listStatus(userTrash2).length == 0;
+        return fs.listStatus(userTrash).length == 0 &&
+            fs.listStatus(userTrash2).length == 0;
       } catch (IOException e) {
         LOG.error("Delete from Trash Failed", e);
         fail("Delete from Trash Failed");
@@ -1910,8 +1908,8 @@ && getOMMetrics().getNumTrashFilesDeletes()
               >= prevNumTrashFileDeletes, 100, 180000);
     }
     // Cleanup
-    ofs.delete(trashRoot, true);
-    ofs.delete(trashRoot2, true);
+    fs.delete(trashRoot, true);
+    fs.delete(trashRoot2, true);
 
   }
 
@@ -2147,11 +2145,11 @@ void testGetFileStatus() throws Exception {
     String volumeNameLocal = getRandomNonExistVolumeName();
     String bucketNameLocal = RandomStringUtils.secure().nextNumeric(5);
     Path volume = new Path("/" + volumeNameLocal);
-    ofs.mkdirs(volume);
+    fs.mkdirs(volume);
     assertThrows(OMException.class,
-        () -> ofs.getFileStatus(new Path(volume, bucketNameLocal)));
+        () -> fs.getFileStatus(new Path(volume, bucketNameLocal)));
     // Cleanup
-    ofs.delete(volume, false);
+    fs.delete(volume, false);
   }
 
   @Test
@@ -2181,14 +2179,14 @@ void testCreateAndCheckECFileDiskUsage() throws 
Exception {
         RandomUtils.secure().randomBytes(1));
     // make sure the disk usage matches the expected value
     Path filePath = new Path(bucketPathTest, key);
-    ContentSummary contentSummary = ofs.getContentSummary(filePath);
+    ContentSummary contentSummary = fs.getContentSummary(filePath);
     long length = contentSummary.getLength();
     long spaceConsumed = contentSummary.getSpaceConsumed();
     long expectDiskUsage = QuotaUtil.getReplicatedSize(length,
         new ECReplicationConfig(3, 2, RS, (int) OzoneConsts.MB));
     assertEquals(expectDiskUsage, spaceConsumed);
     //clean up
-    ofs.delete(filePath, true);
+    fs.delete(filePath, true);
   }
 
   @Test
@@ -2204,7 +2202,7 @@ void testCreateAndCheckRatisFileDiskUsage() throws 
Exception {
         RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.THREE),
         RandomUtils.secure().randomBytes(1));
     // make sure the disk usage matches the expected value
-    ContentSummary contentSummary = ofs.getContentSummary(filePathTest);
+    ContentSummary contentSummary = fs.getContentSummary(filePathTest);
     long length = contentSummary.getLength();
     long spaceConsumed = contentSummary.getSpaceConsumed();
     long expectDiskUsage = QuotaUtil.getReplicatedSize(length,
@@ -2212,7 +2210,7 @@ void testCreateAndCheckRatisFileDiskUsage() throws 
Exception {
                     HddsProtos.ReplicationFactor.THREE));
     assertEquals(expectDiskUsage, spaceConsumed);
     //clean up
-    ofs.delete(filePathTest, true);
+    fs.delete(filePathTest, true);
   }
 
   @Test
@@ -2343,7 +2341,7 @@ void testSnapshotDiff() throws Exception {
     String fromSnap = fromSnapPath != null ? fromSnapPath.toString() : null;
     String toSnap = toSnapPath != null ? toSnapPath.toString() : null;
     SnapshotDiffReport diff =
-        ofs.getSnapshotDiffReport(bucketPath1, fromSnap, toSnap);
+        fs.getSnapshotDiffReport(bucketPath1, fromSnap, toSnap);
     assertEquals(2, diff.getDiffList().size());
     assertEquals(SnapshotDiffReport.DiffType.CREATE, 
diff.getDiffList().get(0).getType());
     assertEquals(SnapshotDiffReport.DiffType.CREATE, 
diff.getDiffList().get(1).getType());
@@ -2362,19 +2360,19 @@ void testSnapshotDiff() throws Exception {
     toSnapPath = Paths.get(snap3.toString()).getFileName();
     fromSnap = fromSnapPath != null ? fromSnapPath.toString() : null;
     toSnap = toSnapPath != null ? toSnapPath.toString() : null;
-    diff = ofs.getSnapshotDiffReport(bucketPath1, fromSnap, toSnap);
+    diff = fs.getSnapshotDiffReport(bucketPath1, fromSnap, toSnap);
     assertEquals(10, diff.getDiffList().size());
 
     Path file =
         new Path(bucketPath1, "key" + 
RandomStringUtils.secure().nextAlphabetic(5));
     ContractTestUtils.touch(fs, file);
-    diff = ofs.getSnapshotDiffReport(bucketPath1, toSnap, "");
+    diff = fs.getSnapshotDiffReport(bucketPath1, toSnap, "");
     assertEquals(1, diff.getDiffList().size());
 
-    diff = ofs.getSnapshotDiffReport(bucketPath1, "", toSnap);
+    diff = fs.getSnapshotDiffReport(bucketPath1, "", toSnap);
     assertEquals(1, diff.getDiffList().size());
 
-    diff = ofs.getSnapshotDiffReport(bucketPath1, "", "");
+    diff = fs.getSnapshotDiffReport(bucketPath1, "", "");
     assertEquals(0, diff.getDiffList().size());
 
     // try snapDiff between non-bucket paths
@@ -2383,7 +2381,7 @@ void testSnapshotDiff() throws Exception {
     String finalToSnap = toSnap;
     IllegalArgumentException exception = assertThrows(
         IllegalArgumentException.class,
-        () -> ofs.getSnapshotDiffReport(volumePath1, finalFromSnap,
+        () -> fs.getSnapshotDiffReport(volumePath1, finalFromSnap,
             finalToSnap));
     assertThat(exception.getMessage()).contains(errorMsg);
   }


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


Reply via email to