Commit Graph

67 Commits

Author SHA1 Message Date
Rishabh Dave
485841b255 qa: import CommandFailedError from exceptions not run
Stop importing CommandFailedError from teuthology.orchestra.run, it is
actually defined in teuthology.exception.

Fixes: https://tracker.ceph.com/issues/51226
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2021-10-05 23:41:09 +05:30
Patrick Donnelly
e2b39f6c8c
qa: avoid using sudo for regular test artifacts
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
2021-07-01 10:56:10 -07:00
Patrick Donnelly
8a1ee83b1a
qa: use run_shell_payload to avoid sudo
"run_shell" adds 'sudo' which runs afoul of new security protections on
Ubuntu 20.04.

Fixes: https://tracker.ceph.com/issues/51417
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
2021-07-01 10:56:10 -07:00
Tarang Sharma
8e1afc35f8 test_cephfs_shell: add tests for ls command
Signed-off-by: Tarang Sharma <tarangnsharma@gmail.com>
2020-12-04 00:03:19 +05:30
Kyr Shatskyy
af0f2d20eb qa/tasks/cephfs: use remote.write_file instead of misc.sudo_write_file
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
2020-09-04 00:02:15 +02:00
Kefu Chai
76c4e68be4 qa/tasks/cephfs: drop python2 support
Signed-off-by: Kefu Chai <kchai@redhat.com>
2020-07-21 19:52:11 +08:00
Kefu Chai
ee90f40905 qa/tasks/cephfs: drop py2 support
Signed-off-by: Kefu Chai <kchai@redhat.com>
2020-07-05 10:58:28 +08:00
Kefu Chai
21ad5bf2eb qa/tasks/cephfs: flake8 fixes
Signed-off-by: Kefu Chai <kchai@redhat.com>
2020-06-24 10:12:11 +08:00
Rishabh Dave
58c7c7e8f4 test_cephfs_shell: run cephfs-shell with conf file
And set colors to False and debug to True in this conf file.

stdout captured by Python code in this testsuite can contain the colour
codes along with the expected string output. Setting colors to False in
cephfs-shell.conf should fix this.

Setting debug to False should help with analyzing test failures since
it enables printing messages that helps debugging (stacktrace for
cephfs-shell code, for example).

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-17 17:21:31 +05:30
Rishabh Dave
99d944ce67 test_cephfs_shell: remove test_every_shell_cmd_at_invocation
The reason behind adding and removing this test in different commits of
the same PR is that test_every_shell_cmd_at_invocation is to keep it in
case it's needed later. It reruns all tests in this testsuite by issuing
all cephfs shell commands as arguments to cephfs-shell instead of
issuing them on stdin.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-05 09:41:17 +05:30
Rishabh Dave
a11b3c0177 test_cephfs_shell: catch specific exception instead of catching all
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-05 09:41:17 +05:30
Rishabh Dave
9b2077ff10 cephfs-shell: set return value before exiting
Code for each command has a return value set yet cephfs-shell itself
doesn't exit with proper return value. This makes cephfs-shell quit with
zero return value all the time.

Also, many tests execute cephfs-shell commands expecting the command to
fail but without expecting the method issuing the command to fail. Fix
these test accordingly by adding a new method (negtest_cephfs_shell_cmd)
that expects the command to fail and allows verifying return value and
error messages.

Fixes: https://tracker.ceph.com/issues/44113
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-05 09:41:16 +05:30
Rishabh Dave
c4bd10bdb9 test_cephfs_shell: re-arrange TestCephFSShell's methods
Re-arrange in the order of their usefulness and use keyword arguments
instead of positional arguments to reduce chances of errors, especially
since test_every_cephfs_shell_cmd_at_invocation overrides these methods.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-05 09:31:40 +05:30
Rishabh Dave
d0be1f9f07 test_cephfs_shell: add new test for shell cmd at invocation
Test passing each CephFS shell command at invocation of shell. The test
replaces run_cephfs_shell_cmd (and other related methods) by it's own
version of the same method that runs each shell command as
"cephfs-shell -c ceph.conf shellcmd" instead of
"cephfs-shell -c ceph.conf -- shellcmd" and then run each
test_cephfs_shell.py.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-05 09:28:03 +05:30
Rishabh Dave
b67ce004ad test_cephfs_shell: use StringIO instead of BytesIO
Code in qa/ uses both StringIO and BytesIO. Let's use StringIO
exclusively (unless necessary) for uniformity. The reason for using
StringIO over BytesIO is that tests mostly need stdout as string than
as bytes and StringIO is used more frequently used in qa/ code at this
point.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-06-05 00:02:36 +05:30
Rishabh Dave
1abfdd161c cephfs-shell: support cephfs-shell.conf
cephfs-shell options should reside in cephfs-shell.conf and not in
ceph.conf. Please note, unlike before, -c option of cephfs-shell must
take path to cephfs-shell.conf instead of path to ceph.conf.

This commit also updates the docs and the tests for cephfs-shell accordingly
and renames the variable config_path in cephfs-shell to shell_conf_path so
that it's easy to distinguish.

Fixes: https://tracker.ceph.com/issues/44127
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-05-20 21:32:45 +05:30
Rishabh Dave
39db91ea19 test_cephfs_shell: refactor test_put_and_get_without_target_directory
The refactor intends to simplify the test and make it more readable,

It also changes how this test creates directory -- tempfile.mkdtemp is
used instead of coreutils mkdir to avoid bug reported here -
https://tracker.ceph.com/issues/43567.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-04-27 14:28:03 +05:30
Kefu Chai
981ad34987 qa/tasks/cephfs/test_cephfs_shell: assertRegex(text, regex)
per Python3 doc of unittest,

> assertRegex(text, regex, msg=None)

Signed-off-by: Kefu Chai <kchai@redhat.com>
2020-04-07 21:51:23 +08:00
Kyr Shatskyy
9f6c764f10 qa/tasks/cephfs: get rid of StringIO for py3
Use io.BytesIO and six.ensure_str for py3 compatibility

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
2020-03-06 10:19:55 +01:00
Patrick Donnelly
29d850fb7e
Merge PR #32570 into master
* refs/pull/32570/head:
	cephfs-shell: Add tests for setxattr, getxattr and listxattr
	cephfs-shell: Add listxattr command
	cephfs-shell: Add getxattr command
	cephfs-shell: Add setxattr command
	doc: Update about extended attributes

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
2020-02-02 06:56:50 -08:00
Varsha Rao
e601242afe cephfs-shell: Add tests for setxattr, getxattr and listxattr
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-30 01:16:27 +05:30
Varsha Rao
d4b6a5c2d4 cephfs-shell: Instead of assert use stat for tests in rmdir
Using assert causes the tests to fail on teuthology due to this test being run
separately from the ceph cluster. Instead use stat for testing.

Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
d21df7560e cephfs-shell: Add function for common rmdir test code
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
c512b94127 cephfs-shell: Add rmdir test for non empty directory
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
0ef7c6e849 cephfs-shell: Add rmdir -p test for non empty directory
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
32be18e239 cephfs-shell: Add rmdir -p test for non existing dir
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
dec171dddb cephfs-shell: Add rmdir -p test to delete all dirs in given path
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
31710d037c cephfs-shell: Add rmdir -p test for root directory with empty directories
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
5236f76a19 cephfs-shell: Add rmdir test for valid file
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
b93d91b171 cephfs-shell: Add rmdir test for invalid directory
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
00c052fec5 cephfs-shell: Add rmdir test for valid directory
Signed-off-by: Varsha Rao <varao@redhat.com>
2020-01-22 16:30:11 +05:30
Varsha Rao
cd15fc8a77 cephfs-shell: Modify Quota Test
This patch makes following modifications quota test:
- Add additional condtion to confirm Command Failure Error due to exceeding set
  quota values.
- Rename function valid to set_and_get_quota_vals.
- Use run_cephfs_shell_cmd instead of get_cephfs_shell_cmd_output.

Signed-off-by: Varsha Rao <varao@redhat.com>
2019-12-28 17:55:40 +05:30
Varsha Rao
228a290c2d cephfs-shell: Fix permission errors on quota tests
Use of mount_a.run_shell() to create directory, requires Sudo access and
cephfs-shell should be run without sudo access. Instead use cephfs-shell mkdir
command to create directory.

Signed-off-by: Varsha Rao <varao@redhat.com>
2019-12-28 17:55:40 +05:30
Varsha Rao
d4b5c760cd cephfs-shell: Add tests for quota
Signed-off-by: Varsha Rao <varao@redhat.com>
2019-12-28 17:55:40 +05:30
Rishabh Dave
4e11b5b5e7 test_cephfs_shell: fix test_du_works_for_hardlinks
ln command needs superuser privileges, oddly that test had run
successfully before.

Fixes: https://tracker.ceph.com/issues/43250
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-12-13 12:15:27 +05:30
Thomas Bechtold
0127cd1e88 qa: Enable flake8 tox and fix failures
There were a couple of problems found by flake8 in the qa/
directory (most of them fixed now). Enabling flake8 during the usual
check runs hopefully avoids adding new issues in the future.

Signed-off-by: Thomas Bechtold <tbechtold@suse.com>
2019-12-12 10:21:01 +01:00
Patrick Donnelly
0448a31fcb
qa: fix output check to not be sensitive to debugging
The traceback would screw up the equality checks.

Also, use unittest asserts so we can easily see the assert values.

Fixes: https://tracker.ceph.com/issues/43247
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
2019-12-10 16:45:09 -08:00
Patrick Donnelly
12e7401a43
Merge PR #27894 into master
* refs/pull/27894/head:
	cephfs-shell: Add default list to df
	cephfs-shell: Add tests for df command
	cephfs-shell: Fix 'df' command errors

Reviewed-by: Rishabh Dave <ridave@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
2019-12-09 17:05:52 -08:00
Rishabh Dave
d6f768b24e qa/cephfs: test conf file reading for CephFS shell
Adds tests that checks -
* reading conf option
* reading conf option after setting it twice
* reading conf option after setting it after a reset

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-12-06 08:54:06 +05:30
Rishabh Dave
a1e3e270b9 qa/cephfs: allow passing conf to methods that runs shell command
Add an argument to the methods that issues CephFS shell command to
accept path to the ceph.conf file.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-12-06 08:54:06 +05:30
Rishabh Dave
2f85a03b56 test_cephfs_shell: update test since shell can now read ceph.conf
In the test
test_cephfs_shell.TestMisc.test_issue_cephfs_shell_cmd_at_invocation,
don't set the shell option with in the command to be tested since
CephFS shell can now read it's value from ceph.conf.

Also, add methods to set config options for vstart as well teuthology
testing.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-12-06 08:52:59 +05:30
Patrick Donnelly
f1e3fec83d
Merge PR #27467 into master
* refs/pull/27467/head:
	cephfs-shell: add snapshot management

Reviewed-by: Rishabh Dave <ridave@redhat.com>
Reviewed-by: Varsha Rao <varao@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
2019-11-26 09:47:40 -08:00
Varsha Rao
2c1c683b19 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 <varao@redhat.com>
2019-11-15 16:51:05 +05:30
Rishabh Dave
bafef71e49 test_cephfs_shell: initialize stderr for run_cephfs_shell_cmd()
Since teuthology initializes stderr to None by default, absence of this
breaks the tests accessing stderr of commands executed within the test
when the execution is using teuthology.

Fixes: https://tracker.ceph.com/issues/42806
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-11-14 13:54:14 +05:30
Milind Changire
73597e94f1 cephfs-shell: add snapshot management
Snapshots can be managed by:
$ snap {create|delete} snap_name dir_name

Fixes: http://tracker.ceph.com/issues/38681
Signed-off-by: Milind Changire <mchangir@redhat.com>
2019-11-04 16:17:32 +05:30
Rishabh Dave
34ab7b9465 test_cephfs_shell: pass arg to "help" in test_help
The default behaviour by cmd2 for help command with no argument is to
print all possible commands and return 1. This leads to a failure even
when test is supposed to pass.

Fixes: https://tracker.ceph.com/issues/42101
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-11-02 14:18:07 +05:30
Rishabh Dave
d165b98554 test_cephfs_shell: add note on how to run this testsuite
Inform that exporting path to cephfs-shell is needed beforehand.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-09-17 17:24:30 +05:30
Rishabh Dave
f9b4d790e5 test_cephfs_shell: test cephfs-shell command at invocation
Verify that "cephfs-shell -c ceph.conf <cephfs-shell-cmd>" works as
expected.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-09-13 10:45:42 +05:30
Rishabh Dave
79c9d91b9a test_cephfs_shell: test du with no args
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-09-13 10:45:39 +05:30
Rishabh Dave
54562691ee test_cephfs_shell: test du with multiple paths in args
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2019-09-13 10:45:34 +05:30