Skip to content

Commit

Permalink
Merge pull request #8948 from cooboos/perf-reset
Browse files Browse the repository at this point in the history
test: add perf-reset test in test/perf_counters.cc

Reviewed-by: Haomai Wang <haomai@xsky.com>
  • Loading branch information
yuyuyu101 committed Nov 22, 2016
2 parents 013d4b2 + 15a345b commit 69c2996
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/perf_counters.cc
Expand Up @@ -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);
}

0 comments on commit 69c2996

Please sign in to comment.