]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add test for validating cephfs-mirror daemon service status 39408/head
authorVenky Shankar <vshankar@redhat.com>
Tue, 16 Feb 2021 09:22:06 +0000 (04:22 -0500)
committerVenky Shankar <vshankar@redhat.com>
Fri, 5 Mar 2021 06:00:01 +0000 (01:00 -0500)
Fixes: http://tracker.ceph.com/issues/48943
Signed-off-by: Venky Shankar <vshankar@redhat.com>
qa/tasks/cephfs/test_mirroring.py

index 2994f1ccc231ff5ff88d774e59dd6bacdb8efaad..45ef59d7ea14660d5ccb980b8623271b91539495 100644 (file)
@@ -219,6 +219,28 @@ class TestMirroring(CephFSTestCase):
         log.debug(f'command returned={res}')
         return json.loads(res)
 
+    def get_mirror_daemon_id(self):
+        ceph_status = json.loads(self.fs.mon_manager.raw_cluster_cmd("status", "--format=json"))
+        log.debug(f'ceph_status: {ceph_status}')
+        daemon_id = None
+        for k in ceph_status['servicemap']['services']['cephfs-mirror']['daemons']:
+            try:
+                daemon_id = int(k)
+                break #nit, only a single mirror daemon is expected -- bail out.
+            except ValueError:
+                pass
+
+        log.debug(f'daemon_id: {daemon_id}')
+        self.assertTrue(daemon_id is not None)
+        return daemon_id
+
+    def get_mirror_daemon_status(self, daemon_id, fs_name, fs_id):
+        daemon_status = json.loads(self.mgr_cluster.mon_manager.raw_cluster_cmd("fs", "snapshot", "mirror", "daemon", "status", fs_name))
+        log.debug(f'daemon_status: {daemon_status}')
+        status = daemon_status[str(daemon_id)][str(fs_id)]
+        log.debug(f'status: {status}')
+        return status
+
     def test_basic_mirror_commands(self):
         self.enable_mirroring(self.primary_fs_name, self.primary_fs_id)
         self.disable_mirroring(self.primary_fs_name, self.primary_fs_id)
@@ -625,3 +647,46 @@ class TestMirroring(CephFSTestCase):
         self.check_peer_status(self.primary_fs_name, self.primary_fs_id,
                                "client.mirror_remote@ceph", '/d0', 'snap0', 1)
         self.disable_mirroring(self.primary_fs_name, self.primary_fs_id)
+
+    def test_cephfs_mirror_service_daemon_status(self):
+        self.enable_mirroring(self.primary_fs_name, self.primary_fs_id)
+        self.peer_add(self.primary_fs_name, self.primary_fs_id, "client.mirror_remote@ceph", self.secondary_fs_name)
+        peer_uuid = self.get_peer_uuid("client.mirror_remote@ceph")
+
+        daemon_id = self.get_mirror_daemon_id()
+
+        time.sleep(30)
+        status = self.get_mirror_daemon_status(daemon_id, self.primary_fs_name, self.primary_fs_id)
+
+        # we have not added any directories
+        self.assertEquals(status['directory_count'], 0)
+
+        peer_stats = status['peers'][peer_uuid]['stats']
+        self.assertEquals(peer_stats['failure_count'], 0)
+        self.assertEquals(peer_stats['recovery_count'], 0)
+
+        # add a non-existent directory for synchronization -- check if its reported
+        # in daemon stats
+        self.add_directory(self.primary_fs_name, self.primary_fs_id, '/d0')
+
+        time.sleep(120)
+        status = self.get_mirror_daemon_status(daemon_id, self.primary_fs_name, self.primary_fs_id)
+        # we added one
+        self.assertEquals(status['directory_count'], 1)
+        peer_stats = status['peers'][peer_uuid]['stats']
+        # failure count should be reflected
+        self.assertEquals(peer_stats['failure_count'], 1)
+        self.assertEquals(peer_stats['recovery_count'], 0)
+
+        # create the directory, mirror daemon would recover
+        self.mount_a.run_shell(["mkdir", "d0"])
+
+        time.sleep(120)
+        status = self.get_mirror_daemon_status(daemon_id, self.primary_fs_name, self.primary_fs_id)
+        self.assertEquals(status['directory_count'], 1)
+        peer_stats = status['peers'][peer_uuid]['stats']
+        # failure and recovery count should be reflected
+        self.assertEquals(peer_stats['failure_count'], 1)
+        self.assertEquals(peer_stats['recovery_count'], 1)
+
+        self.disable_mirroring(self.primary_fs_name, self.primary_fs_id)