]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test: Use a config variable debug_version_for_testing
authorDavid Zafman <dzafman@redhat.com>
Tue, 25 Aug 2020 01:20:28 +0000 (01:20 +0000)
committerDavid Zafman <dzafman@redhat.com>
Wed, 11 Nov 2020 23:10:11 +0000 (15:10 -0800)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/common/admin_socket.cc
src/common/options.cc
src/common/util.cc
src/common/version.cc
src/common/version.h
src/crimson/admin/admin_socket.cc
src/global/signal_handler.cc
src/libcephfs.cc
src/mon/Monitor.cc
src/tools/immutable_object_cache/CacheClient.cc

index 01021d94193bf10034828f61a2196b2b61ad5fa8..33c528801ded2252e08c68642c412662f1d82715 100644 (file)
@@ -631,7 +631,7 @@ public:
     } else {
       f->open_object_section("version");
       if (command == "version") {
-       f->dump_string("version", ceph_version_to_str());
+       f->dump_string("version", ceph_version_to_str(nullptr));
        f->dump_string("release", ceph_release_to_str());
        f->dump_string("release_type", ceph_release_type());
       } else if (command == "git_version") {
index 8165692f95a8388ab0bccba59452c936daff61fc..ac0cb9b3a0d60c4c4af6068fa4fcadaa976ca1a8 100644 (file)
@@ -8800,6 +8800,10 @@ std::vector<Option> get_mds_client_options() {
     .set_description("Size of thread pool for ASIO completions")
     .add_tag("client"),
 
+    Option("debug_version_for_testing", Option::TYPE_STR, Option::LEVEL_DEV)
+    .set_default("")
+    .set_description("Override ceph_version_short for testing"),
+
     Option("client_shutdown_timeout", Option::TYPE_SECS, Option::LEVEL_ADVANCED)
     .set_flag(Option::FLAG_RUNTIME)
     .set_default(30)
index 6cb1f02733cfce00efd21aca57624b26a91fa927..7e9ca49f0393be04bb5495028c1b99ba3122abe9 100644 (file)
@@ -229,7 +229,7 @@ void collect_sys_info(map<string, string> *m, CephContext *cct)
 {
   // version
   (*m)["ceph_version"] = pretty_version_to_str();
-  (*m)["ceph_version_short"] = ceph_version_to_str();
+  (*m)["ceph_version_short"] = ceph_version_to_str(cct);
   (*m)["ceph_release"] = ceph_release_to_str();
 
   #ifndef _WIN32
index 4d5c001b2e0e0d1a5c777abfce2070a67625435c..24d1c8a843eea145f1867bf177ca0cf2c9e151d2 100644 (file)
 #define _STR(x) #x
 #define STRINGIFY(x) _STR(x)
 
-const char *ceph_version_to_str(void)
+// Keep ver.c_str() available
+static std::string ver;
+
+const char *ceph_version_to_str(CephContext *cct)
 {
+  if (cct) ver = cct->_conf.get_val<std::string>("debug_version_for_testing");
+  if (ver.size() > 0)
+    return ver.c_str();
   return CEPH_GIT_NICE_VER;
 }
 
index 066fa914623f111d0ce7bc1e6d03a4f89f3b3b24..067148a060df61d932b35a0a84fc3a18fcee05db 100644 (file)
 #define CEPH_COMMON_VERSION_H
 
 #include <string>
+#include "common/ceph_context.h"
 
 // Return a string describing the Ceph version
-const char *ceph_version_to_str(void);
+const char *ceph_version_to_str(CephContext *cct);
 
 // Return a string with the Ceph release
 const char *ceph_release_to_str(void);
index 13782ac7e37cd3fb2f2d72ca82cace8d4bcd4009..27cdcf132fcff20d2c758c2e37a161b3914258f1 100644 (file)
@@ -297,7 +297,7 @@ class VersionHook final : public AdminSocketHook {
   {
     unique_ptr<Formatter> f{Formatter::create(format, "json-pretty", "json-pretty")};
     f->open_object_section("version");
-    f->dump_string("version", ceph_version_to_str());
+    f->dump_string("version", ceph_version_to_str(nullptr));
     f->dump_string("release", ceph_release_to_str());
     f->dump_string("release_type", ceph_release_type());
     f->close_section();
index 0447f96e1b18138ddc0122a8b9bae9310c88b141..a9e9e28bf1451e230228b046e60a3834aec9dbb0 100644 (file)
@@ -204,7 +204,7 @@ static void handle_fatal_signal(int signum)
        now.gmtime(jf.dump_stream("timestamp"));
        jf.dump_string("process_name", g_process_name);
        jf.dump_string("entity_name", g_ceph_context->_conf->name.to_str());
-       jf.dump_string("ceph_version", ceph_version_to_str());
+       jf.dump_string("ceph_version", ceph_version_to_str(g_ceph_context));
 
        struct utsname u;
        r = uname(&u);
index a17577ac7fc2f828a2717d9ffa376e2a790fe852..7e280815a0694db0ba2baf7b5941636b9d54c63d 100644 (file)
@@ -362,7 +362,7 @@ extern "C" void ceph_userperm_destroy(UserPerm *perm)
 extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
 {
   int major, minor, patch;
-  const char *v = ceph_version_to_str();
+  const char *v = ceph_version_to_str(nullptr);
 
   int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch);
   if (pmajor)
index 279d786a60cec4627f003d3b2550bcdaec4fc3fa..21c3f7b8d19fcd1c5187c2bf6669e74a19a3f0c4 100644 (file)
@@ -3638,7 +3638,7 @@ void Monitor::handle_command(MonOpRequestRef op)
       f.reset(Formatter::create("json-pretty"));
     f->open_object_section("report");
     f->dump_stream("cluster_fingerprint") << fingerprint;
-    f->dump_string("version", ceph_version_to_str());
+    f->dump_string("version", ceph_version_to_str(cct));
     f->dump_string("commit", git_version_to_str());
     f->dump_stream("timestamp") << ceph_clock_now();
 
index e31713cd5079d519599124126c2d5bc6bc673fb1..d378992719c7bd8f8e4eec04c4cad8e1722a787b 100644 (file)
@@ -380,7 +380,7 @@ namespace immutable_obj_cache {
   int CacheClient::register_client(Context* on_finish) {
     ObjectCacheRequest* reg_req = new ObjectCacheRegData(RBDSC_REGISTER,
                                                          m_sequence_id++,
-                                                         ceph_version_to_str());
+                                                         ceph_version_to_str(m_cct));
     reg_req->encode();
 
     bufferlist bl;