diff --git a/qa/tasks/cephfs/test_misc.py b/qa/tasks/cephfs/test_misc.py index b72c92578fa79a..3d617d9a60db95 100644 --- a/qa/tasks/cephfs/test_misc.py +++ b/qa/tasks/cephfs/test_misc.py @@ -207,3 +207,46 @@ def test_dump_inode(self): info = self.fs.mds_asok(['dump', 'inode', '1']) assert(info['path'] == "/") + def test_drop_cache_command(self): + """ + Basic test for checking drop cache command. Note that the cache size + post trimming is not checked here. + """ + + self.mount_b.umount_wait() + ls_data = self.fs.mds_asok(['session', 'ls']) + self.assert_session_count(1, ls_data) + + # create some files + self.mount_a.create_n_files("dc-dir/dc-file", 1000) + + # drop cache + drop_res = self.fs.mds_asok(['cache', 'drop', '10']) + self.assertTrue(drop_res['client_recall']['return_code'] == 0) + self.assertTrue(drop_res['flush_journal']['return_code'] == 0) + + def test_drop_cache_command_timeout(self): + """ + Check drop cache command with non-responding client. Note that the + cache size post trimming is not checked here. + """ + + self.mount_b.umount_wait() + ls_data = self.fs.mds_asok(['session', 'ls']) + self.assert_session_count(1, ls_data) + + # create some files + self.mount_a.create_n_files("dc-dir/dc-file-t", 1000) + + # simulate client death + self.mount_a.kill() + + # drop cache + drop_res = self.fs.mds_asok(['cache', 'drop', '5']) + + self.assertTrue(drop_res['client_recall']['return_code'] == errno.ETIMEDOUT) + self.assertTrue(drop_res['flush_journal']['return_code'] == 0) + + self.mount_a.kill_cleanup() + self.mount_a.mount() + self.mount_a.wait_until_mounted()