From: John Spray Date: Wed, 15 Mar 2017 19:36:08 +0000 (+0000) Subject: qa/cephfs: use getfattr/setfattr helpers X-Git-Tag: v12.0.3~276^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dd43d3bc646aeab88486b0963fc83de0b18800c4;p=ceph.git qa/cephfs: use getfattr/setfattr helpers Signed-off-by: John Spray --- diff --git a/qa/tasks/cephfs/test_backtrace.py b/qa/tasks/cephfs/test_backtrace.py index 98255b8ff432..af246a1e347e 100644 --- a/qa/tasks/cephfs/test_backtrace.py +++ b/qa/tasks/cephfs/test_backtrace.py @@ -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) diff --git a/qa/tasks/cephfs/test_data_scan.py b/qa/tasks/cephfs/test_data_scan.py index aaa1b9adbbbe..9b92216b9840 100644 --- a/qa/tasks/cephfs/test_data_scan.py +++ b/qa/tasks/cephfs/test_data_scan.py @@ -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 diff --git a/qa/tasks/cephfs/test_pool_perm.py b/qa/tasks/cephfs/test_pool_perm.py index edaa8ea4a66f..22775e71c1b0 100644 --- a/qa/tasks/cephfs/test_pool_perm.py +++ b/qa/tasks/cephfs/test_pool_perm.py @@ -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): diff --git a/qa/tasks/cephfs/test_strays.py b/qa/tasks/cephfs/test_strays.py index 500a0aa84db5..a38f2b820305 100644 --- a/qa/tasks/cephfs/test_strays.py +++ b/qa/tasks/cephfs/test_strays.py @@ -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