summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2019-12-12 15:52:27 +0100
committerMarcin Siodelski <marcin@isc.org>2019-12-13 17:01:00 +0100
commit43f53bd04e52c5349d10a1d5fd1c5c66f36f5722 (patch)
treeda08fc014074fb43b60e0965753370d184114004 /src
parent[#1041] Checkpoint: moved uptime/reload to libprocess (diff)
downloadkea-43f53bd04e52c5349d10a1d5fd1c5c66f36f5722.tar.xz
kea-43f53bd04e52c5349d10a1d5fd1c5c66f36f5722.zip
[#1041] Checkpoint: CA updated
Diffstat (limited to 'src')
-rw-r--r--src/bin/agent/ca_controller.cc4
-rw-r--r--src/bin/agent/tests/ca_controller_unittests.cc23
-rw-r--r--src/lib/process/d_process.h3
3 files changed, 30 insertions, 0 deletions
diff --git a/src/bin/agent/ca_controller.cc b/src/bin/agent/ca_controller.cc
index 38d5733e97..134bde5659 100644
--- a/src/bin/agent/ca_controller.cc
+++ b/src/bin/agent/ca_controller.cc
@@ -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);
}
diff --git a/src/bin/agent/tests/ca_controller_unittests.cc b/src/bin/agent/tests/ca_controller_unittests.cc
index b7223eff5e..6fe750b848 100644
--- a/src/bin/agent/tests/ca_controller_unittests.cc
+++ b/src/bin/agent/tests/ca_controller_unittests.cc
@@ -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"));
+}
+
}
diff --git a/src/lib/process/d_process.h b/src/lib/process/d_process.h
index 0b637f0539..e0e429d343 100644
--- a/src/lib/process/d_process.h
+++ b/src/lib/process/d_process.h
@@ -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;