From 07e4273c6a0d48adf0dd2f3370e07b99f43bd013 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Sat, 26 Jan 2019 11:25:16 -0800 Subject: [PATCH] test: ceph-objectstore-tool: Add test for EC object dump to check hinfo section Fixes: http://tracker.ceph.com/issues/38053 Signed-off-by: David Zafman --- .../special/ceph_objectstore_tool.py | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/qa/standalone/special/ceph_objectstore_tool.py b/qa/standalone/special/ceph_objectstore_tool.py index e06d3511ead..c423f276158 100755 --- a/qa/standalone/special/ceph_objectstore_tool.py +++ b/qa/standalone/special/ceph_objectstore_tool.py @@ -1457,7 +1457,7 @@ def main(argv): for basename in db[nspace].keys(): file = os.path.join(DATADIR, nspace + "-" + basename + "__head") JSON = db[nspace][basename]['json'] - GETNAME = "/tmp/getbytes.{pid}".format(pid=pid) + jsondict = json.loads(JSON) for pg in OBJREPPGS: OSDS = get_osds(pg, OSDDIR) for osd in OSDS: @@ -1468,12 +1468,33 @@ def main(argv): continue if int(basename.split(REP_NAME)[1]) > int(NUM_CLONED_REP_OBJECTS): continue + logging.debug("REPobject " + JSON) cmd = (CFSD_PREFIX + " '{json}' dump | grep '\"snap\": 1,' > /dev/null").format(osd=osd, json=JSON) logging.debug(cmd) ret = call(cmd, shell=True) if ret != 0: logging.error("Invalid dump for {json}".format(json=JSON)) ERRORS += 1 + if 'shard_id' in jsondict[1]: + logging.debug("ECobject " + JSON) + for pg in OBJECPGS: + OSDS = get_osds(pg, OSDDIR) + jsondict = json.loads(JSON) + for osd in OSDS: + DIR = os.path.join(OSDDIR, os.path.join(osd, os.path.join("current", "{pg}_head".format(pg=pg)))) + fnames = [f for f in os.listdir(DIR) if os.path.isfile(os.path.join(DIR, f)) + and f.split("_")[0] == basename and f.split("_")[4] == nspace] + if not fnames: + continue + if int(basename.split(EC_NAME)[1]) > int(NUM_EC_OBJECTS): + continue + # Fix shard_id since we only have one json instance for each object + jsondict[1]['shard_id'] = int(pg.split('s')[1]) + cmd = (CFSD_PREFIX + " '{json}' dump | grep '\"hinfo\": [{{]' > /dev/null").format(osd=osd, json=json.dumps((pg, jsondict[1]))) + logging.debug(cmd) + ret = call(cmd, shell=True) + if ret != 0: + logging.error("Invalid dump for {json}".format(json=JSON)) print("Test list-attrs get-attr") ATTRFILE = r"/tmp/attrs.{pid}".format(pid=pid)