From 539117a38ddebb78e05f5ae37e32cb1dfd439842 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 28 Apr 2015 12:52:36 +0800 Subject: [PATCH] tasks/cephfs: add test_pool_perm This tests that client checks pool permission before copy data to its cache. Signed-off-by: Yan, Zheng --- suites/fs/recovery/tasks/pool-perm.yaml | 5 +++ tasks/cephfs/test_pool_perm.py | 47 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 suites/fs/recovery/tasks/pool-perm.yaml create mode 100644 tasks/cephfs/test_pool_perm.py diff --git a/suites/fs/recovery/tasks/pool-perm.yaml b/suites/fs/recovery/tasks/pool-perm.yaml new file mode 100644 index 0000000000000..f220626df62fe --- /dev/null +++ b/suites/fs/recovery/tasks/pool-perm.yaml @@ -0,0 +1,5 @@ + +tasks: + - cephfs_test_runner: + modules: + - tasks.cephfs.test_pool_perm diff --git a/tasks/cephfs/test_pool_perm.py b/tasks/cephfs/test_pool_perm.py new file mode 100644 index 0000000000000..0d3b5eb80f73e --- /dev/null +++ b/tasks/cephfs/test_pool_perm.py @@ -0,0 +1,47 @@ + +from textwrap import dedent +from tasks.cephfs.cephfs_test_case import CephFSTestCase +import os + +class TestPoolPerm(CephFSTestCase): + def test_pool_perm(self): + self.mount_a.run_shell(["touch", "test_file"]) + + file_path = os.path.join(self.mount_a.mountpoint, "test_file") + + remote_script = dedent(""" + import os + import errno + + fd = os.open("{path}", os.O_RDWR) + try: + if {check_read}: + ret = os.read(fd, 1024) + else: + os.write(fd, 'content') + except OSError, e: + if e.errno != errno.EPERM: + raise + else: + raise RuntimeError("client does not check permission of data pool") + """) + + # set data pool read only + self.fs.mon_manager.raw_cluster_cmd_result('auth', 'caps', 'client.0', 'mon', 'allow r', 'osd', 'allow r pool=data') + + self.mount_a.umount_wait() + self.mount_a.mount() + self.mount_a.wait_until_mounted() + + # write should fail + self.mount_a.run_python(remote_script.format(path=file_path, check_read=str(False))) + + # set data pool write only + self.fs.mon_manager.raw_cluster_cmd_result('auth', 'caps', 'client.0', 'mon', 'allow r', 'osd', 'allow w pool=data') + + self.mount_a.umount_wait() + self.mount_a.mount() + self.mount_a.wait_until_mounted() + + # read should fail + self.mount_a.run_python(remote_script.format(path=file_path, check_read=str(True))) -- 2.39.5