]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: use getfattr/setfattr helpers 14018/head
authorJohn Spray <john.spray@redhat.com>
Wed, 15 Mar 2017 19:36:08 +0000 (19:36 +0000)
committerJohn Spray <john.spray@redhat.com>
Fri, 14 Apr 2017 10:38:48 +0000 (06:38 -0400)
Signed-off-by: John Spray <john.spray@redhat.com>
qa/tasks/cephfs/test_backtrace.py
qa/tasks/cephfs/test_data_scan.py
qa/tasks/cephfs/test_pool_perm.py
qa/tasks/cephfs/test_strays.py

index 98255b8ff432f2a188e0fe2114ea5ae92c421b46..af246a1e347e0698f0febb884653639d3d6bdf7c 100644 (file)
@@ -44,7 +44,8 @@ class TestBacktrace(CephFSTestCase):
         new_pool_id = self.fs.add_data_pool(new_pool_name)
 
         # That an object which has switched pools gets its backtrace updated
-        self.mount_a.run_shell(["setfattr", "-n", "ceph.file.layout.pool", "-v", new_pool_name, "./parent_b/alpha"])
+        self.mount_a.setfattr("./parent_b/alpha",
+                              "ceph.file.layout.pool", new_pool_name)
         self.fs.mds_asok(["flush", "journal"])
         backtrace_old_pool = self.fs.read_backtrace(file_ino, pool=old_data_pool_name)
         self.assertEqual(backtrace_old_pool['pool'], new_pool_id)
@@ -64,7 +65,8 @@ class TestBacktrace(CephFSTestCase):
         self.assertEqual(['alpha', 'parent_c'], [a['dname'] for a in backtrace_new_pool['ancestors']])
 
         # That layout is written to new pool after change to other field in layout
-        self.mount_a.run_shell(["setfattr", "-n", "ceph.file.layout.object_size", "-v", "8388608", "./parent_c/alpha"])
+        self.mount_a.setfattr("./parent_c/alpha",
+                              "ceph.file.layout.object_size", "8388608")
 
         self.fs.mds_asok(["flush", "journal"])
         new_pool_layout = self.fs.read_layout(file_ino, pool=new_pool_name)
index aaa1b9adbbbe0b9bd3e257dd54027ce1182479c9..9b92216b9840871283341ebbcc958f397614ecba 100644 (file)
@@ -158,13 +158,11 @@ class StripedStashedLayout(Workload):
         # Create a dir with a striped layout set on it
         self._mount.run_shell(["mkdir", "stripey"])
 
-        self._mount.run_shell([
-            "setfattr", "-n", "ceph.dir.layout", "-v",
-            "stripe_unit={ss} stripe_count={sc} object_size={os} pool={pool}".format(
-                ss=self.ss, os=self.os, sc=self.sc,
-                pool=self._filesystem.get_data_pool_name()
-            ),
-            "./stripey"])
+        self._mount.setfattr("./stripey", "ceph.dir.layout",
+             "stripe_unit={ss} stripe_count={sc} object_size={os} pool={pool}".format(
+                 ss=self.ss, os=self.os, sc=self.sc,
+                 pool=self._filesystem.get_data_pool_name()
+             ))
 
         # Write files, then flush metadata so that its layout gets written into an xattr
         for i, n_bytes in enumerate(self.interesting_sizes):
@@ -289,15 +287,14 @@ class NonDefaultLayout(Workload):
     """
     def write(self):
         self._mount.run_shell(["touch", "datafile"])
-        self._mount.run_shell(["setfattr", "-n", "ceph.file.layout.object_size", "-v", "8388608", "./datafile"])
+        self._mount.setfattr("./datafile", "ceph.file.layout.object_size", "8388608")
         self._mount.run_shell(["dd", "if=/dev/urandom", "of=./datafile", "bs=1M", "count=32"])
         self._initial_state = self._mount.stat("datafile")
 
     def validate(self):
-        p = self._mount.run_shell(["sudo", "getfattr", "--only-values", "-n", "ceph.file.layout.object_size", "./datafile"])
-
         # Check we got the layout reconstructed properly
-        object_size = int(p.stdout.getvalue().strip())
+        object_size = int(self._mount.getfattr(
+            "./datafile", "ceph.file.layout.object_size"))
         self.assert_equal(object_size, 8388608)
 
         # Check we got the file size reconstructed properly
index edaa8ea4a66f7ad8b6811dad08e2d953141df029..22775e71c1b051efd9c320003dd1929a5fd1954e 100644 (file)
@@ -81,13 +81,11 @@ class TestPoolPerm(CephFSTestCase):
         self.mount_a.wait_until_mounted()
 
         with self.assertRaises(CommandFailedError):
-            self.mount_a.run_shell(["setfattr",
-                                    "-n", "ceph.file.layout.pool",
-                                    "-v", new_pool_name, "layoutfile"])
+            self.mount_a.setfattr("layoutfile", "ceph.file.layout.pool",
+                                  new_pool_name)
         with self.assertRaises(CommandFailedError):
-            self.mount_a.run_shell(["setfattr",
-                                    "-n", "ceph.dir.layout.pool",
-                                    "-v", new_pool_name, "layoutdir"])
+            self.mount_a.setfattr("layoutdir", "ceph.dir.layout.pool",
+                                  new_pool_name)
         self.mount_a.umount_wait()
 
         # Set MDS 'rwp' perms: should now be able to set layouts
@@ -100,12 +98,10 @@ class TestPoolPerm(CephFSTestCase):
             ))
         self.mount_a.mount()
         self.mount_a.wait_until_mounted()
-        self.mount_a.run_shell(["setfattr",
-                                "-n", "ceph.file.layout.pool",
-                                "-v", new_pool_name, "layoutfile"])
-        self.mount_a.run_shell(["setfattr",
-                                "-n", "ceph.dir.layout.pool",
-                                "-v", new_pool_name, "layoutdir"])
+        self.mount_a.setfattr("layoutfile", "ceph.file.layout.pool",
+                              new_pool_name)
+        self.mount_a.setfattr("layoutdir", "ceph.dir.layout.pool",
+                              new_pool_name)
         self.mount_a.umount_wait()
 
     def tearDown(self):
index 500a0aa84db57bcebecd7d6752931b12e4ac048b..a38f2b820305c9708e2b668054f7decabf3c4f27 100644 (file)
@@ -760,7 +760,7 @@ class TestStrays(CephFSTestCase):
         self.mount_a.run_shell(["touch", file_name])
 
         file_layout = "stripe_unit=1048576 stripe_count=4 object_size=8388608"
-        self.mount_a.run_shell(["setfattr", "-n", "ceph.file.layout", "-v", file_layout, file_name])
+        self.mount_a.setfattr(file_name, "ceph.file.layout", file_layout)
 
         # 35MB requires 7 objects
         size_mb = 35