Commit Graph

34 Commits

Author SHA1 Message Date
Rishabh Dave
571a3fc414
Merge pull request #55320 from rishabh-d-dave/mdscaps-update-issues
cephfs,mon: fix bugs related to updating MDS caps

Reviewed-by: Venky Shankar <vshankar@redhat.com>
2024-04-12 18:26:21 +05:30
Xiubo Li
bdabe22a0d qa/cephfs: add 'root_squash' check from the keyring
Fixes: https://tracker.ceph.com/issues/63141
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2024-02-20 16:39:57 +08:00
Rishabh Dave
7626bd5d37 qa/cephfs: handle case where mntpt is '/' in caps_helper.py
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2024-02-13 19:35:42 +05:30
Rishabh Dave
8f50048dd1 qa/cephfs: declare f-string to get values to substitute variable names
Fixes: https://tracker.ceph.com/issues/64289
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2024-02-01 18:51:04 +05:30
Rishabh Dave
6ac58b0a12 qa/cephfs: minor improvement caps_helper.py
When assert fails for equality of two variables and when both the
variables are printed in error message, print each variable on a new
line.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-10-10 16:38:19 +05:30
Xiubo Li
28023f84d7 qa: add test for checking access in client side of root_squash
Test the 'chown' and 'truncate', which will call the setattr and
'cat' will open the files. Before each testing will open the file
by non-root user and keep it to make sure the Fxw caps are issued,
and then user the 'sudo' do to the tests, which will set the uid/gid
to 0/0.

Fixes: https://tracker.ceph.com/issues/57154
Signed-off-by: Xiubo Li <xiubli@redhat.com>
2023-09-11 09:29:46 +08:00
Rishabh Dave
13168834e3 qa/cephfs: add and use get_ceph_cmd_stdout()
Add method get_ceph_cmd_stdout() to class CephFSTestCase so that one
doesn't have to type something as long as
"self.mds_cluster.mon_manager.raw_cluster_cmd()" to execute a
command and get its output. And delete and replace
CephFSTestCase.run_cluster_cmd() too.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-06-28 17:38:19 +05:30
Rishabh Dave
ac9ca5d14b
Merge pull request #51127 from rishabh-d-dave/fs-qa-caps_helper-bug
qa/cephfs/caps_helper: fix a bug in methods that generate cap string

Reviewed-by: Venky Shankar <vshankar@redhat.com>
2023-04-20 19:27:19 +05:30
Rishabh Dave
f0ffade052 qa/cephfs/cap_tester: simplify CapTester and its instantiation
Class CapTester contains two distinct immiscible group of methods: one
that tests MON caps and other that tests MDS caps. When using CapTester
for the former reason the instantiation neither needs mount object and
the path where files for testing will be created nor it needs to run the
method that creates files for testing rw permissions. When using
this class for latter the case is the exact opposite.

Create 2 separate classes for each of these purpose and class that
inherits both of these classes so that instantiating the class becomes
as simple as it can be.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 20:32:15 +05:30
Rishabh Dave
95c6daa45b qa/cephfs: update method caps_helper.CapTester.run_cap_tests()
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 19:42:55 +05:30
Rishabh Dave
ea9f13e553 qa/cephfs: move few methods such that they can be reused
Move get_mon_cap_from_keyring() and get_fsnmes_from_moncap() from class
CapTester to main namespace of caps_helper.py so that they can be
imported freely and reused by tests.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 19:42:55 +05:30
Rishabh Dave
ad68a55121 qa/cephfs: improve caps_helper.CapTester.run_mon_cap_tests()
This method checks if the output of the command "ceph fs ls" for client
ID it receives is same as the output printed for client.admin. Don't do
so, limit the test to only checking if "ceph fs ls --id client.x -k
keyring_file" prints fs name for which client.x has permissions.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 19:42:55 +05:30
Rishabh Dave
008dbe91e2 qa/cephfs: improve caps_helper.CapTester
Improvement #1:

CapTester.write_test_files() not only creates the test file but also
does the following for every mount object it receives in parameters -

* carefully produces the path for the test file as per parameters
  received
* generates the unique data for each test file on a CephFS mount
* creates a data structure -- list of lists -- that holds all this
  information along with mount object itself for each mount object so
  that tests can be conducted at a later point

Untangle this mess of code by splitting this method into 3 separate
methods -

1. To produce the path for test file (as per user's need).
2. To generate the data that will be written into the test file.
3. To actually create the test file on CephFS.

Improvement #2:

Remove the internal data structure used for testing -- self.test_set --
and use separate class attributes to store all the data required for
testing instead of a tuple. This serves two purpose -

One, it makes it easy to manipulate all this data from helper methods
and during debugging session, especially while using a PDB session.

And two, make it impossible to have multiple mounts/multiple "test sets"
within same CapTester instance for the sake of simplicity. Users can
instead create two instances of CapTester instances if needed.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 19:42:55 +05:30
Rishabh Dave
e8bdf94b81 qa/cephfs: don't inherit CephFSTestCase in CapTester
Inheritting CephFSTestCase in CapTester just for methods assertEqual()
and assertIn() from class unittest.TestCase is odd and heavy-weight.
Don't inherit CephFSTestCase and use simple assert instead.

Reference: https://github.com/ceph/ceph/pull/50882#discussion_r1160611549.

To avoid code duplication, a couple of similar methods have been added
instead.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 19:34:40 +05:30
Rishabh Dave
64e3dd7e62 qa/cephfs/caps_helper: fix a bug in methods that generate cap string
The tuple was not meant to be passed as a whole but its individual
members are to be passed as a list of positional arguments.

Introduced-by: 87025d1585
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-18 16:28:03 +05:30
Rishabh Dave
1a7ca489b4 qa/cephfs: minor improvement in caps_helper
Use Python type list instead of tuple since it get's necessary to modify
members of this sequence.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-04-11 12:03:49 +05:30
Rishabh Dave
87025d1585 qa/cephfs: use kwargs to unpack tuples in caps_helper.py
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-03-29 21:00:08 +05:30
Rishabh Dave
0934845a38 qa/cephfs: upgrade gen_mds_cap_str() in caps_helper
Modify get_mds_cap_str() to accept a tuple with a single member. In this
case, the only member is assumed to be a permission, FS name is assigned
None type and cephfs_mntpt is assigned '/'.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-03-29 18:09:29 +05:30
Rishabh Dave
969a93d0dc qa/cephfs: add more helper methods to caps_helper.py
Add methods that will accept read/write permissions, CephFS names and
CephFS mount point and in return will generate string form of MON, OSD
and MDS caps exactly as it is reported in Ceph keyrings.

Replace similar code in test_multifs_auth.py with calls to these helper
methods.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-03-24 11:32:58 +05:30
Rishabh Dave
1428fb1e73 qa/cephfs: minor corrections in caps_helper.py
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2023-03-13 17:45:57 +05:30
Rishabh Dave
34e94e9ae5 qa/cephfs: refactor and upgrade test_single_path_rootsquash
test_single_path_rootsquash instead of using helper methods duplicates
the code from those methods. This commit fixes that and also upgrade
this method since caps_helper was upgraded in previous commits.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
f11a757b78 qa/cephfs: add log entries for caps_helper.py
The intention is to make logs contain some information of what's being
done by caps_helper.py regardless of which test/method is calling it.
This should make logs more understandable and also add hints for
future debugging.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
463c9e1714 qa/cephfs: upgrade caps_helper.CapTester.run_mon_cap_tests()
With this commit, the design of run_mon_cap_tests() is now aligned with
rest of CapTester -- it's not meant to be inherited by test class
anymore and it is to be called by using CapTester instance.

This commit also changes working of this method. Now instead of
obtaining FS names from Python objects representing FSs, it obtains
those names from MON cap. This removes the need to pass the FS objects
around.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
2601831ff7 qa/cephfs: make file data unique in caps_helper.py
Let's change the file data to include the file path, the CephFS name
and the host FS and CephFS mountpoint so that the bugs where, let's say,
"cephfs2" is mounted instead of "cephfs1" (where obviously both the
CephFSs lie on the same Ceph cluster) is caught by the tests due to
uniqueness of every test file's content.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
d1f01cc86d qa/cephfs: simplify caps_helper.CapTester
Simplify methods in CapsTester by adding a test set, which will be a
list of tuples. The first element in tuple will be the mount object,
the second will be the test file path and the third will be the test
file data. Thus instead of having three independent class variables
that are always used together now we have list of test sets making
management of multiple test sets simpler.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
370449ac9d qa/cephfs: upgrade and rename class CapsHelper
Modify caps_helper.py such that calling code does't have to store
returned values just to pass those values again to a method in
caps_helper.py. This is a common pattern where write_test_files()
return 3 values and all 3 passed as it is to run_cap_tests().

The easy way to do it is to upgrade caps_helper so that it can be used
an object and not just as a class supplying helper methods. The return
values will be stored by the object internally and thus resued. In case
of testing multiple FSs inside a single test method, we'll now need
multiple instances of this class to keep those values separate.

And since CapsHelper is not just a class supplying helper methods
anymore, it's being renamed to CapTester.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
d9013dacc9 qa/cephfs: allow creating files at custom location
Concerned method: caps_helper.CapsHelper.write_test_file()

When CephFS mountpoint is changed inside a single test method, the test
files created at root are neither accessible nor useful. Therefore, add
an option to create the test files in the directory passed by the user.
This also increases general flexibility of the concerned method.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
cc30c78162 qa/cephfs: add a helper method in caps_helper.py
This helper method prevents repeating code to write test files in
test methods for caps.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-21 17:53:16 +05:30
Rishabh Dave
82b58e3667 qa/cephfs: allow checking for multiple error messages while...
while negative testing.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-20 13:11:31 +05:30
Rishabh Dave
ce942f250a qa/cephfs: delete path from cmd args after use
A new path is obtained every iteration which is appended to command
arguments. After the command has been executed successfully, delete the
the  path from command's arguments so that the command's arguments don't
have two paths in next iteration and it works as expected.

Fixes: https://tracker.ceph.com/issues/56416
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-07-06 17:12:58 +05:30
Rishabh Dave
f01188d72a qa/cephfs: fix minor bug in caps_helper.py's run_mon_cap_tests()
When an entity's MON cap contains no FS name in it, the entity has the
access to all the FSs on cluster and not just to the default FS of the
cluster.

Fixes: https://tracker.ceph.com/issues/55558
Signed-off-by: Rishabh Dave <ridave@redhat.com>
2022-05-27 15:19:38 +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
Rishabh Dave
511434ac5a qa/cephfs: remove create_keyring_file from cephfs_test_case.py
Since teuthology.orchestra.remote.mktemp() can write a temporary file
and not just create it, create_keyring_file() is now redundant.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2021-04-08 12:11:00 +05:30
Rishabh Dave
352a41d1b3 qa/cephfs: add tests for multi-FS auth tests
Add testsuite for testing authorization on Ceph cluster with multiple
file systems and enable it to be executable with Teuthology framework.

Also add helper methods required to setup the test environment for
multi-FS tests.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
2020-09-11 18:02:48 +05:30