CommandMgr::instance().registerCommand("statistic-remove-all",
boost::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2));
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-age",
+ boost::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-count",
+ boost::bind(&StatsMgr::statisticSetMaxSampleCountHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-age-all",
+ boost::bind(&StatsMgr::statisticSetMaxSampleAgeAllHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-count-all",
+ boost::bind(&StatsMgr::statisticSetMaxSampleCountAllHandler, _1, _2));
+
+
}
void ControlledDhcpv4Srv::shutdown() {
CommandMgr::instance().deregisterCommand("statistic-remove-all");
CommandMgr::instance().deregisterCommand("statistic-reset");
CommandMgr::instance().deregisterCommand("statistic-reset-all");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-age");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-count");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-age-all");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-count-all");
CommandMgr::instance().deregisterCommand("version-get");
+
} catch (...) {
// Don't want to throw exceptions from the destructor. The server
// is shutting down anyway.
EXPECT_TRUE(command_list.find("\"statistic-remove-all\"") != string::npos);
EXPECT_TRUE(command_list.find("\"statistic-reset\"") != string::npos);
EXPECT_TRUE(command_list.find("\"statistic-reset-all\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-age\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-age-all\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-count\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-count-all\"") != string::npos);
EXPECT_TRUE(command_list.find("\"version-get\"") != string::npos);
// Ok, and now delete the server. It should deregister its commands.
" \"arguments\": {}}", response);
EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics removed.\" }",
response);
+
+ // Check statistic-set-max-sample-age
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-age\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\", \"duration\": 1245 }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-set-max-sample-age-all
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-age-all\", "
+ " \"arguments\": {"
+ " \"duration\": 1245 }}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics duration limit are set.\" }",
+ response);
+
+ // Check statistic-set-max-sample-count
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-count\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\", \"max-samples\": 100 }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-set-max-sample-count-all
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-count-all\", "
+ " \"arguments\": {"
+ " \"max-samples\": 100 }}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics count limit are set.\" }",
+ response);
}
// Check that the "config-set" command will replace current configuration
checkListCommands(rsp, "statistic-remove-all");
checkListCommands(rsp, "statistic-reset");
checkListCommands(rsp, "statistic-reset-all");
+ checkListCommands(rsp, "statistic-set-max-sample-age");
+ checkListCommands(rsp, "statistic-set-max-sample-age-all");
+ checkListCommands(rsp, "statistic-set-max-sample-count");
+ checkListCommands(rsp, "statistic-set-max-sample-count-all");
checkListCommands(rsp, "version-get");
}
CommandMgr::instance().registerCommand("statistic-remove-all",
boost::bind(&StatsMgr::statisticRemoveAllHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-age",
+ boost::bind(&StatsMgr::statisticSetMaxSampleAgeHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-count",
+ boost::bind(&StatsMgr::statisticSetMaxSampleCountHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-age-all",
+ boost::bind(&StatsMgr::statisticSetMaxSampleAgeAllHandler, _1, _2));
+
+ CommandMgr::instance().registerCommand("statistic-set-max-sample-count-all",
+ boost::bind(&StatsMgr::statisticSetMaxSampleCountAllHandler, _1, _2));
}
void ControlledDhcpv6Srv::shutdown() {
CommandMgr::instance().deregisterCommand("statistic-remove-all");
CommandMgr::instance().deregisterCommand("statistic-reset");
CommandMgr::instance().deregisterCommand("statistic-reset-all");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-age");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-count");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-age-all");
+ CommandMgr::instance().deregisterCommand("statistic-set-max-sample-count-all");
CommandMgr::instance().deregisterCommand("version-get");
} catch (...) {
EXPECT_TRUE(command_list.find("\"statistic-remove-all\"") != string::npos);
EXPECT_TRUE(command_list.find("\"statistic-reset\"") != string::npos);
EXPECT_TRUE(command_list.find("\"statistic-reset-all\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-age\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-age-all\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-count\"") != string::npos);
+ EXPECT_TRUE(command_list.find("\"statistic-set-max-sample-count-all\"") != string::npos);
EXPECT_TRUE(command_list.find("\"version-get\"") != string::npos);
// Ok, and now delete the server. It should deregister its commands.
" \"arguments\": {}}", response);
EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics removed.\" }",
response);
+
+ // Check statistic-set-max-sample-age
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-age\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\", \"duration\": 1245 }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-set-max-sample-age-all
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-age-all\", "
+ " \"arguments\": {"
+ " \"duration\": 1245 }}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics duration limit are set.\" }",
+ response);
+
+ // Check statistic-set-max-sample-count
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-count\", "
+ " \"arguments\": {"
+ " \"name\":\"bogus\", \"max-samples\": 100 }}", response);
+ EXPECT_EQ("{ \"result\": 1, \"text\": \"No 'bogus' statistic found\" }",
+ response);
+
+ // Check statistic-set-max-sample-count-all
+ sendUnixCommand("{ \"command\" : \"statistic-set-max-sample-count-all\", "
+ " \"arguments\": {"
+ " \"max-samples\": 100 }}", response);
+ EXPECT_EQ("{ \"result\": 0, \"text\": \"All statistics count limit are set.\" }",
+ response);
}
// Tests that the server properly responds to shtudown command sent
checkListCommands(rsp, "statistic-remove-all");
checkListCommands(rsp, "statistic-reset");
checkListCommands(rsp, "statistic-reset-all");
+ checkListCommands(rsp, "statistic-set-max-sample-age");
+ checkListCommands(rsp, "statistic-set-max-sample-age-all");
+ checkListCommands(rsp, "statistic-set-max-sample-count");
+ checkListCommands(rsp, "statistic-set-max-sample-count-all");
}
// Tests if the server returns its configuration using config-get.