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)
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)