Commit 43f53bd0 authored by Francis Dupont's avatar Francis Dupont Committed by Marcin Siodelski

[#1041] Checkpoint: CA updated

parent 300c6809
......@@ -72,6 +72,9 @@ CtrlAgentController::registerCommands() {
CtrlAgentCommandMgr::instance().registerCommand(SHUT_DOWN_COMMAND,
boost::bind(&DControllerBase::shutdownHandler, this, _1, _2));
CtrlAgentCommandMgr::instance().registerCommand(STATUS_GET_COMMAND,
boost::bind(&DControllerBase::statusGetHandler, this, _1, _2));
CtrlAgentCommandMgr::instance().registerCommand(VERSION_GET_COMMAND,
boost::bind(&DControllerBase::versionGetHandler, this, _1, _2));
}
......@@ -85,6 +88,7 @@ CtrlAgentController::deregisterCommands() {
CtrlAgentCommandMgr::instance().deregisterCommand(CONFIG_TEST_COMMAND);
CtrlAgentCommandMgr::instance().deregisterCommand(CONFIG_WRITE_COMMAND);
CtrlAgentCommandMgr::instance().deregisterCommand(SHUT_DOWN_COMMAND);
CtrlAgentCommandMgr::instance().deregisterCommand(STATUS_GET_COMMAND);
CtrlAgentCommandMgr::instance().deregisterCommand(VERSION_GET_COMMAND);
}
......
......@@ -454,6 +454,7 @@ TEST_F(CtrlAgentControllerTest, registeredCommands) {
checkCommandRegistered("config-write");
checkCommandRegistered("list-commands");
checkCommandRegistered("shutdown");
checkCommandRegistered("status-get");
checkCommandRegistered("version-get");
ctrl->deregisterCommands();
......@@ -657,4 +658,26 @@ TEST_F(CtrlAgentControllerTest, configReloadFileValid) {
ctrl->deregisterCommands();
}
// Tests that status-get returns expected info (pid, uptime and reload).
TEST_F(CtrlAgentControllerTest, statusGet) {
// Start the server.
time_duration elapsed_time;
runWithConfig(valid_agent_config, 500, elapsed_time);
const DControllerBasePtr& ctrl = getController();
ConstElementPtr response;
ASSERT_NO_THROW(response = ctrl->statusGetHandler("status-get", ConstElementPtr()));
ASSERT_TRUE(response);
ASSERT_EQ(Element::map, response->getType());
EXPECT_EQ(2, response->size());
ConstElementPtr result = response->get("result");
ASSERT_TRUE(result);
ASSERT_EQ(Element::integer, result->getType());
EXPECT_EQ(0, result->intValue());
ConstElementPtr arguments = response->get("arguments");
ASSERT_EQ(Element::map, arguments->getType());
EXPECT_TRUE(arguments->contains("pid"));
EXPECT_TRUE(arguments->contains("uptime"));
}
}
......@@ -52,6 +52,9 @@ static const std::string SERVER_TAG_GET_COMMAND("server-tag-get");
/// @brief String value for the shutdown command.
static const std::string SHUT_DOWN_COMMAND("shutdown");
/// @brief String value for the status-get command.
static const std::string STATUS_GET_COMMAND("status-get");
/// @brief Returned by the process to indicate a command was successful.
static const int COMMAND_SUCCESS = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment