]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: add tests for normalization configuration on subvolume creation
authorXavi Hernandez <xhernandez@gmail.com>
Wed, 19 Mar 2025 12:12:42 +0000 (13:12 +0100)
committerXavi Hernandez <xhernandez@gmail.com>
Tue, 25 Mar 2025 13:45:55 +0000 (14:45 +0100)
Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
qa/tasks/cephfs/test_volumes.py
src/pybind/mgr/volumes/fs/operations/versions/subvolume_base.py

index f1baba16eee6ee464e90c24313e61b4daffbc212..e79c0ee802666f90dbfe263d1b9cf8e9bb54da7c 100644 (file)
@@ -2686,6 +2686,36 @@ class TestSubvolumes(TestVolumesHelper):
             except CommandFailedError as ce:
                 self.assertEqual(ce.exitstatus, errno.ENOENT, error_message)
 
+    def test_subvolume_create_without_normalization(self):
+        # create subvolume
+        subvolume = self._gen_subvol_name()
+        self._fs_cmd("subvolume", "create", self.volname, subvolume)
+
+        # make sure it exists
+        subvolpath = self._get_subvolume_path(self.volname, subvolume)
+        self.assertNotEqual(subvolpath, None)
+
+        # check normalization
+        try:
+            self._fs_cmd("subvolume", "charmap", "get", self.volname, subvolume, "normalization")
+        except CommandFailedError as ce:
+            self.assertEqual(ce.exitstatus, errno.ENODATA)
+        else:
+            self.fail("expected the 'fs subvolume charmap' command to fail")
+
+    def test_subvolume_create_with_normalization(self):
+        # create subvolume
+        subvolume = self._gen_subvol_name()
+        self._fs_cmd("subvolume", "create", self.volname, subvolume, "--normalization", "nfc")
+
+        # make sure it exists
+        subvolpath = self._get_subvolume_path(self.volname, subvolume)
+        self.assertNotEqual(subvolpath, None)
+
+        # check normalization
+        normalization = self._fs_cmd("subvolume", "charmap", "get", self.volname, subvolume, "normalization")
+        self.assertEqual(normalization.strip(), "nfc")
+
     def test_subvolume_expand(self):
         """
         That a subvolume can be expanded in size and its quota matches the expected size.
index c360a28bcdf9a3551be9b3d2d5fc83b3574aba39..7a6dde11750b75719bce85bd0f7be16203c1b8a4 100644 (file)
@@ -210,6 +210,12 @@ class SubvolumeBase(object):
         except cephfs.NoData:
             attrs["normalization"] = None
 
+        try:
+            case_insensitive = self.fs.getxattr(pathname, 'ceph.dir.caseinsensitive').decode('utf-8')
+            attrs["case_insensitive"] = case_insensitive == "0"
+        except cephfs.NoData:
+            attrs["case_insensitive"] = False
+
         return attrs
 
     def set_attrs(self, path, attrs):
@@ -308,6 +314,13 @@ class SubvolumeBase(object):
             except cephfs.Error as e:
                 raise VolumeException(-e.args[0], e.args[1])
 
+        case_insensitive = attrs.get("case_insensitive")
+        if case_insensitive:
+            try:
+                self.fs.setxattr(path, "ceph.dir.casesensitive", "0".encode('utf-8'), 0)
+            except cephfs.Error as e:
+                raise VolumeException(-e.args[0], e.args[1])
+
     def _resize(self, path, newsize, noshrink):
         try:
             newsize = int(newsize)
@@ -473,6 +486,14 @@ class SubvolumeBase(object):
         except cephfs.NoData:
             normalization = "none"
 
+        try:
+            case_insensitive = self.fs.getxattr(subvolpath,
+                                                'ceph.dir.casesensitive'
+                                                ).decode('utf-8')
+            case_insensitive = case_insensitive == "0"
+        except cephfs.NoData:
+            case_insensitive = False
+
         return {'path': subvolpath,
                 'type': etype.value,
                 'uid': int(st["uid"]),
@@ -493,6 +514,7 @@ class SubvolumeBase(object):
                 'state': self.state.value,
                 'earmark': earmark,
                 'normalization': normalization,
+                'case_insensitive': case_insensitive,
         }
 
     def set_user_metadata(self, keyname, value):