From 81a786e9e52ad5168bb7024145ba11f98e35229b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 8 Jun 2013 21:38:18 -0700 Subject: [PATCH] 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 --- src/test/librados/cmd.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/librados/cmd.cc b/src/test/librados/cmd.cc index 66702b02d2435..39484d76af03b 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); -- 2.39.5