From 0aca27d2fcb17e4e5b5ef339b2d1d011d52dbd6c Mon Sep 17 00:00:00 2001 From: dparmar18 Date: Mon, 23 May 2022 14:45:40 +0530 Subject: [PATCH] qa/cephfs: fallback to older way of get_op_read_count Fixes: https://tracker.ceph.com/issues/55538 Signed-off-by: Dhairya Parmar --- qa/tasks/cephfs/kernel_mount.py | 26 +++++++++++++++++++++----- qa/tasks/cephfs/test_readahead.py | 3 +-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index 8d11b01028c..22eb8d95114 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -1,3 +1,4 @@ +import errno import json import logging import os @@ -349,8 +350,23 @@ echo '{fdata}' | sudo tee /sys/kernel/debug/dynamic_debug/control return epoch, barrier def get_op_read_count(self): - buf = self.read_debug_file("metrics/size") - if buf is None: - return 0 - else: - return int(re.findall(r'read.*', buf)[0].split()[1]) + stdout = StringIO() + stderr = StringIO() + try: + path = os.path.join(self._get_debug_dir(), "metrics/size") + self.run_shell(f"sudo stat {path}", stdout=stdout, + stderr=stderr, cwd=None) + buf = self.read_debug_file("metrics/size") + except CommandFailedError: + if 'no such file or directory' in stderr.getvalue().lower() \ + or 'not a directory' in stderr.getvalue().lower(): + try: + path = os.path.join(self._get_debug_dir(), "metrics") + self.run_shell(f"sudo stat {path}", stdout=stdout, + stderr=stderr, cwd=None) + buf = self.read_debug_file("metrics") + except CommandFailedError: + return errno.ENOENT + else: + return 0 + return int(re.findall(r'read.*', buf)[0].split()[1]) diff --git a/qa/tasks/cephfs/test_readahead.py b/qa/tasks/cephfs/test_readahead.py index b1484ab0713..7e6270f035d 100644 --- a/qa/tasks/cephfs/test_readahead.py +++ b/qa/tasks/cephfs/test_readahead.py @@ -16,8 +16,7 @@ class TestReadahead(CephFSTestCase): 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.get_op_read_count() - - assert op_read >= initial_op_read + self.assertGreaterEqual(op_read, initial_op_read) op_read -= initial_op_read log.info("read operations: {0}".format(op_read))