From f3a91d2ecda7929e7760ed85a18f78299f3ca6ec Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Fri, 21 Nov 2014 15:52:25 +0100 Subject: [PATCH] repair_test: rework indentation to make it pep8 clean Signed-off-by: Loic Dachary --- tasks/ceph_manager.py | 8 +++++--- tasks/repair_test.py | 35 +++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/tasks/ceph_manager.py b/tasks/ceph_manager.py index c880352b3af17..1d12d16585efc 100644 --- a/tasks/ceph_manager.py +++ b/tasks/ceph_manager.py @@ -30,7 +30,8 @@ def write_conf(ctx, conf_path=DEFAULT_CONF_PATH): 'sudo', 'chmod', '0755', '/etc/ceph', run.Raw('&&'), 'sudo', 'python', '-c', - 'import shutil, sys; shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))', + ('import shutil, sys; ' + 'shutil.copyfileobj(sys.stdin, file(sys.argv[1], "wb"))'), conf_path, run.Raw('&&'), 'sudo', 'chmod', '0644', conf_path, @@ -184,13 +185,13 @@ class Thrasher: "--data-path {fpath} --journal-path {jpath} " "--type keyvaluestore " "--log-file=" - "/var/log/ceph/objectstore_tool.\\$pid.log". + "/var/log/ceph/objectstore_tool.\\$pid.log ". format(fpath=FSPATH, jpath=JPATH)) else: prefix = ("sudo ceph-objectstore-tool " "--data-path {fpath} --journal-path {jpath} " "--log-file=" - "/var/log/ceph/objectstore_tool.\\$pid.log". + "/var/log/ceph/objectstore_tool.\\$pid.log ". format(fpath=FSPATH, jpath=JPATH)) cmd = (prefix + "--op list-pgs").format(id=exp_osd) proc = exp_remote.run(args=cmd, wait=True, @@ -633,6 +634,7 @@ class Thrasher: time.sleep(delay) self.all_up() + class CephManager: """ Ceph manager object. diff --git a/tasks/repair_test.py b/tasks/repair_test.py index e4719bdaacda9..7b22fbf53231a 100644 --- a/tasks/repair_test.py +++ b/tasks/repair_test.py @@ -10,6 +10,7 @@ from teuthology import misc as teuthology log = logging.getLogger(__name__) + def choose_primary(ctx, pool, num): """ Return primary to test on. @@ -17,6 +18,7 @@ def choose_primary(ctx, pool, num): log.info("Choosing primary") return ctx.manager.get_pg_primary(pool, num) + def choose_replica(ctx, pool, num): """ Return replica to test on. @@ -24,6 +26,7 @@ def choose_replica(ctx, pool, num): log.info("Choosing replica") return ctx.manager.get_pg_replica(pool, num) + def trunc(ctx, osd, pool, obj): """ truncate an object @@ -33,15 +36,17 @@ def trunc(ctx, osd, pool, obj): osd, ['truncobj', pool, obj, '1']) + def dataerr(ctx, osd, pool, obj): """ - cause an error in the data + cause an error in the data """ log.info("injecting data err on object") return ctx.manager.osd_admin_socket( osd, ['injectdataerr', pool, obj]) + def mdataerr(ctx, osd, pool, obj): """ cause an error in the mdata @@ -51,12 +56,14 @@ def mdataerr(ctx, osd, pool, obj): osd, ['injectmdataerr', pool, obj]) + def omaperr(ctx, osd, pool, obj): """ Cause an omap error. """ log.info("injecting omap err on object") - return ctx.manager.osd_admin_socket(osd, ['setomapval', pool, obj, 'badkey', 'badval']); + return ctx.manager.osd_admin_socket(osd, ['setomapval', pool, obj, + 'badkey', 'badval']) def repair_test_1(ctx, corrupter, chooser, scrub_type): """ @@ -101,13 +108,14 @@ def repair_test_1(ctx, corrupter, chooser, scrub_type): assert not ctx.manager.pg_inconsistent(pool, 0) log.info("done") + def repair_test_2(ctx, config, chooser): """ First creates a set of objects and sets the omap value. It then corrupts an object, does both a scrub and a deep-scrub, and then corrupts more objects. After that, it repairs the pool and makes sure that the pool is consistent some - time after a deep-scrub. + time after a deep-scrub. :param chooser: primary or replica selection routine. """ @@ -122,12 +130,14 @@ def repair_test_2(ctx, config, chooser): # create object log.info("doing put and setomapval") ctx.manager.do_put(pool, 'file1', '/etc/hosts') - ctx.manager.do_rados(mon, ['-p', pool, 'setomapval', 'file1', 'key', 'val']) + ctx.manager.do_rados(mon, ['-p', pool, 'setomapval', 'file1', + 'key', 'val']) ctx.manager.do_put(pool, 'file2', '/etc/hosts') ctx.manager.do_put(pool, 'file3', '/etc/hosts') ctx.manager.do_put(pool, 'file4', '/etc/hosts') ctx.manager.do_put(pool, 'file5', '/etc/hosts') - ctx.manager.do_rados(mon, ['-p', pool, 'setomapval', 'file5', 'key', 'val']) + ctx.manager.do_rados(mon, ['-p', pool, 'setomapval', 'file5', + 'key', 'val']) ctx.manager.do_put(pool, 'file6', '/etc/hosts') # corrupt object @@ -196,7 +206,20 @@ def task(ctx, config): - chef: - install: - ceph: - log-whitelist: ['candidate had a read error', 'deep-scrub 0 missing, 1 inconsistent objects', 'deep-scrub 0 missing, 4 inconsistent objects', 'deep-scrub 1 errors', 'deep-scrub 4 errors', '!= known omap_digest', 'repair 0 missing, 1 inconsistent objects', 'repair 0 missing, 4 inconsistent objects', 'repair 1 errors, 1 fixed', 'repair 4 errors, 4 fixed', 'scrub 0 missing, 1 inconsistent', 'scrub 1 errors', 'size 1 != known size'] + log-whitelist: + - 'candidate had a read error' + - 'deep-scrub 0 missing, 1 inconsistent objects' + - 'deep-scrub 0 missing, 4 inconsistent objects' + - 'deep-scrub 1 errors' + - 'deep-scrub 4 errors' + - '!= known omap_digest' + - 'repair 0 missing, 1 inconsistent objects' + - 'repair 0 missing, 4 inconsistent objects' + - 'repair 1 errors, 1 fixed' + - 'repair 4 errors, 4 fixed' + - 'scrub 0 missing, 1 inconsistent' + - 'scrub 1 errors' + - 'size 1 != known size' conf: osd: filestore debug inject read err: true -- 2.39.5