]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/mds_client_recovery: client trim its cache on reconnect
authorYan, Zheng <zyan@redhat.com>
Mon, 29 Sep 2014 09:13:20 +0000 (17:13 +0800)
committerJohn Spray <jspray@redhat.com>
Mon, 29 Sep 2014 19:59:43 +0000 (20:59 +0100)
make sure CephFS client trim its cache before reconnect to the MDS.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
tasks/mds_client_recovery.py

index 6f65575ffdd44dac705037359b639ddd9c6dfcea..fcbfc53a6977a688f91e2cbd05710d186b8951c2 100644 (file)
@@ -84,6 +84,10 @@ class TestClientRecovery(CephFSTestCase):
         self.mount_a.create_destroy()
         self.mount_b.create_destroy()
 
+    def _session_num_caps(self, client_id):
+        ls_data = self.fs.mds_asok(['session', 'ls'])
+        return int(self._session_by_id(ls_data).get(client_id, {'num_caps': None})['num_caps'])
+
     def test_reconnect_timeout(self):
         # Reconnect timeout
         # =================
@@ -252,6 +256,34 @@ class TestClientRecovery(CephFSTestCase):
         self.mount_a.mount()
         self.mount_a.wait_until_mounted()
 
+    def test_trim_caps(self):
+        # Trim capability when reconnecting MDS
+        # ===================================
+
+        count = 500
+        # Create lots of files
+        for i in range(count):
+            self.mount_a.run_shell(["sudo", "touch", "f{0}".format(i)])
+
+        # Populate mount_b's cache
+        self.mount_b.run_shell(["sudo", "ls"])
+
+        client_id = self.mount_b.get_global_id()
+        num_caps = self._session_num_caps(client_id)
+        self.assertGreaterEqual(num_caps, count)
+
+        # Restart MDS. client should trim its cache when reconnecting to the MDS
+        self.fs.mds_stop()
+        self.fs.mds_fail()
+        self.fs.mds_restart()
+        self.fs.wait_for_state('up:active', timeout=MDS_RESTART_GRACE)
+
+        num_caps = self._session_num_caps(client_id)
+        self.assertLess(num_caps, count,
+                        "should have less than {0} capabilities, have {1}".format(
+                            count, num_caps
+                        ))
+
     def test_network_death(self):
         """
         Simulate software freeze or temporary network failure.