From: David Zafman Date: Fri, 28 Feb 2020 01:18:05 +0000 (-0800) Subject: test: Fix failing ceph_objectstore_tool.py test X-Git-Tag: v15.1.1~179^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=08f7e7980ff2e79e43f2d8f0687490f9fa3081d9;p=ceph.git test: Fix failing ceph_objectstore_tool.py test The -N option to vstart.sh was removed, use -k Old hinfo_key binary happen to be utf-8 decodable, now it throws an exception trying to decode it. Use new option to ceph-objectstore-tool to treat stdout as a terminal and convert binary data to base64. Signed-off-by: David Zafman --- diff --git a/qa/standalone/special/ceph_objectstore_tool.py b/qa/standalone/special/ceph_objectstore_tool.py index 0fd6b5d5ce2e..2790bc19b694 100755 --- a/qa/standalone/special/ceph_objectstore_tool.py +++ b/qa/standalone/special/ceph_objectstore_tool.py @@ -152,7 +152,7 @@ def cat_file(level, filename): def vstart(new, opt="-o osd_pool_default_pg_autoscale_mode=off"): print("vstarting....", end="") - NEW = new and "-n" or "-N" + NEW = new and "-n" or "-k" call("MON=1 OSD=4 MDS=0 MGR=1 CEPH_PORT=7400 MGR_PYTHON_PATH={path}/src/pybind/mgr {path}/src/vstart.sh --filestore --short -l {new} -d {opt} > /dev/null 2>&1".format(new=NEW, opt=opt, path=CEPH_ROOT), shell=True) print("DONE") @@ -1535,7 +1535,7 @@ def main(argv): jsondict[1]['shard_id'] = int(pg.split('s')[1]) JSON = json.dumps((pg, jsondict[1])) for osd in OSDS: - cmd = (CFSD_PREFIX + " '{json}' get-attr hinfo_key").format(osd=osd, json=JSON) + cmd = (CFSD_PREFIX + " --tty '{json}' get-attr hinfo_key").format(osd=osd, json=JSON) logging.debug("TRY: " + cmd) try: out = check_output(cmd, shell=True, stderr=subprocess.STDOUT) @@ -1543,9 +1543,9 @@ def main(argv): found += 1 except subprocess.CalledProcessError as e: logging.debug("Error message: {output}".format(output=e.output)) - if "No such file or directory" not in e.output and \ - "No data available" not in e.output and \ - "not contained by pg" not in e.output: + if "No such file or directory" not in str(e.output) and \ + "No data available" not in str(e.output) and \ + "not contained by pg" not in str(e.output): raise # Assuming k=2 m=1 for the default ec pool if found != 3: diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 9422ad239ebe..3699c3821c95 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -3199,7 +3199,7 @@ int main(int argc, char **argv) ghobject_t ghobj; bool human_readable; Formatter *formatter; - bool head; + bool head, tty; po::options_description desc("Allowed options"); desc.add_options() @@ -3239,6 +3239,7 @@ int main(int argc, char **argv) ("skip-mount-omap", "Disable mounting of omap") ("head", "Find head/snapdir when searching for objects by name") ("dry-run", "Don't modify the objectstore") + ("tty", "Treat stdout as a tty (no binary data)") ("namespace", po::value(&argnspace), "Specify namespace when searching for objects") ("rmtype", po::value(&rmtypestr), "Specify corrupting object removal 'snapmap' or 'nosnapmap' - TESTING USE ONLY") ("slow-omap-threshold", po::value(&slow_threshold), @@ -3293,6 +3294,7 @@ int main(int argc, char **argv) nspace = argnspace; dry_run = (vm.count("dry-run") > 0); + tty = (vm.count("tty") > 0); osflagbits_t flags = 0; if (dry_run || vm.count("skip-journal-replay")) @@ -3389,7 +3391,7 @@ int main(int argc, char **argv) usage(desc); return 1; } - outistty = isatty(STDOUT_FILENO); + outistty = isatty(STDOUT_FILENO) || tty; file_fd = fd_none; if ((op == "export" || op == "export-remove" || op == "get-osdmap" || op == "get-inc-osdmap") && !dry_run) {