1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2017 Red Hat
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include <algorithm> // for move
16 #include <iostream> // for ostream
17 #include <memory> // for unique_ptr
18 #include <string> // for operator<<
19 #include <vector> // for vector
20 #include <boost/program_options/option.hpp> // for program_opt...
21 #include <boost/program_options/options_description.hpp> // for options_des...
22 #include <boost/program_options/parsers.hpp> // for basic_comma...
23 #include <boost/program_options/variables_map.hpp> // for variables_map
24 #include <boost/program_options/parsers.hpp> // for basic_comma...
26 #include "admin_socket_output.h"
27 #include "admin_socket_output_tests.h"
29 namespace po
= boost::program_options
;
31 void usage(po::options_description desc
) {
32 std::cout
<< desc
<< std::endl
;
35 void handle_unrecognised(std::vector
<std::string
>&& unrecognised
) {
36 for (auto& un
: unrecognised
) {
37 std::cout
<< "Unrecognized Parameter: " << un
<< std::endl
;
42 // See admin_socket_output_tests.h
44 int main(int argc
, char** argv
) {
46 po::options_description
desc("Allowed options");
48 ("help,h", "produce help message")
56 ("osd", "Test osd admin socket output")
57 ("mon", "Test mon admin socket output")
58 ("mgr", "Test mgr admin socket output")
59 ("mds", "Test mds admin socket output")
60 ("client", "Test client (includes rgw) admin socket output")
61 ("vstart", po::value
<std::string
>()->implicit_value("./out"),
62 "Modify to run in vstart environment")
65 po::command_line_parser(argc
, argv
).options(desc
).allow_unregistered().run();
67 po::store(parsed
, vm
);
70 auto unrecognised
= collect_unrecognized(parsed
.options
, po::include_positional
);
71 if(!unrecognised
.empty()) {
72 handle_unrecognised(std::move(unrecognised
));
76 if (vm
.count("help") || vm
.empty()) {
81 std::unique_ptr
<AdminSocketOutput
> asockout(new AdminSocketOutput
);
83 if (vm
.count("vstart")) {
84 asockout
->mod_for_vstart(vm
["vstart"].as
<std::string
>());
88 asockout
->add_target("all");
90 if (vm
.count("osd")) {
91 asockout
->add_target("osd");
93 if (vm
.count("mon")) {
94 asockout
->add_target("mon");
96 if (vm
.count("mgr")) {
97 asockout
->add_target("mgr");
99 if (vm
.count("mds")) {
100 asockout
->add_target("mds");
102 if (vm
.count("client")) {
103 asockout
->add_target("client");
107 // Postpone commands that may affect later commands
109 asockout
->postpone("mds", "force_readonly");
114 //asockout->add_command("osd", R"({"prefix":"config get", "var":"admin_socket"})");
116 // End custom commands
120 //asockout->add_test("osd", R"({"prefix":"config get", "var":"admin_socket"})", test_config_get_admin_socket);
122 asockout
->add_test("osd", R
"({"prefix
":"dump_pgstate_history
"})", test_dump_pgstate_history
);