Merge pull request #85 from ceph/wip-testdir

remove basedir/testdir distinction
This commit is contained in:
Sage Weil 2013-09-10 12:20:29 -07:00
commit 748fa5e559
4 changed files with 16 additions and 130 deletions

View File

@ -312,24 +312,13 @@ this issue.
Test Sandbox Directory
======================
Teuthology currently places most test files and mount points in a sandbox
directory, defaulting to ``/home/$USER/cephtest/{rundir}``. The ``{rundir}``
is the name of the run (as given by ``--name``) or if no name is specified,
``user@host-timestamp`` is used. To change the location of the sandbox
directory, the following options can be specified in
``$HOME/.teuthology.yaml``::
base_test_dir: <directory>
The ``base_test_dir`` option will set the base directory to use for the
individual run directories.
Teuthology currently places most test files and mount points in a
sandbox directory, defaulting to ``/home/$USER/cephtest``. To change
the location of the sandbox directory, the following option can be
specified in ``$HOME/.teuthology.yaml``::
test_path: <directory>
The ``test_path`` option will set the complete path to use for the test
directory. This allows for the old behavior, where ``/tmp/cephtest`` was used
as the sandbox directory.
VIRTUAL MACHINE SUPPORT
=======================

View File

@ -21,8 +21,6 @@ log = logging.getLogger(__name__)
import datetime
stamp = datetime.datetime.now().strftime("%y%m%d%H%M")
global_jobid = None
checked_jobid = False
is_vm = lambda x: x.startswith('vpm') or x.startswith('ubuntu@vpm')
is_arm = lambda x: x.startswith('tala') or x.startswith('ubuntu@tala') or x.startswith('saya') or x.startswith('ubuntu@saya')
@ -30,62 +28,11 @@ is_arm = lambda x: x.startswith('tala') or x.startswith('ubuntu@tala') or x.star
def get_testdir(ctx):
if 'test_path' in ctx.teuthology_config:
return ctx.teuthology_config['test_path']
basedir = get_testdir_base(ctx)
global global_jobid
global checked_jobid
# check if a jobid exists in the machine status for all our targets
# and if its the same jobid, use that as the subdir for the test
if not checked_jobid and ctx.config.get('check-locks') != False:
jobids = {}
for machine in ctx.config['targets'].iterkeys():
status = lockstatus.get_status(ctx, machine)
if status is None or 'description' not in status or status['description'] is None:
continue
jid = status['description'].split('/')[-1]
if jid is None or jid == 'None':
continue
jobids[jid] = 1
if len(jobids) > 1:
break
if len(jobids) == 1:
# same job id on all machines, use that as the test subdir
(jobid,) = jobids.iterkeys()
if jobid is not None:
global_jobid = jobid
log.debug('setting my jobid to {jid}'.format(jid=global_jobid))
checked_jobid = True
# the subdir is chosen using the priority:
# 1. jobid chosen by the teuthology beanstalk queue
# 2. run name specified by teuthology schedule
# 3. user@timestamp
if global_jobid is not None:
log.debug('with jobid basedir: {b}'.format(b=global_jobid))
return '{basedir}/{jobid}'.format(
basedir=basedir,
jobid=global_jobid,
)
elif hasattr(ctx, 'name') and ctx.name:
log.debug('with name basedir: {b}'.format(b=basedir))
# we need a short string to keep the path short
import re
m = re.match(r"(.*)-(.*)-(.*)-(.*)_(.*)-(.*)-(.*)-(.*)-(.*)", ctx.name)
(u, y, m, d, hms, s, c, k, f) = m.groups()
short = u[0:2] + y[2:4] + m[0:2] + d[0:2] + hms[0:2] + hms[3:5] + s[0] + c[0] + k[0] + f[0]
return '{basedir}/{rundir}'.format(
basedir=basedir,
rundir=short,
)
else:
log.debug('basedir: {b}'.format(b=basedir))
return '{basedir}/{user}{stamp}'.format(
basedir=basedir,
user=get_user()[0:2],
stamp=stamp)
test_user = get_test_user(ctx)
# FIXME this ideally should use os.path.expanduser() in the future, in case
# $HOME isn't /home/$USER - e.g. on a Mac. However, since we're executing
# this on the server side, it won't work properly.
return ctx.teuthology_config.get('test_path', '/home/%s/cephtest' % test_user)
def get_test_user(ctx):
"""
@ -94,16 +41,6 @@ def get_test_user(ctx):
return ctx.teuthology_config.get('test_user', 'ubuntu')
def get_testdir_base(ctx):
if 'test_path' in ctx.teuthology_config:
return ctx.teuthology_config['test_path']
test_user = get_test_user(ctx)
# FIXME this ideally should use os.path.expanduser() in the future, in case
# $HOME isn't /home/$USER - e.g. on a Mac. However, since we're executing
# this on the server side, it won't work properly.
return ctx.teuthology_config.get('base_test_dir', '/home/%s/cephtest' %
test_user)
def get_archive_dir(ctx):
test_dir = get_testdir(ctx)
return os.path.normpath(os.path.join(test_dir, 'archive'))

View File

@ -263,13 +263,13 @@ def remove_installed_packages(ctx, log):
install_task.purge_data(ctx)
def remove_testing_tree(ctx, log):
from teuthology.misc import get_testdir_base
from teuthology.misc import get_testdir
from .orchestra import run
nodes = {}
for remote in ctx.cluster.remotes.iterkeys():
proc = remote.run(
args=[
'sudo', 'rm', '-rf', get_testdir_base(ctx),
'sudo', 'rm', '-rf', get_testdir(ctx),
# just for old time's sake
run.Raw('&&'),
'sudo', 'rm', '-rf', '/tmp/cephtest',

View File

@ -18,31 +18,17 @@ log = logging.getLogger(__name__)
@contextlib.contextmanager
def base(ctx, config):
log.info('Creating base directory...')
test_basedir = teuthology.get_testdir_base(ctx)
log.info('Creating test directory...')
testdir = teuthology.get_testdir(ctx)
# make base dir if it doesn't exist
run.wait(
ctx.cluster.run(
args=[
'mkdir', '-m0755', '-p', '--',
test_basedir,
'mkdir', '-m0755', '--',
testdir,
],
wait=False,
)
)
# only create testdir if its not set to basedir
if test_basedir != testdir:
run.wait(
ctx.cluster.run(
args=[
'mkdir', '-m0755', '--',
testdir,
],
wait=False,
)
wait=False,
)
)
try:
yield
finally:
@ -235,32 +221,6 @@ def check_ceph_data(ctx, config):
def check_conflict(ctx, config):
log.info('Checking for old test directory...')
test_basedir = teuthology.get_testdir_base(ctx)
processes = ctx.cluster.run(
args=[
'test', '!', '-e', test_basedir,
],
wait=False,
)
for proc in processes:
assert isinstance(proc.exitstatus, gevent.event.AsyncResult)
try:
proc.exitstatus.get()
except run.CommandFailedError:
# base dir exists
r = proc.remote.run(
args=[
'ls', test_basedir, run.Raw('|'), 'wc', '-l'
],
stdout=StringIO(),
)
if int(r.stdout.getvalue()) > 0:
log.error('WARNING: Host %s has stale test directories, these need to be investigated and cleaned up!',
proc.remote.shortname)
# testdir might be the same as base dir (if test_path is set)
# need to bail out in that case if the testdir exists
testdir = teuthology.get_testdir(ctx)
processes = ctx.cluster.run(
args=[