From 4a00b2bbb1f940fc018993cf444b9696e9ab4b56 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Tue, 19 Apr 2022 22:01:49 +0530 Subject: [PATCH 1/7] qa/cephfs: use standard name for logging variable Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index f606f645ef2..345b23054b9 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -7,7 +7,7 @@ from textwrap import dedent from tasks.cephfs.cephfs_test_case import CephFSTestCase -logger = getLogger(__name__) +log = getLogger(__name__) # TODO: add code to run non-ACL tests too. From 49c7a79f8a75985eb79b2cef42761b2758f58490 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Sat, 7 May 2022 09:12:52 +0530 Subject: [PATCH 2/7] qa/cephfs: make it easier to use xfstests-dev using vstart_runner The intention of this re-arrangement is to make it easier for developers to use an already cloned and built xfstests-dev repo with vstart_runner.py. The re-arrangements are - * move tearDown() closer to setUp() (so that devs can enable/disable parts of them easily), * carve out separate methods (so that these codeblocks can be disabled in a single go) for - ** deleting groups and users, ** deleting xfstests-dev and xfsprogs-dev repo and ** building xfstests-dev repo * carve out method for deleting xfstests-dev and xfsprogs-dev repos * add self.xfstests_repo_path comment (for devs to set path to xfstests-dev repo), and, * add a note showing how to use already cloned and built xfstests-dev repo Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 52 ++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index 345b23054b9..61bb087b784 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -27,13 +27,44 @@ class XFSTestsDev(CephFSTestCase): self.install_xfsprogs = False def prepare_xfstests_devs(self): + # NOTE: To run a quick test with vstart_runner.py, enable next line + # and disable calls to get_repo(), install_deps(), and + # build_and_install() and also disable lines in tearDown() for repo + # deletion. + #self.xfstests_repo_path = '/path/to/xfstests-dev' + self.get_repos() self.get_test_and_scratch_dirs_ready() self.install_deps() self.create_reqd_users() self.write_local_config() self.write_ceph_exclude() + self.build_and_install() + def tearDown(self): + self.del_users_and_groups() + self.del_repos() + super(XFSTestsDev, self).tearDown() + + def del_users_and_groups(self): + self.mount_a.client_remote.run(args=['sudo', 'userdel', '--force', + '--remove', 'fsgqa'], + omit_sudo=False, check_status=False) + self.mount_a.client_remote.run(args=['sudo', 'userdel', '--force', + '--remove', '123456-fsgqa'], + omit_sudo=False, check_status=False) + self.mount_a.client_remote.run(args=['sudo', 'groupdel', 'fsgqa'], + omit_sudo=False, check_status=False) + + def del_repos(self): + self.mount_a.client_remote.run(args=f'sudo rm -rf {self.xfstests_repo_path}', + omit_sudo=False, check_status=False) + + if self.install_xfsprogs: + self.mount_a.client_remote.run(args=f'sudo rm -rf {self.xfsprogs_repo_path}', + omit_sudo=False, check_status=False) + + def build_and_install(self): # NOTE: On teuthology machines it's necessary to run "make" as # superuser since the repo is cloned somewhere in /tmp. self.mount_a.client_remote.run(args=['sudo', 'make'], @@ -192,24 +223,3 @@ class XFSTestsDev(CephFSTestCase): self.mount_a.client_remote.write_file(join(self.xfstests_repo_path, 'ceph.exclude'), xfstests_exclude_contents, sudo=True) - - def tearDown(self): - self.mount_a.client_remote.run(args=['sudo', 'userdel', '--force', - '--remove', 'fsgqa'], - omit_sudo=False, check_status=False) - self.mount_a.client_remote.run(args=['sudo', 'userdel', '--force', - '--remove', '123456-fsgqa'], - omit_sudo=False, check_status=False) - self.mount_a.client_remote.run(args=['sudo', 'groupdel', 'fsgqa'], - omit_sudo=False, check_status=False) - - self.mount_a.client_remote.run(args=['sudo', 'rm', '-rf', - self.xfstests_repo_path], - omit_sudo=False, check_status=False) - - if self.install_xfsprogs: - self.mount_a.client_remote.run(args=['sudo', 'rm', '-rf', - self.xfsprogs_repo_path], - omit_sudo=False, check_status=False) - - super(XFSTestsDev, self).tearDown() From 4d75730200330c5769e912e2df388db95d72b4a7 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 8 Jun 2022 22:28:34 +0530 Subject: [PATCH 3/7] qa/cephfs: minor changes in xfstests_dev.py In xfstests-dev repo, local.config options "SCRATCH_DEV" and "SCRATCH_MNT" were enabled in commit 2ba6b871056c10d7ea75b526489baa3586024fbf but TODO comment for the wasn't deleted. Let's delete that and use format string instead of format function on regular string. Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index 61bb087b784..e57f062e4d2 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -11,7 +11,6 @@ log = getLogger(__name__) # TODO: add code to run non-ACL tests too. -# TODO: get tests running with SCRATCH_DEV and SCRATCH_DIR. # TODO: make xfstests-dev tests running without running `make install`. # TODO: make xfstests-dev compatible with ceph-fuse. xfstests-dev remounts # CephFS before running tests using kernel, so ceph-fuse mounts are never @@ -201,18 +200,17 @@ class XFSTestsDev(CephFSTestCase): self.test_dev = mon_sock + ':/' + self.test_dirname self.scratch_dev = mon_sock + ':/' + self.scratch_dirname - xfstests_config_contents = dedent('''\ + xfstests_config_contents = dedent(f'''\ export FSTYP=ceph - export TEST_DEV={} - export TEST_DIR={} - export SCRATCH_DEV={} - export SCRATCH_MNT={} - export CEPHFS_MOUNT_OPTIONS="-o name=admin,secret={}{}" - ''').format(self.test_dev, self.test_dirs_mount_path, self.scratch_dev, - self.scratch_dirs_mount_path, self.get_admin_key(), _options) + export TEST_DEV={self.test_dev} + export TEST_DIR={self.test_dirs_mount_path} + export SCRATCH_DEV={self.scratch_dev} + export SCRATCH_MNT={self.scratch_dirs_mount_path} + export CEPHFS_MOUNT_OPTIONS="-o name=admin,secret={self.get_admin_key()}{_options}" + ''') - self.mount_a.client_remote.write_file(join(self.xfstests_repo_path, 'local.config'), - xfstests_config_contents, sudo=True) + self.mount_a.client_remote.write_file(join(self.xfstests_repo_path, 'local.config'), + xfstests_config_contents, sudo=True) def write_ceph_exclude(self): # These tests will fail or take too much time and will From 392e2787496523794d05e52b34a5a59034646c68 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 8 Jun 2022 22:32:27 +0530 Subject: [PATCH 4/7] qa/cephfs: log xfstests-dev local.config Log contents of xfstests-dev repo config file "local.config" to make debugging easier. Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index e57f062e4d2..c507dbe4963 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -209,8 +209,10 @@ class XFSTestsDev(CephFSTestCase): export CEPHFS_MOUNT_OPTIONS="-o name=admin,secret={self.get_admin_key()}{_options}" ''') - self.mount_a.client_remote.write_file(join(self.xfstests_repo_path, 'local.config'), - xfstests_config_contents, sudo=True) + self.mount_a.client_remote.write_file( + join(self.xfstests_repo_path, 'local.config'), + xfstests_config_contents, sudo=True) + log.info(f'local.config\'s contents -\n{xfstests_config_contents}') def write_ceph_exclude(self): # These tests will fail or take too much time and will From 18465b8f56dd10ff42fa9cc66988f1da714698b8 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 8 Jun 2022 22:34:51 +0530 Subject: [PATCH 5/7] qa/cephfs: modify user creation code for xfstests-dev Create user "fsgqa2" and, since xfstests-dev's README uses option "-m" while creating user "fsgqa", do the same in our codebase. Creating user "fsgqa2" is optional along with other users according to xfstests-dev's README. Create all these users is a preventive step since tests needing user/users maybe skipped during execution. Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index c507dbe4963..005d6bf407e 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -185,10 +185,12 @@ class XFSTestsDev(CephFSTestCase): self.mount_a.client_remote.run(args=args, omit_sudo=False) def create_reqd_users(self): - self.mount_a.client_remote.run(args=['sudo', 'useradd', 'fsgqa'], + self.mount_a.client_remote.run(args=['sudo', 'useradd', '-m', 'fsgqa'], omit_sudo=False, check_status=False) self.mount_a.client_remote.run(args=['sudo', 'groupadd', 'fsgqa'], omit_sudo=False, check_status=False) + self.mount_a.client_remote.run(args=['sudo', 'useradd', 'fsgqa2'], + omit_sudo=False, check_status=False) self.mount_a.client_remote.run(args=['sudo', 'useradd', '123456-fsgqa'], omit_sudo=False, check_status=False) From 053a1fb8516e7fe6fb4160ebdf8c17b8cc35b71a Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 8 Jun 2022 22:19:59 +0530 Subject: [PATCH 6/7] qa/cephfs: don't create symlinks for xfstests-dev Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index 005d6bf407e..b2375c9298b 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -122,18 +122,12 @@ class XFSTestsDev(CephFSTestCase): # read var name as "test dir's mount path" self.test_dirs_mount_path = self.mount_a.client_remote.mkdtemp( suffix=self.test_dirname) - self.mount_a.run_shell(['sudo','ln','-s',join(self.mount_a.mountpoint, - self.test_dirname), - self.test_dirs_mount_path]) self.scratch_dirname = 'scratch' self.mount_a.run_shell(['mkdir', self.scratch_dirname]) # read var name as "scratch dir's mount path" self.scratch_dirs_mount_path = self.mount_a.client_remote.mkdtemp( suffix=self.scratch_dirname) - self.mount_a.run_shell(['sudo','ln','-s',join(self.mount_a.mountpoint, - self.scratch_dirname), - self.scratch_dirs_mount_path]) def install_deps(self): from teuthology.misc import get_system_type From 92aaaf7b57c326cc3755a5ed43862550a0d9a865 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Tue, 31 May 2022 08:44:51 +0530 Subject: [PATCH 7/7] qa/cephfs: save results dir from xfstests-dev repo The "results" directory in xfstests-dev repo contains logs that are created by it during execution of its tests. Copying this directory to Ceph log directory saves it from being erased during tear down conducted by teuthology test runner. These logs allow deeper inspection in to the cause of failure of tests. Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/xfstests_dev.py | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/qa/tasks/cephfs/xfstests_dev.py b/qa/tasks/cephfs/xfstests_dev.py index b2375c9298b..f551dc3e616 100644 --- a/qa/tasks/cephfs/xfstests_dev.py +++ b/qa/tasks/cephfs/xfstests_dev.py @@ -17,6 +17,8 @@ log = getLogger(__name__) # actually testsed. class XFSTestsDev(CephFSTestCase): + RESULTS_DIR = "results" + def setUp(self): super(XFSTestsDev, self).setUp() self.setup_xfsprogs_devs() @@ -56,6 +58,7 @@ class XFSTestsDev(CephFSTestCase): omit_sudo=False, check_status=False) def del_repos(self): + self.save_results_dir() self.mount_a.client_remote.run(args=f'sudo rm -rf {self.xfstests_repo_path}', omit_sudo=False, check_status=False) @@ -63,6 +66,41 @@ class XFSTestsDev(CephFSTestCase): self.mount_a.client_remote.run(args=f'sudo rm -rf {self.xfsprogs_repo_path}', omit_sudo=False, check_status=False) + def save_results_dir(self): + """ + When tests in xfstests-dev repo are executed, logs are created and + saved, under a directory named "results" that lies at the repo root. + In case a test from xfstests-dev repo fails, these logs will help find + the cause of the failure. + + Since there's no option in teuthology to copy a directory lying at a + custom location in order to save it from teuthology test runner's tear + down, let's copy this directory to a standard location that teuthology + copies away before erasing all data on the test machine. The standard + location chosen in the case here is the Ceph log directory. + + In case of vstart_runner.py, this methods does nothing. + """ + # No need to save results dir in case of vstart_runner.py. + for x in ('LocalFuseMount', 'LocalKernelMount'): + if x in self.mount_a.__class__.__name__: + return + + src = join(self.xfstests_repo_path, self.RESULTS_DIR) + + if self.mount_a.run_shell(f'sudo stat {src}', + check_status=False, omit_sudo=False).returncode != 0: + log.info(f'xfstests-dev repo contains not directory named ' + f'"{self.RESULTS_DIR}". repo location: {self.xfstests_repo_path}') + return + + std_loc = '/var/log/ceph' # standard location + dst = join(std_loc, 'xfstests-dev-results') + self.mount_a.run_shell(f'sudo mkdir -p {dst}', omit_sudo=False) + self.mount_a.run_shell(f'sudo cp -r {src} {dst}', omit_sudo=False) + log.info(f'results dir from xfstests-dev has been saved; it was ' + f'copied from {self.xfstests_repo_path} to {std_loc}.') + def build_and_install(self): # NOTE: On teuthology machines it's necessary to run "make" as # superuser since the repo is cloned somewhere in /tmp.