From aafa06eb9da983df89b8f522624251968f1bade3 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 30 Nov 2015 18:21:14 +0000 Subject: [PATCH] tasks/cephfs: generate mount paths on the fly ...because new tests that modify the client ID will get confused about whether they're mounted or not, otherwise. Signed-off-by: John Spray --- tasks/cephfs/cephfs_test_case.py | 5 ++--- tasks/cephfs/fuse_mount.py | 8 +++----- tasks/cephfs/mount.py | 5 ++++- tasks/cephfs/vstart_runner.py | 13 +++++-------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/tasks/cephfs/cephfs_test_case.py b/tasks/cephfs/cephfs_test_case.py index 206b14e4464ab..846cf8d2c3254 100644 --- a/tasks/cephfs/cephfs_test_case.py +++ b/tasks/cephfs/cephfs_test_case.py @@ -160,9 +160,8 @@ class CephFSTestCase(unittest.TestCase): def tearDown(self): self.fs.clear_firewall() - self.mount_a.teardown() - if self.mount_b: - self.mount_b.teardown() + for m in self.mounts: + m.teardown() for subsys, key in self.configs_set: self.fs.clear_ceph_conf(subsys, key) diff --git a/tasks/cephfs/fuse_mount.py b/tasks/cephfs/fuse_mount.py index 9eb93374a9fb9..8440bfbdf716f 100644 --- a/tasks/cephfs/fuse_mount.py +++ b/tasks/cephfs/fuse_mount.py @@ -2,7 +2,6 @@ from StringIO import StringIO import json import time -import os import logging from textwrap import dedent @@ -30,15 +29,14 @@ class FuseMount(CephFSMount): if self.client_config.get('coverage') or self.client_config.get('valgrind') is not None: daemon_signal = 'term' - mnt = os.path.join(self.test_dir, 'mnt.{id}'.format(id=self.client_id)) log.info('Mounting ceph-fuse client.{id} at {remote} {mnt}...'.format( - id=self.client_id, remote=self.client_remote, mnt=mnt)) + id=self.client_id, remote=self.client_remote, mnt=self.mountpoint)) self.client_remote.run( args=[ 'mkdir', '--', - mnt, + self.mountpoint, ], ) @@ -59,7 +57,7 @@ class FuseMount(CephFSMount): fuse_cmd += [ '--name', 'client.{id}'.format(id=self.client_id), # TODO ceph-fuse doesn't understand dash dash '--', - mnt, + self.mountpoint, ] if self.client_config.get('valgrind') is not None: diff --git a/tasks/cephfs/mount.py b/tasks/cephfs/mount.py index 2a720c4cec5b1..832d0002e5401 100644 --- a/tasks/cephfs/mount.py +++ b/tasks/cephfs/mount.py @@ -24,11 +24,14 @@ class CephFSMount(object): self.client_id = client_id self.client_remote = client_remote - self.mountpoint = os.path.join(self.test_dir, 'mnt.{id}'.format(id=self.client_id)) self.test_files = ['a', 'b', 'c'] self.background_procs = [] + @property + def mountpoint(self): + return os.path.join(self.test_dir, 'mnt.{id}'.format(id=self.client_id)) + def is_mounted(self): raise NotImplementedError() diff --git a/tasks/cephfs/vstart_runner.py b/tasks/cephfs/vstart_runner.py index 8ebbc68e5e671..78ee4ccfab309 100644 --- a/tasks/cephfs/vstart_runner.py +++ b/tasks/cephfs/vstart_runner.py @@ -358,10 +358,8 @@ class MountDaemon(object): class LocalFuseMount(FuseMount): - def __init__(self, client_id, mount_point): - test_dir = "/tmp/not_there" + def __init__(self, test_dir, client_id): super(LocalFuseMount, self).__init__(None, test_dir, client_id, LocalRemote()) - self.mountpoint = mount_point @property def config_path(self): @@ -752,15 +750,14 @@ def exec_test(): open("./keyring", "a").write(p.stdout.getvalue()) - mount_point = os.path.join(test_dir, "mnt.{0}".format(client_id)) - mount = LocalFuseMount(client_id, mount_point) + mount = LocalFuseMount(test_dir, client_id) mounts.append(mount) if mount.is_mounted(): - log.warn("unmounting {0}".format(mount_point)) + log.warn("unmounting {0}".format(mount.mountpoint)) mount.umount_wait() else: - if os.path.exists(mount_point): - os.rmdir(mount_point) + if os.path.exists(mount.mountpoint): + os.rmdir(mount.mountpoint) filesystem = LocalFilesystem(ctx) from tasks.cephfs_test_runner import DecoratingLoader -- 2.47.3