]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: fix pg command test
authorSage Weil <sage@inktank.com>
Sun, 9 Jun 2013 04:38:18 +0000 (21:38 -0700)
committerSage Weil <sage@inktank.com>
Sun, 9 Jun 2013 04:38:18 +0000 (21:38 -0700)
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 <sage@inktank.com>
src/test/librados/cmd.cc

index 66702b02d24358cdd07022e9dbb9ec1098bab973..39484d76af03b72bea519c89439b4acbbb510327 100644 (file)
@@ -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);