]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_test_cls_hello: only do returndata test on octopus+
authorSage Weil <sage@redhat.com>
Tue, 21 Jan 2020 16:58:09 +0000 (10:58 -0600)
committerSage Weil <sage@redhat.com>
Thu, 23 Jan 2020 23:13:09 +0000 (17:13 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/test/cls_hello/test_cls_hello.cc

index 3b3ae9a7517a33d6366002bfd38e772fa7e8ddee..b5413c89ac79e5ec985d3da0dbfa00dc6ff2ee65 100644 (file)
 
 #include <iostream>
 #include <errno.h>
+#include <string>
 
 #include "include/rados/librados.hpp"
 #include "include/encoding.h"
 #include "test/librados/test_cxx.h"
 #include "gtest/gtest.h"
+#include "json_spirit/json_spirit.h"
 
 using namespace librados;
 
@@ -77,6 +79,32 @@ TEST(ClsHello, RecordHello) {
   ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
 }
 
+static std::string _get_required_osd_release(Rados& cluster)
+{
+  bufferlist inbl;
+  std::string cmd = std::string("{\"prefix\": \"osd dump\",\"format\":\"json\"}");
+  bufferlist outbl;
+  int r = cluster.mon_command(cmd, inbl, &outbl, NULL);
+  ceph_assert(r >= 0);
+  std::string outstr(outbl.c_str(), outbl.length());
+  json_spirit::Value v;
+  if (!json_spirit::read(outstr, v)) {
+    std::cerr <<" unable to parse json " << outstr << std::endl;
+    return "";
+  }
+
+  json_spirit::Object& o = v.get_obj();
+  for (json_spirit::Object::size_type i=0; i<o.size(); i++) {
+    json_spirit::Pair& p = o[i];
+    if (p.name_ == "require_osd_release") {
+      std::cout << "require_osd_release = " << p.value_.get_str() << std::endl;
+      return p.value_.get_str();
+    }
+  }
+  std::cerr << "didn't find require_osd_release in " << outstr << std::endl;
+  return "";
+}
+
 TEST(ClsHello, WriteReturnData) {
   Rados cluster;
   std::string pool_name = get_temp_pool_name();
@@ -84,6 +112,12 @@ TEST(ClsHello, WriteReturnData) {
   IoCtx ioctx;
   cluster.ioctx_create(pool_name.c_str(), ioctx);
 
+  // skip test if not yet mimic
+  if (_get_required_osd_release(cluster) < "octopus") {
+    std::cout << "cluster is not yet octopus, skipping test" << std::endl;
+    return;
+  }
+
   // this will return nothing -- not flag set
   bufferlist in, out;
   ASSERT_EQ(0, ioctx.exec("myobject", "hello", "write_return_data", in, out));