From 2f4980f394301fca793af9ca513aca6fa1d1822a Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Thu, 12 Nov 2020 14:18:16 +0800 Subject: [PATCH] qa: test_readahead add kernel client support If the "ceph.cluster_fsid" and "ceph.client_id" vxattrs or the "metric" debug file are not support yet, will assume the test succeeds. Fixes: https://tracker.ceph.com/issues/48053 Signed-off-by: Xiubo Li --- qa/tasks/cephfs/fuse_mount.py | 3 +++ qa/tasks/cephfs/kernel_mount.py | 7 +++++++ qa/tasks/cephfs/mount.py | 3 +++ qa/tasks/cephfs/test_readahead.py | 9 +++------ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/qa/tasks/cephfs/fuse_mount.py b/qa/tasks/cephfs/fuse_mount.py index 360c4a32b110..711a39786691 100644 --- a/qa/tasks/cephfs/fuse_mount.py +++ b/qa/tasks/cephfs/fuse_mount.py @@ -511,3 +511,6 @@ print(_find_admin_socket("{client_name}")) def set_cache_size(self, size): return self.admin_socket(['config', 'set', 'client_cache_size', str(size)]) + + def get_op_read_count(self): + return self.admin_socket(['perf', 'dump', 'objecter'])['objecter']['osdop_read'] diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index 03ab3ddaaa86..9845454199ad 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -286,3 +286,10 @@ class KernelMount(CephFSMount): epoch, barrier = int(first_line_tokens[1]), int(first_line_tokens[3]) return epoch, barrier + + def get_op_read_count(self): + buf = self.read_debug_file("metrics") + if buf is None: + return 0 + else: + return int(re.findall(r'read.*', buf)[0].split()[1]) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 61fd1574e40e..6d2ce064768f 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -1104,6 +1104,9 @@ class CephFSMount(object): def get_osd_epoch(self): raise NotImplementedError() + def get_op_read_count(self): + raise NotImplementedError() + def lstat(self, fs_path, follow_symlinks=False, wait=True): return self.stat(fs_path, follow_symlinks=False, wait=True) diff --git a/qa/tasks/cephfs/test_readahead.py b/qa/tasks/cephfs/test_readahead.py index 28c544c64943..b1484ab0713e 100644 --- a/qa/tasks/cephfs/test_readahead.py +++ b/qa/tasks/cephfs/test_readahead.py @@ -1,5 +1,4 @@ import logging -from tasks.cephfs.fuse_mount import FuseMount from tasks.cephfs.cephfs_test_case import CephFSTestCase log = logging.getLogger(__name__) @@ -7,9 +6,6 @@ log = logging.getLogger(__name__) class TestReadahead(CephFSTestCase): def test_flush(self): - if not isinstance(self.mount_a, FuseMount): - self.skipTest("FUSE needed for measuring op counts") - # Create 32MB file self.mount_a.run_shell(["dd", "if=/dev/urandom", "of=foo", "bs=1M", "count=32"]) @@ -17,9 +13,10 @@ class TestReadahead(CephFSTestCase): self.mount_a.umount_wait() self.mount_a.mount_wait() - initial_op_read = self.mount_a.admin_socket(['perf', 'dump', 'objecter'])['objecter']['osdop_read'] + initial_op_read = self.mount_a.get_op_read_count() self.mount_a.run_shell(["dd", "if=foo", "of=/dev/null", "bs=128k", "count=32"]) - op_read = self.mount_a.admin_socket(['perf', 'dump', 'objecter'])['objecter']['osdop_read'] + op_read = self.mount_a.get_op_read_count() + assert op_read >= initial_op_read op_read -= initial_op_read log.info("read operations: {0}".format(op_read)) -- 2.47.3