]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: test the fs volume info cmd 47768/head
authorNeeraj Pratap Singh <neesingh@redhat.com>
Thu, 21 Apr 2022 12:01:23 +0000 (17:31 +0530)
committerNeeraj Pratap Singh <neesingh@redhat.com>
Tue, 23 Aug 2022 18:17:23 +0000 (23:47 +0530)
Fixes: https://tracker.ceph.com/issues/51434
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
(cherry picked from commit eaaea3bea306827a4f0b654fd26bb9f87fd73a92)

qa/tasks/cephfs/test_volumes.py

index 967e9425c4cd94e4bdb7588515d82f42c6e2e0b5..612b9340f722e9fee2eddb0d6ae4d2ae0547e04e 100644 (file)
@@ -207,6 +207,12 @@ class TestVolumesHelper(CephFSTestCase):
         else:
             self.volname = result[0]['name']
 
+    def  _get_volume_info(self, vol_name):
+        args = ["volume", "info", vol_name]
+        args = tuple(args)
+        vol_md = self._fs_cmd(*args)
+        return vol_md
+
     def  _get_subvolume_group_path(self, vol_name, group_name):
         args = ("subvolumegroup", "getpath", vol_name, group_name)
         path = self._fs_cmd(*args)
@@ -624,6 +630,38 @@ class TestVolumes(TestVolumesHelper):
         # data pool names unchanged
         self.assertCountEqual(orig_data_pool_names, list(self.fs.data_pools.values()))
 
+    def test_volume_info(self):
+        """
+        Tests the 'fs volume info' command
+        """
+        vol_fields = ["pools", "used_size", "pending_subvolume_deletions", "mon_addrs"]
+        group = self._generate_random_group_name()
+        # create subvolumegroup
+        self._fs_cmd("subvolumegroup", "create", self.volname, group)
+        # get volume metadata
+        vol_info = json.loads(self._get_volume_info(self.volname))
+        for md in vol_fields:
+            self.assertIn(md, vol_info,
+                          f"'{md}' key not present in metadata of volume")
+        self.assertEqual(vol_info["used_size"], 0,
+                         "Size should be zero when volumes directory is empty")
+
+    def test_volume_info_without_subvolumegroup(self):
+        """
+        Tests the 'fs volume info' command without subvolume group
+        """
+        vol_fields = ["pools", "mon_addrs"]
+        # get volume metadata
+        vol_info = json.loads(self._get_volume_info(self.volname))
+        for md in vol_fields:
+            self.assertIn(md, vol_info,
+                          f"'{md}' key not present in metadata of volume")
+        self.assertNotIn("used_size", vol_info,
+                         "'used_size' should not be present in absence of subvolumegroup")
+        self.assertNotIn("pending_subvolume_deletions", vol_info,
+                         "'pending_subvolume_deletions' should not be present in absence"
+                         " of subvolumegroup")
+
 
 class TestSubvolumeGroups(TestVolumesHelper):
     """Tests for FS subvolume group operations."""