From: Sage Weil Date: Thu, 17 Dec 2015 20:38:17 +0000 (-0500) Subject: Merge pull request #6405 from jcsp/wip-9963 X-Git-Tag: v10.0.3~215 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a32dd5e3b22fe2cbccf414c6c46a24ef3f421758;p=ceph.git Merge pull request #6405 from jcsp/wip-9963 librados: new style (sharded) object listing Reviewed-by: Sage Weil --- a32dd5e3b22fe2cbccf414c6c46a24ef3f421758 diff --cc src/test/librados/test.cc index b82936af677,488b35c0b7f..469b7145bff --- a/src/test/librados/test.cc +++ b/src/test/librados/test.cc @@@ -45,43 -145,44 +145,73 @@@ std::string create_one_pool return ""; } -int destroy_ec_profile(rados_t *cluster) +int destroy_ec_profile(rados_t *cluster, std::ostream &oss) { - char *cmd[2]; - cmd[0] = (char *)"{\"prefix\": \"osd erasure-code-profile rm\", \"name\": \"testprofile\"}"; - cmd[1] = NULL; - return rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0); + char *cmd[2]; + cmd[0] = (char *)"{\"prefix\": \"osd erasure-code-profile rm\", \"name\": \"testprofile\"}"; + cmd[1] = NULL; + int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0); + if (ret) + oss << "rados_mon_command: erasure-code-profile rm testprofile failed with error " << ret; + return ret; +} + +int destroy_ruleset(rados_t *cluster, + std::string ruleset, + std::ostream &oss) +{ + char *cmd[2]; + std::string tmp = ("{\"prefix\": \"osd crush rule rm\", \"name\":\"" + + ruleset + "\"}"); + cmd[0] = (char*)tmp.c_str(); + cmd[1] = NULL; + int ret = rados_mon_command(*cluster, (const char **)cmd, 1, "", 0, NULL, 0, NULL, 0); + if (ret) + oss << "rados_mon_command: osd crush rule rm " + ruleset + " failed with error " << ret; + return ret; +} + +int destroy_ec_profile_and_ruleset(rados_t *cluster, + std::string ruleset, + std::ostream &oss) +{ + int ret; + ret = destroy_ec_profile(cluster, oss); + if (ret) + return ret; + return destroy_ruleset(cluster, ruleset, oss); } + std::string set_pg_num( + rados_t *cluster, const std::string &pool_name, uint32_t pg_num) + { + // Wait for 'creating' to clear + int r = wait_for_healthy(cluster); + if (r != 0) { + goto err; + } + + // Adjust pg_num + r = rados_pool_set(cluster, pool_name, "pg_num", stringify(pg_num)); + if (r != 0) { + goto err; + } + + // Wait for 'creating' to clear + r = wait_for_healthy(cluster); + if (r != 0) { + goto err; + } + + return ""; + + err: + rados_shutdown(*cluster); + std::ostringstream oss; + oss << __func__ << "(" << pool_name << ") failed with error " << r; + return oss.str(); + } + std::string create_one_ec_pool(const std::string &pool_name, rados_t *cluster) { std::string err = connect_cluster(cluster);