From 877a79d8cfb00a036f6c725d635deeb24f2f5bee Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Tue, 18 Jun 2019 18:54:19 +0530 Subject: [PATCH] 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 --- qa/tasks/cephfs/test_cephfs_shell.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 -- 2.39.5