Browse Source

[ozone] Update unit tests for service_id changes

Harshg999 2 years ago
parent
commit
ec3e6b7134

+ 42 - 20
desktop/core/src/desktop/lib/fs/ozone/ofs_test.py

@@ -56,35 +56,38 @@ class TestOFSClient(object):
 
 
   def test_strip_normpath(self):
-    test_path = self.ofs_client.strip_normpath('ofs://vol1/buk1/key')
+    test_path = self.ofs_client.strip_normpath('ofs://ozone1/vol1/buk1/key')
     assert_equal(test_path, '/vol1/buk1/key')
 
-    test_path = self.ofs_client.strip_normpath('ofs:/vol1/buk1/key')
+    test_path = self.ofs_client.strip_normpath('ofs:/ozone1/vol1/buk1/key')
     assert_equal(test_path, '/vol1/buk1/key')
 
-    test_path = self.ofs_client.strip_normpath('/vol1/buk1/key')
-    assert_equal(test_path, '/vol1/buk1/key')
+    test_path = self.ofs_client.strip_normpath('/ozone1/vol1/buk1/key')
+    assert_equal(test_path, '/ozone1/vol1/buk1/key')
 
 
   def test_normpath(self):
     test_path = self.ofs_client.normpath('ofs://')
     assert_equal(test_path, 'ofs://')
 
-    test_path = self.ofs_client.normpath('ofs://vol1/buk1/key')
-    assert_equal(test_path, 'ofs://vol1/buk1/key')
+    test_path = self.ofs_client.normpath('ofs://ozone1/vol1/buk1/key')
+    assert_equal(test_path, 'ofs://ozone1/vol1/buk1/key')
 
-    test_path = self.ofs_client.normpath('ofs://vol1/buk1/key/')
-    assert_equal(test_path, 'ofs://vol1/buk1/key')
+    test_path = self.ofs_client.normpath('ofs://ozone1/vol1/buk1/key/')
+    assert_equal(test_path, 'ofs://ozone1/vol1/buk1/key')
 
-    test_path = self.ofs_client.normpath('ofs://vol1/buk1/key//')
-    assert_equal(test_path, 'ofs://vol1/buk1/key')
+    test_path = self.ofs_client.normpath('ofs://ozone1/vol1/buk1/key//')
+    assert_equal(test_path, 'ofs://ozone1/vol1/buk1/key')
 
-    test_path = self.ofs_client.normpath('ofs://vol1/buk1//key//')
-    assert_equal(test_path, 'ofs://vol1/buk1/key')
+    test_path = self.ofs_client.normpath('ofs://ozone1/vol1/buk1//key//')
+    assert_equal(test_path, 'ofs://ozone1/vol1/buk1/key')
 
 
   def test_isroot(self):
-    is_root = self.ofs_client.isroot('ofs://vol1/buk1/key')
+    is_root = self.ofs_client.isroot('ofs://ozone1/vol1/buk1/key')
+    assert_equal(is_root, False)
+
+    is_root = self.ofs_client.isroot('ofs://ozone1')
     assert_equal(is_root, False)
 
     is_root = self.ofs_client.isroot('ofs://')
@@ -95,19 +98,38 @@ class TestOFSClient(object):
     parent_path = self.ofs_client.parent_path('ofs://')
     assert_equal(parent_path, 'ofs://')
 
-    parent_path = self.ofs_client.parent_path('ofs://vol1/buk1/dir1/file1.csv')
-    assert_equal(parent_path, 'ofs://vol1/buk1/dir1')
+    parent_path = self.ofs_client.parent_path('ofs://ozone1/vol1/buk1/dir1/file1.csv')
+    assert_equal(parent_path, 'ofs://ozone1/vol1/buk1/dir1')
+
+    parent_path = self.ofs_client.parent_path('ofs://ozone1/vol1/buk1/key')
+    assert_equal(parent_path, 'ofs://ozone1/vol1/buk1')
 
-    parent_path = self.ofs_client.parent_path('ofs://vol1/buk1/key')
-    assert_equal(parent_path, 'ofs://vol1/buk1')
+    parent_path = self.ofs_client.parent_path('ofs://ozone1/vol1/buk1')
+    assert_equal(parent_path, 'ofs://ozone1/vol1')
 
-    parent_path = self.ofs_client.parent_path('ofs://vol1/buk1')
-    assert_equal(parent_path, 'ofs://vol1/')
+    parent_path = self.ofs_client.parent_path('ofs://ozone1/vol1')
+    assert_equal(parent_path, 'ofs://ozone1/')
 
-    parent_path = self.ofs_client.parent_path('ofs://vol1')
+    parent_path = self.ofs_client.parent_path('ofs://ozone1')
     assert_equal(parent_path, 'ofs://')
 
 
+  def test_listdir_stats_for_serviceid_path(self):
+    serviceid_stat = self.ofs_client.listdir_stats('ofs://')
+    assert_equal(
+      serviceid_stat[0].to_json_dict(),
+      {'path': 'ofs://ozone1', 'size': 0, 'atime': 0, 'mtime': 0, 'mode': 16895, 'user': '', 'group': '', 'blockSize': 0, 'replication': 0}
+    )
+
+
+  def test_stats_for_serviceid_path(self):
+    serviceid_stat = self.ofs_client.stats('ofs://')
+    assert_equal(
+      serviceid_stat.to_json_dict(),
+      {'path': 'ofs://ozone1', 'size': 0, 'atime': 0, 'mtime': 0, 'mode': 16895, 'user': '', 'group': '', 'blockSize': 0, 'replication': 0}
+    )
+
+
   @classmethod
   def tearDownClass(cls):
     for reset in cls._resets:

+ 3 - 3
desktop/core/src/desktop/lib/fs/ozone/ofsstat_test.py

@@ -26,14 +26,14 @@ class TestOzoneFSStat(object):
       'pathSuffix': 'testfile.csv', 'type': 'FILE', 'length': 32, 'owner': 'hueadmin', 'group': 'huegroup',
       'permission': '666', 'accessTime': 1677914460588, 'modificationTime': 1677914460588, 'blockSize': 268435456, 'replication': 3}
 
-    test_parent_path = '/gethue/'
+    test_parent_path = '/ozone1/gethue/'
 
     self.stat = OzoneFSStat(test_file_status, test_parent_path)
 
 
   def test_stat_attributes(self):
     assert_equal(self.stat.name, 'testfile.csv')
-    assert_equal(self.stat.path, 'ofs://gethue/testfile.csv')
+    assert_equal(self.stat.path, 'ofs://ozone1/gethue/testfile.csv')
     assert_equal(self.stat.isDir, False)
     assert_equal(self.stat.type, 'FILE')
     assert_equal(self.stat.atime, 1677914460)
@@ -50,7 +50,7 @@ class TestOzoneFSStat(object):
 
   def test_to_json_dict(self):
     expected_json_dict = {
-      'path': 'ofs://gethue/testfile.csv', 'size': 32, 'atime': 1677914460, 'mtime': 1677914460, 'mode': 33206, 'user': 'hueadmin',
+      'path': 'ofs://ozone1/gethue/testfile.csv', 'size': 32, 'atime': 1677914460, 'mtime': 1677914460, 'mode': 33206, 'user': 'hueadmin',
       'group': 'huegroup', 'blockSize': 268435456, 'replication': 3}
 
     assert_equal(self.stat.to_json_dict(), expected_json_dict)