]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add perf-reset test in test/perf_counters.cc 8948/head
authorwangsongbo <wangsongbo@unitedstack.com>
Thu, 5 May 2016 16:05:35 +0000 (00:05 +0800)
committerwangsongbo <wangsongbo@unitedstack.com>
Thu, 5 May 2016 16:05:35 +0000 (00:05 +0800)
Signed-off-by: wangsongbo <wangsongbo@unitedstack.com>
src/test/perf_counters.cc

index a916cf08da3b39e5203951e6c92560958aed843b..5b74c35132cf1a6bcd540178051335ca4cdc0c01 100644 (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);
+}