From: Josh Durgin Date: Mon, 22 Jul 2013 21:21:51 +0000 (-0700) Subject: task_util: move rados command here X-Git-Tag: 1.1.0~2053 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=721280b7f3e3a23bc48cc89f67b1866031b42ed1;p=teuthology.git task_util: move rados command here Six copies are replaced with one, with an added option to check status automatically. This should probably be used in a few places where the return code is ignored. Signed-off-by: Josh Durgin --- diff --git a/teuthology/task/divergent_priors.py b/teuthology/task/divergent_priors.py index 2c77a4956..18aca5b57 100644 --- a/teuthology/task/divergent_priors.py +++ b/teuthology/task/divergent_priors.py @@ -1,31 +1,13 @@ import logging +import time + import ceph_manager from teuthology import misc as teuthology -import time +from teuthology.task_util.rados import rados log = logging.getLogger(__name__) - -def rados(testdir, remote, cmd, wait=True): - log.info("rados %s" % ' '.join(cmd)) - pre = [ - '{tdir}/adjust-ulimits'.format(tdir=testdir), - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'rados', - ]; - pre.extend(cmd) - proc = remote.run( - args=pre, - check_status=False, - wait=wait - ) - if wait: - return proc.exitstatus - else: - return proc - def task(ctx, config): """ Test handling of divergent entries with prior_version @@ -42,7 +24,6 @@ def task(ctx, config): first_mon = teuthology.get_first_mon(ctx, config) (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() - testdir = teuthology.get_testdir(ctx) manager = ceph_manager.CephManager( mon, ctx=ctx, @@ -81,7 +62,7 @@ def task(ctx, config): log.info('writing initial objects') # write 1000 objects for i in range(1000): - rados(testdir, mon, ['-p', 'foo', 'put', 'existing_%d' % i, dummyfile]) + rados(ctx, mon, ['-p', 'foo', 'put', 'existing_%d' % i, dummyfile]) manager.wait_for_clean() @@ -93,7 +74,7 @@ def task(ctx, config): # write 1 (divergent) object log.info('writing divergent object existing_0') rados( - testdir, mon, ['-p', 'foo', 'put', 'existing_0', dummyfile2], + ctx, mon, ['-p', 'foo', 'put', 'existing_0', dummyfile2], wait=False) time.sleep(10) mon.run( @@ -123,7 +104,7 @@ def task(ctx, config): # write 1 non-divergent object (ensure that old divergent one is divergent) log.info('writing non-divergent object existing_1') - rados(testdir, mon, ['-p', 'foo', 'put', 'existing_1', dummyfile2]) + rados(ctx, mon, ['-p', 'foo', 'put', 'existing_1', dummyfile2]) manager.wait_for_recovery() @@ -145,7 +126,7 @@ def task(ctx, config): manager.mark_in_osd(divergent) log.info('wait for peering') - rados(testdir, mon, ['-p', 'foo', 'put', 'foo', dummyfile]) + rados(ctx, mon, ['-p', 'foo', 'put', 'foo', dummyfile]) log.info("killing divergent %d", divergent) manager.kill_osd(divergent) @@ -157,7 +138,7 @@ def task(ctx, config): manager.set_config(i, osd_recovery_delay_start=0) log.info('reading existing_0') - exit_status = rados(testdir, mon, + exit_status = rados(ctx, mon, ['-p', 'foo', 'get', 'existing_0', '-o', '/tmp/existing']) assert exit_status is 0 diff --git a/teuthology/task/lost_unfound.py b/teuthology/task/lost_unfound.py index c6dc47612..d7c0fc3c1 100644 --- a/teuthology/task/lost_unfound.py +++ b/teuthology/task/lost_unfound.py @@ -1,27 +1,10 @@ import logging import ceph_manager from teuthology import misc as teuthology - +from teuthology.task_util.rados import rados log = logging.getLogger(__name__) - -def rados(ctx, remote, cmd): - testdir = teuthology.get_testdir(ctx) - log.info("rados %s" % ' '.join(cmd)) - pre = [ - '{tdir}/adjust-ulimits'.format(tdir=testdir), - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'rados', - ]; - pre.extend(cmd) - proc = remote.run( - args=pre, - check_status=False - ) - return proc.exitstatus - def task(ctx, config): """ Test handling of lost objects. diff --git a/teuthology/task/object_source_down.py b/teuthology/task/object_source_down.py index eb0827c0e..544b88640 100644 --- a/teuthology/task/object_source_down.py +++ b/teuthology/task/object_source_down.py @@ -1,26 +1,10 @@ import logging import ceph_manager from teuthology import misc as teuthology - +from teuthology.task_util.rados import rados log = logging.getLogger(__name__) - -def rados(testdir, remote, cmd): - log.info("rados %s" % ' '.join(cmd)) - pre = [ - '{tdir}/adjust-ulimits'.format(tdir=testdir), - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'rados', - ]; - pre.extend(cmd) - proc = remote.run( - args=pre, - check_status=False - ) - return proc.exitstatus - def task(ctx, config): """ Test handling of object location going down @@ -75,14 +59,12 @@ def task(ctx, config): '--osd-recovery-delay-start 10000 --osd-min-pg-log-entries 100000000' ) - testdir = teuthology.get_testdir(ctx) - # kludge to make sure they get a map - rados(testdir, mon, ['-p', 'data', 'put', 'dummy', dummyfile]) + rados(ctx, mon, ['-p', 'data', 'put', 'dummy', dummyfile]) # create old objects for f in range(1, 10): - rados(testdir, mon, ['-p', 'data', 'put', 'existing_%d' % f, dummyfile]) + rados(ctx, mon, ['-p', 'data', 'put', 'existing_%d' % f, dummyfile]) manager.mark_out_osd(3) manager.wait_till_active() diff --git a/teuthology/task/osd_failsafe_enospc.py b/teuthology/task/osd_failsafe_enospc.py index 63a323068..92e5af90c 100644 --- a/teuthology/task/osd_failsafe_enospc.py +++ b/teuthology/task/osd_failsafe_enospc.py @@ -1,32 +1,14 @@ from cStringIO import StringIO import logging -import ceph_manager -from teuthology import misc as teuthology import time + +import ceph_manager from ..orchestra import run +from teuthology.task_util.rados import rados +from teuthology import misc as teuthology log = logging.getLogger(__name__) - -def rados(testdir, remote, cmd, wait=True): - log.info("rados %s" % ' '.join(cmd)) - pre = [ - '{tdir}/adjust-ulimits'.format(tdir=testdir), - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'rados', - ]; - pre.extend(cmd) - proc = remote.run( - args=pre, - check_status=False, - wait=wait - ) - if wait: - return proc.exitstatus - else: - return proc - def task(ctx, config): """ Test handling of osd_failsafe_nearfull_ratio and osd_failsafe_full_ratio @@ -49,7 +31,6 @@ def task(ctx, config): first_mon = teuthology.get_first_mon(ctx, config) (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() - testdir = teuthology.get_testdir(ctx) manager = ceph_manager.CephManager( mon, ctx=ctx, @@ -129,7 +110,7 @@ def task(ctx, config): log.info('3. Verify write failure when exceeding full_ratio') # Write data should fail - ret = rados(testdir, mon, ['-p', 'foo', 'put', 'newfile1', dummyfile]) + ret = rados(ctx, mon, ['-p', 'foo', 'put', 'newfile1', dummyfile]) assert ret != 0, 'Expected write failure but it succeeded with exit status 0' # Put back default @@ -140,7 +121,7 @@ def task(ctx, config): log.info('4. Verify write success when NOT exceeding full_ratio') # Write should succeed - ret = rados(testdir, mon, ['-p', 'foo', 'put', 'newfile2', dummyfile2]) + ret = rados(ctx, mon, ['-p', 'foo', 'put', 'newfile2', dummyfile2]) assert ret == 0, 'Expected write to succeed, but got exit status %d' % ret log.info('5. Verify warning messages again when exceeding nearfull_ratio') diff --git a/teuthology/task/peer.py b/teuthology/task/peer.py index 93a758f24..3fb8b4b6f 100644 --- a/teuthology/task/peer.py +++ b/teuthology/task/peer.py @@ -1,28 +1,12 @@ import logging -import ceph_manager import json -from teuthology import misc as teuthology +import ceph_manager +from teuthology import misc as teuthology +from teuthology.task_util.rados import rados log = logging.getLogger(__name__) - -def rados(ctx, remote, cmd): - testdir = teuthology.get_testdir(ctx) - log.info("rados %s" % ' '.join(cmd)) - pre = [ - '{tdir}/adjust-ulimits'.format(tdir=testdir), - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'rados', - ]; - pre.extend(cmd) - proc = remote.run( - args=pre, - check_status=False - ) - return proc.exitstatus - def task(ctx, config): """ Test peering. diff --git a/teuthology/task/rgw.py b/teuthology/task/rgw.py index 7296de3b6..860e0f9c9 100644 --- a/teuthology/task/rgw.py +++ b/teuthology/task/rgw.py @@ -5,32 +5,15 @@ import os from cStringIO import StringIO +import ceph_manager +from ..orchestra import run from teuthology import misc as teuthology from teuthology import contextutil from teuthology.task_util.rgw import rgwadmin -from ..orchestra import run -import ceph_manager +from teuthology.task_util.rados import rados log = logging.getLogger(__name__) -# this was lifted from lost_unfound.py -def rados(ctx, remote, cmd): - testdir = teuthology.get_testdir(ctx) - log.info("rados %s" % ' '.join(cmd)) - pre = [ - '{tdir}/adjust-ulimits'.format(tdir=testdir), - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'rados', - ]; - pre.extend(cmd) - proc = remote.run( - args=pre, - check_status=False - ) - - return proc.exitstatus - @contextlib.contextmanager def create_dirs(ctx, config): log.info('Creating apache directories...') diff --git a/teuthology/task_util/rados.py b/teuthology/task_util/rados.py new file mode 100644 index 000000000..187b5b90e --- /dev/null +++ b/teuthology/task_util/rados.py @@ -0,0 +1,25 @@ +import logging + +from teuthology import misc as teuthology + +log = logging.getLogger(__name__) + +def rados(ctx, remote, cmd, wait=True, check_status=False): + testdir = teuthology.get_testdir(ctx) + log.info("rados %s" % ' '.join(cmd)) + pre = [ + '{tdir}/enable-coredump'.format(tdir=testdir), + 'ceph-coverage', + '{tdir}/archive/coverage'.format(tdir=testdir), + 'rados', + ]; + pre.extend(cmd) + proc = remote.run( + args=pre, + check_status=check_status, + wait=wait, + ) + if wait: + return proc.exitstatus + else: + return proc