From: Varsha Rao Date: Thu, 3 Oct 2019 08:26:27 +0000 (+0530) Subject: cephfs-shell: Add tests for df command X-Git-Tag: v15.1.0~591^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2c1c683b19829a3ca2f7008397c3f08b23ce38d2;p=ceph.git cephfs-shell: Add tests for df command This patch adds tests for valid and invalid directory, valid files and testing df without any arguments. Signed-off-by: Varsha Rao --- diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index 151a1117edef..705451af45fa 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -560,6 +560,47 @@ class TestDU(TestCephFSShell): "expected_output -\n{}\ndu_output -\n{}\n".format( expected_output, du_output) + +class TestDF(TestCephFSShell): + def validate_df(self, filename): + df_output = self.get_cephfs_shell_cmd_output('df '+filename) + log.info("cephfs-shell df output:\n{}".format(df_output)) + + shell_df = df_output.splitlines()[1].split() + + block_size = int(self.mount_a.df()["total"]) // 1024 + log.info("cephfs df block size output:{}\n".format(block_size)) + + st_size = int(self.mount_a.stat(filename)["st_size"]) + log.info("cephfs stat used output:{}".format(st_size)) + log.info("cephfs available:{}\n".format(block_size - st_size)) + + self.assertTupleEqual((block_size, st_size, block_size - st_size), + (int(shell_df[0]), int(shell_df[1]) , int(shell_df[2]))) + + def test_df_with_no_args(self): + expected_output = '' + df_output = self.get_cephfs_shell_cmd_output('df') + assert df_output == expected_output + + def test_df_for_valid_directory(self): + dir_name = 'dir1' + mount_output = self.mount_a.run_shell('mkdir ' + dir_name) + log.info("cephfs-shell mount output:\n{}".format(mount_output)) + self.validate_df(dir_name) + + def test_df_for_invalid_directory(self): + dir_abspath = path.join(self.mount_a.mountpoint, 'non-existent-dir') + proc = self.run_cephfs_shell_cmd('df ' + dir_abspath) + assert proc.stderr.getvalue().find('error in stat') != -1 + + def test_df_for_valid_file(self): + s = 'df test' * 14145016 + o = self.get_cephfs_shell_cmd_output("put - dumpfile", stdin=s) + log.info("cephfs-shell output:\n{}".format(o)) + self.validate_df("dumpfile") + + # def test_ls(self): # """ # Test that ls passes