]>
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 for (; !iter
.end(); ++iter
) {
40 if ((*iter
)->get_name() == "pg") {
41 ret
= !(*iter
)->get_data().empty();
43 std::cerr
<< "test_dump_pgstate_history: pg value empty, failing"
45 std::cerr
<< "Dumping full output: " << std::endl
;
46 std::cerr
<< output
<< std::endl
;
49 } else if ((*iter
)->get_name() == "history") {
50 ret
= std::string::npos
!= (*iter
)->get_data().find("epoch") &&
51 std::string::npos
!= (*iter
)->get_data().find("state") &&
52 std::string::npos
!= (*iter
)->get_data().find("Initial") &&
53 std::string::npos
!= (*iter
)->get_data().find("enter") &&
54 std::string::npos
!= (*iter
)->get_data().find("exit");
56 std::cerr
<< "test_dump_pgstate_history: Can't find expected values in "
57 "history object, failing"
59 std::cerr
<< "Problem output was:" << std::endl
;
60 std::cerr
<< (*iter
)->get_data() << std::endl
;