From 511434ac5ad050dafee50c82c312eeec8270585a Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Thu, 8 Apr 2021 12:00:18 +0530 Subject: [PATCH] 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 --- qa/tasks/cephfs/caps_helper.py | 2 +- qa/tasks/cephfs/cephfs_test_case.py | 3 --- qa/tasks/cephfs/test_admin.py | 12 ++++-------- qa/tasks/cephfs/test_multifs_auth.py | 9 +++------ qa/tasks/vstart_runner.py | 2 ++ 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/qa/tasks/cephfs/caps_helper.py b/qa/tasks/cephfs/caps_helper.py index a6633354623cb..e27a3e1b35c67 100644 --- a/qa/tasks/cephfs/caps_helper.py +++ b/qa/tasks/cephfs/caps_helper.py @@ -8,7 +8,7 @@ from teuthology.orchestra.run import Raw class CapsHelper(CephFSTestCase): def run_mon_cap_tests(self, moncap, keyring): - keyring_path = self.create_keyring_file(self.fs.admin_remote, keyring) + keyring_path = self.fs.admin_remote.mktemp(data=keyring) fsls = self.run_cluster_cmd(f'fs ls --id {self.client_id} -k ' f'{keyring_path}') diff --git a/qa/tasks/cephfs/cephfs_test_case.py b/qa/tasks/cephfs/cephfs_test_case.py index 816ddcc1e7b62..1a1cf40517a5e 100644 --- a/qa/tasks/cephfs/cephfs_test_case.py +++ b/qa/tasks/cephfs/cephfs_test_case.py @@ -442,6 +442,3 @@ class CephFSTestCase(CephTestCase): self.run_cluster_cmd(cmd) return self.run_cluster_cmd(f'auth get {self.client_name}') - - def create_keyring_file(self, remote, keyring): - return remote.mktemp(data=keyring) diff --git a/qa/tasks/cephfs/test_admin.py b/qa/tasks/cephfs/test_admin.py index 9513a84b76785..ae6cd6e7be69f 100644 --- a/qa/tasks/cephfs/test_admin.py +++ b/qa/tasks/cephfs/test_admin.py @@ -481,8 +481,7 @@ class TestSubCmdFsAuthorize(CapsHelper): self.mount_a.write_file(filepath, filedata) keyring = self.fs.authorize(self.client_id, ('/', 'rw', 'root_squash')) - keyring_path = self.create_keyring_file(self.mount_a.client_remote, - keyring) + keyring_path = self.mount_a.client_remote.mktemp(data=keyring) self.mount_a.remount(client_id=self.client_id, client_keyring_path=keyring_path, cephfs_mntpt='/') @@ -517,8 +516,7 @@ class TestSubCmdFsAuthorize(CapsHelper): filepaths, filedata, mounts, keyring = self.setup_test_env(perm, paths) moncap = self.get_mon_cap_from_keyring(self.client_name) - keyring_path = self.create_keyring_file(self.mount_a.client_remote, - keyring) + keyring_path = self.mount_a.client_remote.mktemp(data=keyring) for path in paths: self.mount_a.remount(client_id=self.client_id, client_keyring_path=keyring_path, @@ -534,8 +532,7 @@ class TestSubCmdFsAuthorize(CapsHelper): filepaths, filedata, mounts, keyring = self.setup_test_env(perm, paths) moncap = self.get_mon_cap_from_keyring(self.client_name) - keyring_path = self.create_keyring_file(self.mount_a.client_remote, - keyring) + keyring_path = self.mount_a.client_remote.mktemp(data=keyring) for path in paths: self.mount_a.remount(client_id=self.client_id, client_keyring_path=keyring_path, @@ -559,8 +556,7 @@ class TestSubCmdFsAuthorize(CapsHelper): self.mount_a.write_file(filepath, filedata) keyring = self.fs.authorize(self.client_id, ('/', perm)) - keyring_path = self.create_keyring_file(self.mount_a.client_remote, - keyring) + keyring_path = self.mount_a.client_remote.mktemp(data=keyring) self.mount_a.remount(client_id=self.client_id, client_keyring_path=keyring_path, diff --git a/qa/tasks/cephfs/test_multifs_auth.py b/qa/tasks/cephfs/test_multifs_auth.py index b247dd8f51bc1..f4c9b9e870715 100644 --- a/qa/tasks/cephfs/test_multifs_auth.py +++ b/qa/tasks/cephfs/test_multifs_auth.py @@ -179,8 +179,7 @@ class TestMDSCaps(TestMultiFS): keyring = self.create_client(self.client_id, moncap, osdcap, mdscap) keyring_paths = [] for mount_x in (self.mount_a, self.mount_b): - keyring_paths.append(self.create_keyring_file( - mount_x.client_remote, keyring)) + keyring_paths.append(mount_x.client_remote.mktemp(data=keyring)) return keyring_paths @@ -275,8 +274,7 @@ class TestClientsWithoutAuth(TestMultiFS): def test_mount_all_caps_absent(self): # setup part... keyring = self.fs1.authorize(self.client_id, ('/', 'rw')) - keyring_path = self.create_keyring_file(self.mount_a.client_remote, - keyring) + keyring_path = self.mount_a.client_remote.mktemp(data=keyring) # mount the FS for which client has no auth... retval = self.mount_a.remount(client_id=self.client_id, @@ -297,8 +295,7 @@ class TestClientsWithoutAuth(TestMultiFS): osdcap = (f'allow rw tag cephfs data={self.fs1.name}, allow rw tag ' f'cephfs data={self.fs2.name}') keyring = self.create_client(self.client_id, moncap, osdcap, mdscap) - keyring_path = self.create_keyring_file(self.mount_a.client_remote, - keyring) + keyring_path = self.mount_a.client_remote.mktemp(data=keyring) # mount the FS for which client has no auth... retval = self.mount_a.remount(client_id=self.client_id, diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 586ecf71d5db1..efa49269df22a 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -316,6 +316,8 @@ class LocalRemote(object): from tempfile import mktemp if not path: path = mktemp(suffix=suffix, dir=parentdir) + if not parentdir: + path = os.path.join('/tmp', path) if data: # sudo is set to False since root user can't write files in /tmp -- 2.39.5