Skip to content

Commit 27aaeb0

Browse files
author
Razvan Becheriu
committed
[#3223] fixed status-get when no lease manager is available
1 parent 4500ae9 commit 27aaeb0

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <dhcp/libdhcp++.h>
1616
#include <dhcp/testutils/iface_mgr_test_config.h>
1717
#include <dhcpsrv/cfgmgr.h>
18+
#include <dhcpsrv/host_mgr.h>
1819
#include <dhcpsrv/lease.h>
1920
#include <dhcpsrv/lease_mgr_factory.h>
2021
#include <dhcp4/ctrl_dhcp4_srv.h>
@@ -1269,6 +1270,27 @@ TEST_F(CtrlChannelDhcpv4SrvTest, statusGet) {
12691270
EXPECT_EQ(3, found_queue_stats->size());
12701271
}
12711272

1273+
// Check that status is returned even if LeaseMgr and HostMgr are not created.
1274+
TEST_F(CtrlChannelDhcpv4SrvTest, noManagers) {
1275+
// Send the status-get command.
1276+
createUnixChannelServer();
1277+
LeaseMgrFactory::destroy();
1278+
HostMgr::create();
1279+
string response_text;
1280+
sendUnixCommand(R"({ "command": "status-get" })", response_text);
1281+
ConstElementPtr response;
1282+
ASSERT_NO_THROW(response = Element::fromJSON(response_text));
1283+
ASSERT_TRUE(response);
1284+
ASSERT_EQ(Element::map, response->getType());
1285+
ConstElementPtr result(response->get("result"));
1286+
ASSERT_TRUE(result);
1287+
ASSERT_EQ(Element::integer, result->getType());
1288+
EXPECT_EQ(0, result->intValue());
1289+
ConstElementPtr arguments(response->get("arguments"));
1290+
ASSERT_TRUE(arguments);
1291+
ASSERT_EQ(Element::map, arguments->getType());
1292+
}
1293+
12721294
// Checks that socket status exists in status-get responses.
12731295
TEST_F(CtrlChannelDhcpv4SrvTest, statusGetSockets) {
12741296
// Create dummy interfaces to test socket status.

src/bin/dhcp6/ctrl_dhcp6_srv.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ ControlledDhcpv6Srv::commandStatusGetHandler(const string&,
820820
status->set("multi-threading-enabled", Element::create(false));
821821
}
822822

823-
status->set("extended-info-tables",
824-
Element::create(LeaseMgrFactory::instance().getExtendedInfoTablesEnabled()));
823+
status->set("extended-info-tables", Element::create(
824+
CfgMgr::instance().getCurrentCfg()->getCfgDbAccess()->getExtendedInfoTablesEnabled()));
825825

826826
// Iterate through the interfaces and get all the errors.
827827
ElementPtr socket_errors(Element::createList());

src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <dhcp/libdhcp++.h>
1414
#include <dhcp/testutils/iface_mgr_test_config.h>
1515
#include <dhcpsrv/cfgmgr.h>
16+
#include <dhcpsrv/host_mgr.h>
1617
#include <dhcpsrv/lease.h>
1718
#include <dhcpsrv/lease_mgr_factory.h>
1819
#include <dhcp6/ctrl_dhcp6_srv.h>
@@ -1171,6 +1172,27 @@ TEST_F(CtrlChannelDhcpv6SrvTest, statusGet) {
11711172
EXPECT_EQ(3, found_queue_stats->size());
11721173
}
11731174

1175+
// Check that status is returned even if LeaseMgr and HostMgr are not created.
1176+
TEST_F(CtrlChannelDhcpv6SrvTest, noManagers) {
1177+
// Send the status-get command.
1178+
createUnixChannelServer();
1179+
LeaseMgrFactory::destroy();
1180+
HostMgr::create();
1181+
string response_text;
1182+
sendUnixCommand(R"({ "command": "status-get" })", response_text);
1183+
ConstElementPtr response;
1184+
ASSERT_NO_THROW(response = Element::fromJSON(response_text));
1185+
ASSERT_TRUE(response);
1186+
ASSERT_EQ(Element::map, response->getType());
1187+
ConstElementPtr result(response->get("result"));
1188+
ASSERT_TRUE(result);
1189+
ASSERT_EQ(Element::integer, result->getType());
1190+
EXPECT_EQ(0, result->intValue());
1191+
ConstElementPtr arguments(response->get("arguments"));
1192+
ASSERT_TRUE(arguments);
1193+
ASSERT_EQ(Element::map, arguments->getType());
1194+
}
1195+
11741196
// Checks that socket status exists in status-get responses.
11751197
TEST_F(CtrlChannelDhcpv6SrvTest, statusGetSockets) {
11761198
// Create dummy interfaces to test socket status.

src/lib/dhcpsrv/lease_mgr_factory.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
5252
"contain the 'type' keyword");
5353
}
5454

55-
5655
// Yes, check what it is.
5756
if (parameters[type] == string("mysql")) {
5857
#ifdef HAVE_MYSQL

0 commit comments

Comments
 (0)