]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/admin_socket_output.h
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 #ifndef CEPH_ADMIN_SOCKET_OUTPUT_H
16 #define CEPH_ADMIN_SOCKET_OUTPUT_H
24 namespace fs
= std::filesystem
;
26 using socket_results
= std::map
<std::string
, std::string
>;
27 using test_functions
=
28 std::vector
<std::pair
<std::string
, bool (*)(std::string
&)>>;
30 class AdminSocketClient
;
32 class AdminSocketOutput
{
34 AdminSocketOutput() {}
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
);
44 void mod_for_vstart(const std::string
& dir
) {
50 bool init_directories() const {
51 std::cout
<< "Checking " << socketdir
<< std::endl
;
52 return exists(socketdir
) && is_directory(socketdir
);
56 bool gather_socket_output();
57 std::string
get_result(const std::string
&target
, const std::string
&command
) const;
59 std::pair
<std::string
, std::string
>
60 run_command(AdminSocketClient
&client
, const std::string
&raw_command
,
61 bool send_untouched
= false);
63 bool run_tests() const;
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
;
72 std::string prefix
= "ceph-";
73 fs::path socketdir
= "/var/run/ceph";
76 #endif // CEPH_ADMIN_SOCKET_OUTPUT_H