]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/admin_socket_output_tests.cc
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.
18 #include "common/ceph_json.h"
22 // Example test function
24 bool test_config_get_admin_socket(std::string& output) {
25 return std::string::npos != output.find("admin_socket") &&
26 std::string::npos != output.rfind(".asok");
30 bool test_dump_pgstate_history(std::string
&output
) {
32 bool ret
= parser
.parse(output
.c_str(), output
.size());
34 std::cerr
<< "test_dump_pgstate_history: parse error" << std::endl
;
38 JSONObjIter iter
= parser
.find_first();
39 if (iter
.end()) { //Empty
40 std::cerr
<< "test_dump_pgstate_history: command output empty, failing"
44 for (; !iter
.end(); ++iter
) {
45 if ((*iter
)->get_name() == "pg") {
46 ret
= !(*iter
)->get_data().empty();
48 std::cerr
<< "test_dump_pgstate_history: pg value empty, failing"
50 std::cerr
<< "Dumping full output: " << std::endl
;
51 std::cerr
<< output
<< std::endl
;
54 } else if ((*iter
)->get_name() == "history") {
55 ret
= std::string::npos
!= (*iter
)->get_data().find("epoch") &&
56 std::string::npos
!= (*iter
)->get_data().find("state") &&
57 std::string::npos
!= (*iter
)->get_data().find("Initial") &&
58 std::string::npos
!= (*iter
)->get_data().find("enter") &&
59 std::string::npos
!= (*iter
)->get_data().find("exit");
61 std::cerr
<< "test_dump_pgstate_history: Can't find expected values in "
62 "history object, failing"
64 std::cerr
<< "Problem output was:" << std::endl
;
65 std::cerr
<< (*iter
)->get_data() << std::endl
;