From: David Zafman Date: Sat, 23 May 2015 00:41:40 +0000 (-0700) Subject: test/ceph_objectstore_tool: Improve dump-journal testing X-Git-Tag: v0.94.7~28^2~10^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=13360d3a55818fc5b63a2bb9889a67f3fc98d286;p=ceph.git test/ceph_objectstore_tool: Improve dump-journal testing Fix false failure when journal has no entries Test dump-journal on all osds in 2 places Signed-off-by: David Zafman (cherry picked from commit ce76f88777ec026521cce465095d6376efd460a8) --- diff --git a/src/test/ceph_objectstore_tool.py b/src/test/ceph_objectstore_tool.py index afa02fde0c06..10ce56f71e7f 100755 --- a/src/test/ceph_objectstore_tool.py +++ b/src/test/ceph_objectstore_tool.py @@ -224,8 +224,7 @@ def check_journal(jsondict): logging.error("Key 'entries' not in dump-journal output") errors += 1 elif len(jsondict['entries']) == 0: - logging.warning("No entries in journal found, probably a problem") - errors += 1 + logging.info("No entries in journal found") else: errors += check_journal_entries(jsondict['entries']) return errors @@ -287,6 +286,35 @@ def check_transaction_ops(ops, enum, tnum): return errors +def test_dump_journal(CFSD_PREFIX, osds): + ERRORS = 0 + pid = os.getpid() + TMPFILE = r"/tmp/tmp.{pid}".format(pid=pid) + + for osd in osds: + # Test --op dump-journal by loading json + cmd = (CFSD_PREFIX + "--op dump-journal --format json").format(osd=osd) + logging.debug(cmd) + tmpfd = open(TMPFILE, "w") + 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 + continue + tmpfd.close() + tmpfd = open(TMPFILE, "r") + jsondict = json.load(tmpfd) + tmpfd.close() + os.unlink(TMPFILE) + + journal_errors = check_journal(jsondict) + if journal_errors is not 0: + logging.error(jsondict) + ERRORS += journal_errors + + return ERRORS + + CEPH_DIR = "ceph_objectstore_tool_dir" CEPH_CONF = os.path.join(CEPH_DIR, 'ceph.conf') @@ -609,25 +637,9 @@ def main(argv): OSDS = get_osds(ALLPGS[0], OSDDIR) osd = OSDS[0] - # Test --op dump-journal by loading json - print "Test --op dump-journal" - cmd = (CFSD_PREFIX + "--op dump-journal --format json").format(osd=osd) - logging.debug(cmd) - tmpfd = open(TMPFILE, "w") - 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() - tmpfd = open(TMPFILE, "r") - jsondict = json.load(tmpfd) - tmpfd.close() - os.unlink(TMPFILE) - - journal_errors = check_journal(jsondict) - if journal_errors is not 0: - logging.error(jsondict) - ERRORS += journal_errors + print "Test all --op dump-journal" + ALLOSDS = [f for f in os.listdir(OSDDIR) if os.path.isdir(os.path.join(OSDDIR, f)) and string.find(f, "osd") == 0] + ERRORS += test_dump_journal(CFSD_PREFIX, ALLOSDS) # Test --op list and generate json for all objects print "Test --op list variants" @@ -1000,6 +1012,10 @@ def main(argv): else: logging.warning("SKIPPING CHECKING IMPORT DATA DUE TO PREVIOUS FAILURES") + print "Test all --op dump-journal again" + ALLOSDS = [f for f in os.listdir(OSDDIR) if os.path.isdir(os.path.join(OSDDIR, f)) and string.find(f, "osd") == 0] + ERRORS += test_dump_journal(CFSD_PREFIX, ALLOSDS) + vstart(new=False) wait_for_health()