Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objectstore tool lookup by name & --op list filter #3020

Merged
15 commits merged into from Dec 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 61 additions & 3 deletions src/test/ceph_objectstore_tool.py
Expand Up @@ -457,9 +457,66 @@ def main(argv):
ERRORS += test_failure(cmd, "Must provide --journal-path")

# Test --op list and generate json for all objects
print "Test --op list by generating json for all objects"
TMPFILE = r"/tmp/tmp.{pid}".format(pid=pid)
ALLPGS = OBJREPPGS + OBJECPGS

print "Test --op list variants"
OSDS = get_osds(ALLPGS[0], OSDDIR)
osd = OSDS[0]

# retrieve all objects from all PGs
cmd = (CFSD_PREFIX + "--op list --pretty-format=false").format(osd=osd)
logging.debug(cmd);
tmpfd = open(TMPFILE, "a")
logging.debug(cmd)
ret = call(cmd, shell=True, stdout=tmpfd)
if ret != 0:
logging.error("Bad exit status {ret} from {cmd}".format(ret=ret, cmd=cmd))
ERRORS += 1
tmpfd.close()
lines = get_lines(TMPFILE)
JSONOBJ = sorted(set(lines))
(pgid, jsondict) = json.loads(JSONOBJ[0])[0]

# retrieve all objects in a given PG
cmd = (CFSD_PREFIX + "--op list --pgid {pg} --pretty-format=false").format(osd=osd, pg=pgid)
logging.debug(cmd);
tmpfd = open(OTHERFILE, "a")
logging.debug(cmd)
ret = call(cmd, shell=True, stdout=tmpfd)
if ret != 0:
logging.error("Bad exit status {ret} from {cmd}".format(ret=ret, cmd=cmd))
ERRORS += 1
tmpfd.close()
lines = get_lines(OTHERFILE)
JSONOBJ = sorted(set(lines))
(other_pgid, other_jsondict) = json.loads(JSONOBJ[0])[0]

if pgid != other_pgid or jsondict != other_jsondict:
logging.error("the first line of --op list is different "
"from the first line of --op list --pgid {pg}".format(pg=pgid))
ERRORS += 1

# retrieve all objects with a given name in a given PG
cmd = (CFSD_PREFIX + "--op list --pgid {pg} {object} --pretty-format=false").format(osd=osd, pg=pgid, object=jsondict['oid'])
logging.debug(cmd);
tmpfd = open(OTHERFILE, "a")
logging.debug(cmd)
ret = call(cmd, shell=True, stdout=tmpfd)
if ret != 0:
logging.error("Bad exit status {ret} from {cmd}".format(ret=ret, cmd=cmd))
ERRORS += 1
tmpfd.close()
lines = get_lines(OTHERFILE)
JSONOBJ = sorted(set(lines))
(other_pgid, other_jsondict) in json.loads(JSONOBJ[0])[0]

if pgid != other_pgid or jsondict != other_jsondict:
logging.error("the first line of --op list is different "
"from the first line of --op list --pgid {pg} {object}".format(pg=pgid, object=jsondict['oid']))
ERRORS += 1

print "Test --op list by generating json for all objects using default format"
for pg in ALLPGS:
OSDS = get_osds(pg, OSDDIR)
for osd in OSDS:
Expand All @@ -475,8 +532,9 @@ def main(argv):
lines = get_lines(TMPFILE)
JSONOBJ = sorted(set(lines))
for JSON in JSONOBJ:
jsondict = json.loads(JSON)
db[jsondict['namespace']][jsondict['oid']]['json'] = JSON
(pgid, jsondict) = json.loads(JSON)
db[jsondict['namespace']][jsondict['oid']]['json'] = json.dumps((pgid, jsondict))
# print db[jsondict['namespace']][jsondict['oid']]['json']
if string.find(jsondict['oid'], EC_NAME) == 0 and 'shard_id' not in jsondict:
logging.error("Malformed JSON {json}".format(json=JSON))
ERRORS += 1
Expand Down