mirror of
https://github.com/ceph/ceph
synced 2024-12-28 22:43:29 +00:00
mempool: fix lack of pool names in mempool:dump output for JSON formatter.
Signed-off-by: Igor Fedotov <ifed@mail.ru>
This commit is contained in:
parent
c9c58c580d
commit
2aeb7b85c8
@ -42,13 +42,18 @@ const char *mempool::get_pool_name(mempool::pool_index_t ix) {
|
||||
void mempool::dump(ceph::Formatter *f)
|
||||
{
|
||||
stats_t total;
|
||||
f->open_object_section("mempool"); // we need (dummy?) topmost section for
|
||||
// JSON Formatter to print pool names. It omits them otherwise.
|
||||
f->open_object_section("by_pool");
|
||||
for (size_t i = 0; i < num_pools; ++i) {
|
||||
const pool_t &pool = mempool::get_pool((pool_index_t)i);
|
||||
f->open_object_section(get_pool_name((pool_index_t)i));
|
||||
pool.dump(f, &total);
|
||||
f->close_section();
|
||||
}
|
||||
f->close_section();
|
||||
f->dump_object("total", total);
|
||||
f->close_section();
|
||||
}
|
||||
|
||||
void mempool::set_debug_mode(bool d)
|
||||
|
@ -256,6 +256,49 @@ TEST(mempool, list)
|
||||
v.push_back(obj());
|
||||
v.push_back(obj(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(mempool, dump)
|
||||
{
|
||||
ostringstream ostr;
|
||||
|
||||
Formatter* f = Formatter::create("xml-pretty", "xml-pretty", "xml-pretty");
|
||||
mempool::dump(f);
|
||||
f->flush(ostr);
|
||||
|
||||
delete f;
|
||||
ASSERT_NE(ostr.str().find(mempool::get_pool_name((mempool::pool_index_t)0)),
|
||||
std::string::npos);
|
||||
|
||||
ostr.str("");
|
||||
|
||||
f = Formatter::create("html-pretty", "html-pretty", "html-pretty");
|
||||
mempool::dump(f);
|
||||
f->flush(ostr);
|
||||
|
||||
delete f;
|
||||
ASSERT_NE(ostr.str().find(mempool::get_pool_name((mempool::pool_index_t)0)),
|
||||
std::string::npos);
|
||||
|
||||
ostr.str("");
|
||||
f = Formatter::create("table", "table", "table");
|
||||
mempool::dump(f);
|
||||
f->flush(ostr);
|
||||
|
||||
delete f;
|
||||
ASSERT_NE(ostr.str().find(mempool::get_pool_name((mempool::pool_index_t)0)),
|
||||
std::string::npos);
|
||||
|
||||
ostr.str("");
|
||||
|
||||
f = Formatter::create("json-pretty", "json-pretty", "json-pretty");
|
||||
mempool::dump(f);
|
||||
f->flush(ostr);
|
||||
delete f;
|
||||
|
||||
ASSERT_NE(ostr.str().find(mempool::get_pool_name((mempool::pool_index_t)0)),
|
||||
std::string::npos);
|
||||
}
|
||||
|
||||
TEST(mempool, unordered_map)
|
||||
|
Loading…
Reference in New Issue
Block a user