]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
remove basedir/testdir distinction
authorSage Weil <sage@inktank.com>
Tue, 10 Sep 2013 17:53:41 +0000 (10:53 -0700)
committerSage Weil <sage@inktank.com>
Tue, 10 Sep 2013 19:23:08 +0000 (12:23 -0700)
We should never run with a conflicting testdir in the basedir, and the
code to do this is confusing and buggy.  Go back to a single testdir and
simple checks.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 5acc57f5ad6ed14b3e1c89166d2571cf302a467c)

Conflicts:

README.rst
teuthology/misc.py

README.rst
teuthology/misc.py
teuthology/nuke.py
teuthology/task/internal.py

index 91bbb55c81c9f1ab9d524a92d9f7d689f9c548cf..f2d6e3cbcf5b1bb0cee18b102685d545c7c69776 100644 (file)
@@ -303,24 +303,15 @@ this issue.
 Test Sandbox Directory
 ======================
 
-Teuthology currently places most test files and mount points in a sandbox
-directory, defaulting to ``/tmp/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.  If not specified, this defaults to: ``/tmp/cephtest``.
+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.
-
+=======
+>>>>>>> 5acc57f... remove basedir/testdir distinction
 
 VIRTUAL MACHINE SUPPORT
 =======================
index 1a0eee7e4ce046f7dd033d89dfb43185ddbee774..cf531e6a5e1cf09deff7db1b2f5d841515487e69 100644 (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,66 +28,22 @@ 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']
+    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)
 
-    basedir = ctx.teuthology_config.get('base_test_dir', '/home/ubuntu/cephtest')
-
-    global global_jobid
-    global checked_jobid
+def get_test_user(ctx):
+    """
+    :returns: str -- the user to run tests as on remote hosts
+    """
+    return ctx.teuthology_config.get('test_user', 'ubuntu')
 
-    # 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)
 
-def get_testdir_base(ctx):
-    if 'test_path' in ctx.teuthology_config:
-        return ctx.teuthology_config['test_path']
-    return ctx.teuthology_config.get('base_test_dir', '/home/ubuntu/cephtest')
+def get_archive_dir(ctx):
+    test_dir = get_testdir(ctx)
+    return os.path.normpath(os.path.join(test_dir, 'archive'))
 
 def get_ceph_binary_url(package=None,
                         branch=None, tag=None, sha1=None, dist=None,
index 82389f99d5ec2664f8d9207345d461f64c004bb1..0dfffb84a9354bfc74df93e562fe40e422d37eb0 100644 (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',
index 755af8f52615bae1c115e660ac6a1279fb89a798..c7dff23eec5b8203ec10d56a166aa0d312072922 100644 (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,
-                ],
-                wait=False,
-                )
-        )
-    # only create testdir if its not set to basedir
-    if test_basedir != testdir:
-        run.wait(
-            ctx.cluster.run(
-                args=[
-                    'mkdir', '-m0755', '--',
-                    testdir,
+                '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=[