]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs: add test for renewing stale session 21712/head
authorYan, Zheng <zyan@redhat.com>
Tue, 1 May 2018 04:26:51 +0000 (12:26 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 3 May 2018 02:50:28 +0000 (10:50 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
qa/suites/fs/basic_functional/tasks/client-recovery.yaml
qa/suites/kcephfs/recovery/tasks/client-recovery.yaml
qa/tasks/cephfs/fuse_mount.py
qa/tasks/cephfs/test_client_recovery.py

index f5e9a0b5cf46169a2a7a92dbe508941f25e6ad4b..a2f56299b221ab995bb74cce0c3d672e0dcee200 100644 (file)
@@ -10,5 +10,6 @@ overrides:
 
 tasks:
   - cephfs_test_runner:
+      fail_on_skip: false
       modules:
         - tasks.cephfs.test_client_recovery
index 72ce013fabfc9c4c71692c8189b5b20a02630980..725a259d24f3225504bee08611a34d48e3ce7282 100644 (file)
@@ -10,5 +10,6 @@ overrides:
 
 tasks:
   - cephfs_test_runner:
+      fail_on_skip: false
       modules:
         - tasks.cephfs.test_client_recovery
index 8503698609812f9be7a48b8e45210f397e65db6b..30de6051c0b2542a0330a5d7fe61b9357bba24a8 100644 (file)
@@ -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
index 8f1df9894044583a5a8ee188752c5db16b5fb11a..c70e224714eda00ca568e3f5a37975640f7a51db 100644 (file)
@@ -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"])