From 0af08071ac8758d64e41a41f6ea9ae413c670fa9 Mon Sep 17 00:00:00 2001 From: Warren Usui Date: Fri, 14 Feb 2014 15:13:01 -0800 Subject: [PATCH] Fix docstrings for task/blktrace.py, peering_speed_test.py, proc_thrasher.py and recovery_bench.py. Fixes: 6535 Signed-off-by: Warren Usui --- teuthology/task/blktrace.py | 19 +++++++++++++++++-- teuthology/task/peering_speed_test.py | 9 +++++++++ teuthology/task/proc_thrasher.py | 17 +++++++++++++++++ teuthology/task/recovery_bench.py | 23 ++++++++++++++++++++++- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/teuthology/task/blktrace.py b/teuthology/task/blktrace.py index bfe05f4235..208bfd533c 100644 --- a/teuthology/task/blktrace.py +++ b/teuthology/task/blktrace.py @@ -1,3 +1,6 @@ +""" +Run blktrace program through teuthology +""" import contextlib import logging @@ -11,11 +14,14 @@ daemon_signal = 'term' @contextlib.contextmanager def setup(ctx, config): + """ + Setup all the remotes + """ osds = ctx.cluster.only(teuthology.is_type('osd')) log_dir = '{tdir}/archive/performance/blktrace'.format(tdir=teuthology.get_testdir(ctx)) for remote, roles_for_host in osds.remotes.iteritems(): - log.info('Creating %s on %s' % (log_dir,remote.name)) + log.info('Creating %s on %s' % (log_dir, remote.name)) remote.run( args=['mkdir', '-p', '-m0755', '--', log_dir], wait=False, @@ -24,8 +30,11 @@ def setup(ctx, config): @contextlib.contextmanager def execute(ctx, config): + """ + Run the blktrace program on remote machines. + """ procs = [] - testdir=teuthology.get_testdir(ctx) + testdir = teuthology.get_testdir(ctx) log_dir = '{tdir}/archive/performance/blktrace'.format(tdir=testdir) osds = ctx.cluster.only(teuthology.is_type('osd')) @@ -64,6 +73,12 @@ def execute(ctx, config): @contextlib.contextmanager def task(ctx, config): + """ + Usage: + blktrace: + + Runs blktrace on all clients. + """ if config is None: config = dict(('client.{id}'.format(id=id_), None) for id_ in teuthology.all_roles_of_type(ctx.cluster, 'client')) diff --git a/teuthology/task/peering_speed_test.py b/teuthology/task/peering_speed_test.py index d70b5a4225..6c885f1c96 100644 --- a/teuthology/task/peering_speed_test.py +++ b/teuthology/task/peering_speed_test.py @@ -1,3 +1,6 @@ +""" +Remotely run peering tests. +""" import logging import time from teuthology import misc as teuthology @@ -19,6 +22,9 @@ ARGS = [ ] def setup(ctx, config): + """ + Setup peering test on remotes. + """ first_mon = teuthology.get_first_mon(ctx, config) (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() ctx.manager = ceph_manager.CephManager( @@ -38,6 +44,9 @@ def setup(ctx, config): log.info("done populating pool") def do_run(ctx, config): + """ + Perform the test. + """ start = time.time() # mark in osd ctx.manager.mark_in_osd(0) diff --git a/teuthology/task/proc_thrasher.py b/teuthology/task/proc_thrasher.py index 472b6ecbdc..1c1100fc56 100644 --- a/teuthology/task/proc_thrasher.py +++ b/teuthology/task/proc_thrasher.py @@ -1,3 +1,6 @@ +""" +Process thrasher +""" import logging import gevent import random @@ -25,18 +28,32 @@ class ProcThrasher: self.run_time = self.config.get("run_time", 1000) # seconds def log(self, msg): + """ + Local log wrapper + """ self.logger.info(msg) def start(self): + """ + Start thrasher. This also makes sure that the greenlet interface + is used. + """ if self.greenlet is not None: return self.greenlet = gevent.Greenlet(self.loop) self.greenlet.start() def join(self): + """ + Local join + """ self.greenlet.join() def loop(self): + """ + Thrashing loop -- loops at time intervals. Inside that loop, the + code loops through the individual procs, creating new procs. + """ time_started = time.time() procs = [] self.log("Starting") diff --git a/teuthology/task/recovery_bench.py b/teuthology/task/recovery_bench.py index 569bba84ca..1984b97d31 100644 --- a/teuthology/task/recovery_bench.py +++ b/teuthology/task/recovery_bench.py @@ -1,3 +1,6 @@ +""" +Recovery system benchmarking +""" from cStringIO import StringIO import contextlib @@ -68,6 +71,9 @@ def task(ctx, config): bench_proc.do_join() class RecoveryBencher: + """ + RecoveryBencher + """ def __init__(self, manager, config): self.ceph_manager = manager self.ceph_manager.wait_for_clean() @@ -81,6 +87,9 @@ class RecoveryBencher: else: def tmp(x): + """ + Local wrapper to print value. + """ print x self.log = tmp @@ -89,9 +98,16 @@ class RecoveryBencher: self.thread = gevent.spawn(self.do_bench) def do_join(self): + """ + Join the recovery bencher. This is called after the main + task exits. + """ self.thread.get() def do_bench(self): + """ + Do the benchmarking. + """ duration = self.config.get("duration", 60) num_objects = self.config.get("num_objects", 500) io_size = self.config.get("io_size", 4096) @@ -160,6 +176,11 @@ class RecoveryBencher: self.ceph_manager.raw_cluster_cmd('osd', 'in', osd) def process_samples(self, input): + """ + Extract samples from the input and process the results + + :param input: input lines in JSON format + """ lat = {} for line in input.split('\n'): try: @@ -167,7 +188,7 @@ class RecoveryBencher: samples = lat.setdefault(sample['type'], []) samples.append(float(sample['latency'])) except Exception: - pass + pass for type in lat: samples = lat[type] -- 2.39.5