]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/librados/cmd.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / test / librados / cmd.cc
index 0db73471326caa43a67b697b4e3bdde0cf94012c..49465c3bccea9a3469afcc180f98d40fed518fee 100644 (file)
@@ -1,23 +1,18 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
-#include "mds/mdstypes.h"
-#include "include/buffer.h"
-#include "include/rbd_types.h"
 #include "include/rados/librados.h"
 #include "include/rados/librados.hpp"
 #include "include/stringify.h"
 #include "test/librados/test.h"
 
-#include "common/Cond.h"
-
 #include "gtest/gtest.h"
 #include <errno.h>
+#include <condition_variable>
 #include <map>
 #include <sstream>
 #include <string>
 
-using namespace librados;
 using std::map;
 using std::ostringstream;
 using std::string;
@@ -92,18 +87,6 @@ TEST(LibRadosCmd, MonDescribe) {
   rados_shutdown(cluster);
 }
 
-TEST(LibRadosCmd, MonDescribePP) {
-  Rados cluster;
-  ASSERT_EQ("", connect_cluster_pp(cluster));
-  bufferlist inbl, outbl;
-  string outs;
-  ASSERT_EQ(0, cluster.mon_command("{\"prefix\": \"get_command_descriptions\"}",
-                                  inbl, &outbl, &outs));
-  ASSERT_LT(0u, outbl.length());
-  ASSERT_LE(0u, outs.length());
-  cluster.shutdown();
-}
-
 TEST(LibRadosCmd, OSDCmd) {
   rados_t cluster;
   ASSERT_EQ("", connect_cluster(&cluster));
@@ -132,27 +115,6 @@ TEST(LibRadosCmd, OSDCmd) {
   rados_shutdown(cluster);
 }
 
-TEST(LibRadosCmd, OSDCmdPP) {
-  Rados cluster;
-  ASSERT_EQ("", connect_cluster_pp(cluster));
-  int r;
-  bufferlist inbl, outbl;
-  string outs;
-  string cmd;
-
-  // note: tolerate NXIO here in case the cluster is thrashing out underneath us.
-  cmd = "asdfasdf";
-  r = cluster.osd_command(0, cmd, inbl, &outbl, &outs);
-  ASSERT_TRUE(r == -22 || r == -ENXIO);
-  cmd = "version";
-  r = cluster.osd_command(0, cmd, inbl, &outbl, &outs);
-  ASSERT_TRUE(r == -22 || r == -ENXIO);
-  cmd = "{\"prefix\":\"version\"}";
-  r = cluster.osd_command(0, cmd, inbl, &outbl, &outs);
-  ASSERT_TRUE((r == 0 && outbl.length() > 0) || (r == -ENXIO && outbl.length() == 0));
-  cluster.shutdown();
-}
-
 TEST(LibRadosCmd, PGCmd) {
   rados_t cluster;
   std::string pool_name = get_temp_pool_name();
@@ -197,54 +159,13 @@ TEST(LibRadosCmd, PGCmd) {
   ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
 }
 
-TEST(LibRadosCmd, PGCmdPP) {
-  Rados cluster;
-  std::string pool_name = get_temp_pool_name();
-  ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
-
-  int r;
-  bufferlist inbl, outbl;
-  string outs;
-  string cmd;
-
-  int64_t poolid = cluster.pool_lookup(pool_name.c_str());
-  ASSERT_LT(0, poolid);
-
-  string pgid = stringify(poolid) + ".0";
-
-  cmd = "asdfasdf";
-  // note: tolerate NXIO here in case the cluster is thrashing out underneath us.
-  r = cluster.pg_command(pgid.c_str(), cmd, inbl, &outbl, &outs);
-  ASSERT_TRUE(r == -22 || r == -ENXIO);
-
-  // make sure the pg exists on the osd before we query it
-  IoCtx io;
-  cluster.ioctx_create(pool_name.c_str(), io);
-  for (int i=0; i<100; i++) {
-    string oid = "obj" + stringify(i);
-    ASSERT_EQ(-ENOENT, io.stat(oid, NULL, NULL));
-  }
-  io.close();
-
-  cmd = "{\"prefix\":\"pg\", \"cmd\":\"query\", \"pgid\":\"" +  pgid + "\"}";
-  // note: tolerate ENOENT/ENXIO here if hte osd is thrashing out underneath us
-  r = cluster.pg_command(pgid.c_str(), cmd, inbl, &outbl, &outs);
-  ASSERT_TRUE(r == 0 || r == -ENOENT || r == -ENXIO);
-
-  ASSERT_LT(0u, outbl.length());
-
-  ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
-}
-
 struct Log {
   list<string> log;
-  Cond cond;
-  Mutex lock;
-
-  Log() : lock("l::lock") {}
+  std::condition_variable cond;
+  std::mutex lock;
 
-  bool contains(string str) {
-    Mutex::Locker l(lock);
+  bool contains(const string& str) {
+    std::lock_guard<std::mutex> l(lock);
     for (list<string>::iterator p = log.begin(); p != log.end(); ++p) {
       if (p->find(str) != std::string::npos)
        return true;
@@ -259,9 +180,9 @@ void log_cb(void *arg,
             uint64_t seq, const char *level,
             const char *msg) {
   Log *l = static_cast<Log *>(arg);
-  Mutex::Locker locker(l->lock);
+  std::lock_guard<std::mutex> locker(l->lock);
   l->log.push_back(line);
-  l->cond.Signal();
+  l->cond.notify_all();
   cout << "got: " << line << std::endl;
 }