Merge pull request #8948 from cooboos/perf-reset

test: add perf-reset test in test/perf_counters.cc

Reviewed-by: Haomai Wang <haomai@xsky.com>
This commit is contained in:
Haomai Wang 2016-11-22 14:31:08 +08:00 committed by GitHub
commit 69c29960a2

View File

@ -200,3 +200,22 @@ TEST(PerfCounters, CephContextPerfCounters) {
// Restore to avoid impact to other test cases
g_ceph_context->disable_perf_counter();
}
TEST(PerfCounters, ResetPerfCounters) {
AdminSocketClient client(get_rand_socket_path());
std::string msg;
PerfCountersCollection *coll = g_ceph_context->get_perfcounters_collection();
coll->clear();
PerfCounters* fake_pf1 = setup_test_perfcounters1(g_ceph_context);
coll->add(fake_pf1);
ASSERT_EQ("", client.do_request("{ \"prefix\": \"perf reset\", \"var\": \"all\", \"format\": \"json\" }", &msg));
ASSERT_EQ(sd("{\"success\":\"perf reset all\"}"), msg);
ASSERT_EQ("", client.do_request("{ \"prefix\": \"perf reset\", \"var\": \"test_perfcounter_1\", \"format\": \"json\" }", &msg));
ASSERT_EQ(sd("{\"success\":\"perf reset test_perfcounter_1\"}"), msg);
coll->clear();
ASSERT_EQ("", client.do_request("{ \"prefix\": \"perf reset\", \"var\": \"test_perfcounter_1\", \"format\": \"json\" }", &msg));
ASSERT_EQ(sd("{\"error\":\"Not find: test_perfcounter_1\"}"), msg);
}