X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Ftest_admin_socket_output.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Ftest_admin_socket_output.cc;h=7e1b35d0aacc2b9b993eb16dfbf94358d3ae7b59;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/test/test_admin_socket_output.cc b/src/ceph/src/test/test_admin_socket_output.cc new file mode 100644 index 0000000..7e1b35d --- /dev/null +++ b/src/ceph/src/test/test_admin_socket_output.cc @@ -0,0 +1,128 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2017 Red Hat + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include // for move +#include // for ostream +#include // for unique_ptr +#include // for operator<< +#include // for vector +#include // for program_opt... +#include // for options_des... +#include // for basic_comma... +#include // for variables_map +#include // for basic_comma... + +#include "admin_socket_output.h" +#include "admin_socket_output_tests.h" + +namespace po = boost::program_options; + +void usage(po::options_description desc) { + std::cout << desc << std::endl; +} + +void handle_unrecognised(std::vector&& unrecognised) { + for (auto& un : unrecognised) { + std::cout << "Unrecognized Parameter: " << un << std::endl; + } +} + +// Test functions: +// See admin_socket_output_tests.h + +int main(int argc, char** argv) { + + po::options_description desc("Allowed options"); + desc.add_options() + ("help,h", "produce help message") + ("all", "implies" + " --osd" + " --mon" + " --mgr" + " --mds" + " --client" + " --vstart") + ("osd", "Test osd admin socket output") + ("mon", "Test mon admin socket output") + ("mgr", "Test mgr admin socket output") + ("mds", "Test mds admin socket output") + ("client", "Test client (includes rgw) admin socket output") + ("vstart", "Modify to run in vstart environment") + ; + auto parsed = + po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); + po::variables_map vm; + po::store(parsed, vm); + po::notify(vm); + + auto unrecognised = collect_unrecognized(parsed.options, po::include_positional); + if(!unrecognised.empty()) { + handle_unrecognised(std::move(unrecognised)); + usage(desc); + return 1; + } + if (vm.count("help") || vm.empty()) { + usage(desc); + return 2; + } + + std::unique_ptr asockout(new AdminSocketOutput); + + if (vm.count("vstart")) { + asockout->mod_for_vstart(); + } + + if(vm.count("all")) { + asockout->add_target("all"); + } else { + if (vm.count("osd")) { + asockout->add_target("osd"); + } + if (vm.count("mon")) { + asockout->add_target("mon"); + } + if (vm.count("mgr")) { + asockout->add_target("mgr"); + } + if (vm.count("mds")) { + asockout->add_target("mds"); + } + if (vm.count("client")) { + asockout->add_target("client"); + } + } + + // Postpone commands that may affect later commands + + asockout->postpone("mds", "force_readonly"); + + // Custom commands + + //Example: + //asockout->add_command("osd", R"({"prefix":"config get", "var":"admin_socket"})"); + + // End custom commands + + // Tests + //Example: + //asockout->add_test("osd", R"({"prefix":"config get", "var":"admin_socket"})", test_config_get_admin_socket); + + asockout->add_test("osd", R"({"prefix":"dump_pgstate_history"})", test_dump_pgstate_history); + + // End tests + + asockout->exec(); + + return 0; +}