Skip to content

Commit

Permalink
test: Use a config variable debug_version_for_testing
Browse files Browse the repository at this point in the history
Signed-off-by: David Zafman <[email protected]>
  • Loading branch information
dzafman committed Nov 11, 2020
1 parent c2a3a22 commit e5b1ae5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/common/admin_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ class VersionHook : public AdminSocketHook {
} 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") {
Expand Down
4 changes: 4 additions & 0 deletions src/common/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/common/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/common/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
#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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/common/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
#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);
Expand Down
2 changes: 1 addition & 1 deletion src/crimson/admin/admin_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/global/signal_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libcephfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/mon/Monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/tools/immutable_object_cache/CacheClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e5b1ae5

Please sign in to comment.