]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/admin_socket_output_tests.cc
bump version to 12.2.4-pve1
[ceph.git] / 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
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 #include <string>
16 #include <iostream>
17
18 #include "common/ceph_json.h"
19
20 // Test functions
21
22 // Example test function
23 /*
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");
27 }
28 */
29
30 bool test_dump_pgstate_history(std::string &output) {
31 JSONParser parser;
32 bool ret = parser.parse(output.c_str(), output.size());
33 if (!ret) {
34 std::cerr << "test_dump_pgstate_history: parse error" << std::endl;
35 return false;
36 }
37
38 JSONObjIter iter = parser.find_first();
39 for (; !iter.end(); ++iter) {
40 if ((*iter)->get_name() == "pg") {
41 ret = !(*iter)->get_data().empty();
42 if (ret == false) {
43 std::cerr << "test_dump_pgstate_history: pg value empty, failing"
44 << std::endl;
45 std::cerr << "Dumping full output: " << std::endl;
46 std::cerr << output << std::endl;
47 break;
48 }
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");
55 if (ret == false) {
56 std::cerr << "test_dump_pgstate_history: Can't find expected values in "
57 "history object, failing"
58 << std::endl;
59 std::cerr << "Problem output was:" << std::endl;
60 std::cerr << (*iter)->get_data() << std::endl;
61 break;
62 }
63 }
64 }
65 return ret;
66 }