From 5688476513a78cf9ab2cf3b1f65e6244f05ea73d Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 1 May 2018 12:26:51 +0800 Subject: [PATCH] qa/tasks/cephfs: add test for renewing stale session Signed-off-by: "Yan, Zheng" --- .../tasks/client-recovery.yaml | 1 + .../recovery/tasks/client-recovery.yaml | 1 + qa/tasks/cephfs/fuse_mount.py | 8 ++++- qa/tasks/cephfs/test_client_recovery.py | 36 +++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/qa/suites/fs/basic_functional/tasks/client-recovery.yaml b/qa/suites/fs/basic_functional/tasks/client-recovery.yaml index f5e9a0b5cf461..a2f56299b221a 100644 --- a/qa/suites/fs/basic_functional/tasks/client-recovery.yaml +++ b/qa/suites/fs/basic_functional/tasks/client-recovery.yaml @@ -10,5 +10,6 @@ overrides: tasks: - cephfs_test_runner: + fail_on_skip: false modules: - tasks.cephfs.test_client_recovery diff --git a/qa/suites/kcephfs/recovery/tasks/client-recovery.yaml b/qa/suites/kcephfs/recovery/tasks/client-recovery.yaml index 72ce013fabfc9..725a259d24f32 100644 --- a/qa/suites/kcephfs/recovery/tasks/client-recovery.yaml +++ b/qa/suites/kcephfs/recovery/tasks/client-recovery.yaml @@ -10,5 +10,6 @@ overrides: tasks: - cephfs_test_runner: + fail_on_skip: false modules: - tasks.cephfs.test_client_recovery diff --git a/qa/tasks/cephfs/fuse_mount.py b/qa/tasks/cephfs/fuse_mount.py index 8503698609812..30de6051c0b25 100644 --- a/qa/tasks/cephfs/fuse_mount.py +++ b/qa/tasks/cephfs/fuse_mount.py @@ -409,9 +409,15 @@ print find_socket("{client_name}") """ Look up the CephFS client ID for this mount """ - return self.admin_socket(['mds_sessions'])['id'] + def get_client_pid(self): + """ + return pid of ceph-fuse process + """ + status = self.admin_socket(['status']) + return status['metadata']['pid'] + def get_osd_epoch(self): """ Return 2-tuple of osd_epoch, osd_epoch_barrier diff --git a/qa/tasks/cephfs/test_client_recovery.py b/qa/tasks/cephfs/test_client_recovery.py index 8f1df98940445..c70e224714eda 100644 --- a/qa/tasks/cephfs/test_client_recovery.py +++ b/qa/tasks/cephfs/test_client_recovery.py @@ -11,8 +11,10 @@ import re import os from teuthology.orchestra.run import CommandFailedError, ConnectionLostError +from tasks.cephfs.fuse_mount import FuseMount from tasks.cephfs.cephfs_test_case import CephFSTestCase from teuthology.packaging import get_package_version +from unittest import SkipTest log = logging.getLogger(__name__) @@ -483,3 +485,37 @@ class TestClientRecovery(CephFSTestCase): self.fs.mds_asok(['session', 'evict', "%s" % mount_a_client_id]) self.mount_a.umount_wait(require_clean=True, timeout=30) + + def test_stale_renew(self): + if not isinstance(self.mount_a, FuseMount): + raise SkipTest("Require FUSE client to handle signal STOP/CONT") + + session_timeout = self.fs.get_var("session_timeout") + + self.mount_a.run_shell(["mkdir", "testdir"]) + self.mount_a.run_shell(["touch", "testdir/file1"]) + # populate readdir cache + self.mount_a.run_shell(["ls", "testdir"]) + self.mount_b.run_shell(["ls", "testdir"]) + + # check if readdir cache is effective + initial_readdirs = self.fs.mds_asok(['perf', 'dump', 'mds_server', 'req_readdir_latency']) + self.mount_b.run_shell(["ls", "testdir"]) + current_readdirs = self.fs.mds_asok(['perf', 'dump', 'mds_server', 'req_readdir_latency']) + self.assertEqual(current_readdirs, initial_readdirs); + + mount_b_gid = self.mount_b.get_global_id() + mount_b_pid = self.mount_b.get_client_pid() + # stop ceph-fuse process of mount_b + self.mount_b.client_remote.run(args=["sudo", "kill", "-STOP", mount_b_pid]) + + self.assert_session_state(mount_b_gid, "open") + time.sleep(session_timeout * 1.5) # Long enough for MDS to consider session stale + self.assert_session_state(mount_b_gid, "stale") + + self.mount_a.run_shell(["touch", "testdir/file2"]) + + # resume ceph-fuse process of mount_b + self.mount_b.client_remote.run(args=["sudo", "kill", "-CONT", mount_b_pid]) + # Is the new file visible from mount_b? (caps become invalid after session stale) + self.mount_b.run_shell(["ls", "testdir/file2"]) -- 2.39.5