From: Rishabh Dave Date: Tue, 18 Jun 2019 13:24:19 +0000 (+0530) Subject: test_cephfs_shell: test du's output for hardlinks X-Git-Tag: v15.1.0~1555^2~14 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=877a79d8cfb00a036f6c725d635deeb24f2f5bee;p=ceph-ci.git test_cephfs_shell: test du's output for hardlinks Test that CephFS shell command du prints output for directories as expected. Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index fd9f986f161..f3469222178 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -375,6 +375,25 @@ class TestDU(TestCephFSShell): "expected_output -\n{}\ndu_output -\n{}\n".format( expected_output, du_output) + def test_du_works_for_hardlinks(self): + regfilename = 'some_regfile' + regfile_abspath = path.join(self.mount_a.mountpoint, regfilename) + sudo_write_file(self.mount_a.client_remote, regfile_abspath, 'somedata') + hlinkname = 'some_hardlink' + hlink_abspath = path.join(self.mount_a.mountpoint, hlinkname) + self.mount_a.run_shell(['ln', regfile_abspath, hlink_abspath]) + + size = humansize(self.mount_a.stat(hlink_abspath)['st_size']) + expected_output = r'{}{}{}'.format(size, " +", hlinkname) + + du_output = self.get_cephfs_shell_cmd_output('du ' + hlinkname) + if sys_version_info.major >= 3: + self.assertRegex(expected_output, du_output) + elif sys_version_info.major < 3: + assert re_search(expected_output, du_output) != None, "\n" + \ + "expected_output -\n{}\ndu_output -\n{}\n".format( + expected_output, du_output) + # def test_ls(self): # """ # Test that ls passes