diff --git a/teuthology/task/exec.py b/teuthology/task/exec.py index a914101e402..00994e078cd 100644 --- a/teuthology/task/exec.py +++ b/teuthology/task/exec.py @@ -21,6 +21,8 @@ def task(ctx, config): log.info('Executing custom commands...') assert isinstance(config, dict), "task exec got invalid config" + testdir = teuthology.get_testdir(ctx) + if 'all' in config and len(config) == 1: a = config['all'] roles = teuthology.all_roles(ctx.cluster) @@ -33,6 +35,7 @@ def task(ctx, config): remote.run( args=[ 'sudo', + 'TESTDIR={tdir}'.format(tdir=testdir), 'bash', '-c', c], diff --git a/teuthology/task/pexec.py b/teuthology/task/pexec.py index 72d9e3f3944..3659907a87b 100644 --- a/teuthology/task/pexec.py +++ b/teuthology/task/pexec.py @@ -28,11 +28,16 @@ def _do_barrier(barrier, barrier_queue, remote): else: barrier.wait() -def _exec_host(barrier, barrier_queue, remote, sudo, ls): +def _exec_host(barrier, barrier_queue, remote, sudo, testdir, ls): log.info('Running commands on host %s', remote.name) - args = ['bash', '-s'] + args = [ + 'TESTDIR={tdir}'.format(tdir=testdir), + 'bash', + '-s' + ] if sudo: args.insert(0, 'sudo') + r = remote.run( args=args, stdin=tor.PIPE, wait=False) r.stdin.writelines(['set -e\n']) r.stdin.flush() @@ -123,6 +128,7 @@ def task(ctx, config): sudo = config['sudo'] del config['sudo'] + testdir = teuthology.get_testdir(ctx) remotes = list(_generate_remotes(ctx, config)) count = len(remotes) @@ -133,4 +139,4 @@ def task(ctx, config): _init_barrier(barrier_queue, remote[0]) with parallel() as p: for remote in remotes: - p.spawn(_exec_host, barrier, barrier_queue, remote[0], sudo, remote[1]) + p.spawn(_exec_host, barrier, barrier_queue, remote[0], sudo, testdir, remote[1])