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>
This commit is contained in:
Rishabh Dave 2021-04-08 12:00:18 +05:30
parent e213849581
commit 511434ac5a
5 changed files with 10 additions and 18 deletions

View File

@ -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}')

View File

@ -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)

View File

@ -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,

View File

@ -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,

View File

@ -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