]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/admin_socket_output.h
import ceph quincy 17.2.6
[ceph.git] / ceph / src / test / admin_socket_output.h
CommitLineData
31f18b77
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3/*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2017 Red Hat
7 *
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.
12 *
13 */
14
15#ifndef CEPH_ADMIN_SOCKET_OUTPUT_H
16#define CEPH_ADMIN_SOCKET_OUTPUT_H
17
20effc67 18#include <filesystem>
31f18b77
FG
19#include <string>
20#include <map>
21#include <set>
22#include <vector>
20effc67 23
f67539c2 24namespace fs = std::filesystem;
31f18b77
FG
25
26using socket_results = std::map<std::string, std::string>;
27using test_functions =
28 std::vector<std::pair<std::string, bool (*)(std::string &)>>;
29
30class AdminSocketClient;
31
32class AdminSocketOutput {
33public:
34 AdminSocketOutput() {}
35
36 void add_target(const std::string &target);
37 void add_command(const std::string &target, const std::string &command);
38 void add_test(const std::string &target, const std::string &command,
39 bool (*test)(std::string &));
40 void postpone(const std::string &target, const std::string &command);
41
42 void exec();
43
11fdf7f2
TL
44 void mod_for_vstart(const std::string& dir) {
45 socketdir = dir;
31f18b77
FG
46 prefix = "";
47 }
48
49private:
50 bool init_directories() const {
51 std::cout << "Checking " << socketdir << std::endl;
52 return exists(socketdir) && is_directory(socketdir);
53 }
54
55 bool init_sockets();
56 bool gather_socket_output();
11fdf7f2 57 std::string get_result(const std::string &target, const std::string &command) const;
31f18b77
FG
58
59 std::pair<std::string, std::string>
11fdf7f2 60 run_command(AdminSocketClient &client, const std::string &raw_command,
31f18b77
FG
61 bool send_untouched = false);
62
63 bool run_tests() const;
64
65 std::set<std::string> targets;
66 std::map<std::string, std::string> sockets;
67 std::map<std::string, socket_results> results;
68 std::map<std::string, std::vector<std::string>> custom_commands;
69 std::map<std::string, std::vector<std::string>> postponed_commands;
70 std::map<std::string, test_functions> tests;
71
72 std::string prefix = "ceph-";
11fdf7f2 73 fs::path socketdir = "/var/run/ceph";
31f18b77
FG
74};
75
76#endif // CEPH_ADMIN_SOCKET_OUTPUT_H