Commit b3242fb7 authored by Francis Dupont's avatar Francis Dupont Committed by Marcin Siodelski

[#1041] Updated d2 (netconf has no control channel)

parent 43f53bd0
......@@ -73,6 +73,9 @@ D2Controller::registerCommands() {
CommandMgr::instance().registerCommand(SHUT_DOWN_COMMAND,
boost::bind(&D2Controller::shutdownHandler, this, _1, _2));
CommandMgr::instance().registerCommand(STATUS_GET_COMMAND,
boost::bind(&DControllerBase::statusGetHandler, this, _1, _2));
CommandMgr::instance().registerCommand(VERSION_GET_COMMAND,
boost::bind(&D2Controller::versionGetHandler, this, _1, _2));
}
......@@ -91,6 +94,7 @@ D2Controller::deregisterCommands() {
CommandMgr::instance().deregisterCommand(CONFIG_TEST_COMMAND);
CommandMgr::instance().deregisterCommand(CONFIG_WRITE_COMMAND);
CommandMgr::instance().deregisterCommand(SHUT_DOWN_COMMAND);
CommandMgr::instance().deregisterCommand(STATUS_GET_COMMAND);
CommandMgr::instance().deregisterCommand(VERSION_GET_COMMAND);
} catch (...) {
......
......@@ -537,6 +537,7 @@ TEST_F(CtrlChannelD2Test, commandsRegistration) {
EXPECT_TRUE(command_list.find("\"config-test\"") != string::npos);
EXPECT_TRUE(command_list.find("\"config-write\"") != string::npos);
EXPECT_TRUE(command_list.find("\"shutdown\"") != string::npos);
EXPECT_TRUE(command_list.find("\"status-get\"") != string::npos);
EXPECT_TRUE(command_list.find("\"version-get\"") != string::npos);
// Ok, and now delete the server. It should deregister its commands.
......@@ -612,6 +613,30 @@ TEST_F(CtrlChannelD2Test, listCommands) {
checkListCommands(rsp, "version-get");
}
// This test verifies that the D2 server handles status-get commands
TEST_F(CtrlChannelD2Test, statusGet) {
EXPECT_NO_THROW(createUnixChannelServer());
std::string response_txt;
// Send the version-get command
sendUnixCommand("{ \"command\": \"status-get\" }", response_txt);
ConstElementPtr response;
ASSERT_NO_THROW(response = Element::fromJSON(response_txt));
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"));
// launch is not called so we have only reload, not uptime.
EXPECT_TRUE(arguments->contains("reload"));
}
// Tests if the server returns its configuration using config-get.
// Note there are separate tests that verify if toElement() called by the
// config-get handler are actually converting the configuration correctly.
......
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