]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/cephfs: add test_pool_perm
authorYan, Zheng <zyan@redhat.com>
Tue, 28 Apr 2015 04:52:36 +0000 (12:52 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 28 Apr 2015 12:38:32 +0000 (20:38 +0800)
This tests that client checks pool permission before
copy data to its cache.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
suites/fs/recovery/tasks/pool-perm.yaml [new file with mode: 0644]
tasks/cephfs/test_pool_perm.py [new file with mode: 0644]

diff --git a/suites/fs/recovery/tasks/pool-perm.yaml b/suites/fs/recovery/tasks/pool-perm.yaml
new file mode 100644 (file)
index 0000000..f220626
--- /dev/null
@@ -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 (file)
index 0000000..0d3b5eb
--- /dev/null
@@ -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)))