From: Sage Weil Date: Sun, 9 Jun 2013 04:38:18 +0000 (-0700) Subject: librados: fix pg command test X-Git-Tag: v0.65~124 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=81a786e9e52ad5168bb7024145ba11f98e35229b;p=ceph.git librados: fix pg command test Stat a bunch of (non-existent) random objects in the pool so ensure the pg exists on the OSD before we assert that we get a 0 from querying it. Although it is somewhat tempting to make the pg commands block until the pg exists, that defeats much of the value of the command as a diagnostic tool as it could block indefinitely instead of informing the admin/dev that "the pg isn't there yet". In any case, this fixes the api test failure. Signed-off-by: Sage Weil --- diff --git a/src/test/librados/cmd.cc b/src/test/librados/cmd.cc index 66702b02d243..39484d76af03 100644 --- a/src/test/librados/cmd.cc +++ b/src/test/librados/cmd.cc @@ -97,9 +97,21 @@ TEST(LibRadosCmd, PGCmd) { cmd[0] = (char *)"asdfasdf"; ASSERT_EQ(-22, rados_pg_command(cluster, pgid.c_str(), (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); + + + // make sure the pg exists on the osd before we query it + rados_ioctx_t io; + rados_ioctx_create(cluster, pool_name.c_str(), &io); + for (int i=0; i<100; i++) { + string oid = "obj" + stringify(i); + ASSERT_EQ(-ENOENT, rados_stat(io, oid.c_str(), NULL, NULL)); + } + rados_ioctx_destroy(io); + string qstr = "{\"prefix\":\"pg\", \"cmd\":\"query\", \"pgid\":\"" + pgid + "\"}"; cmd[0] = (char *)qstr.c_str(); ASSERT_EQ(0, rados_pg_command(cluster, pgid.c_str(), (const char **)cmd, 1, "", 0, &buf, &buflen, &st, &stlen)); + ASSERT_LT(0u, buflen); rados_buffer_free(buf); rados_buffer_free(st);