From c83760ce68365d1eb243c68ecdb789e12e39bd89 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Fri, 21 Jan 2022 20:46:42 +0200 Subject: [PATCH] [#2279] fixed unittests --- src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc | 11 +++++++++++ src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc | 11 +++++++++++ src/lib/dhcpsrv/srv_config.cc | 3 +-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 84ef848acf..eefe39dea1 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -184,6 +184,17 @@ public: ConstElementPtr config; ASSERT_NO_THROW(config = parseDHCP4(config_txt)); + + // Parse the logger configuration explicitly into the staging config. + // Note this does not alter the current loggers, they remain in + // effect until we apply the logging config below. If no logging + // is supplied logging will revert to default logging. + server_->configureLogger(config, CfgMgr::instance().getStagingCfg()); + + // Let's apply the new logging. We do it early, so we'll be able to print + // out what exactly is wrong with the new config in case of problems. + CfgMgr::instance().getStagingCfg()->applyLoggingCfg(); + ConstElementPtr answer = server_->processConfig(config); // Commit the configuration so any subsequent reconfigurations diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index 9352387b04..67fb8cc4a2 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -211,6 +211,17 @@ public: ConstElementPtr config; ASSERT_NO_THROW(config = parseDHCP6(config_txt)); + + // Parse the logger configuration explicitly into the staging config. + // Note this does not alter the current loggers, they remain in + // effect until we apply the logging config below. If no logging + // is supplied logging will revert to default logging. + server_->configureLogger(config, CfgMgr::instance().getStagingCfg()); + + // Let's apply the new logging. We do it early, so we'll be able to print + // out what exactly is wrong with the new config in case of problems. + CfgMgr::instance().getStagingCfg()->applyLoggingCfg(); + ConstElementPtr answer = server_->processConfig(config); // Commit the configuration so any subsequent reconfigurations diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc index 0e233581c8..ca496e6869 100644 --- a/src/lib/dhcpsrv/srv_config.cc +++ b/src/lib/dhcpsrv/srv_config.cc @@ -132,8 +132,7 @@ SrvConfig::copy(SrvConfig& new_config) const { // Replace configured hooks libraries. new_config.hooks_config_.clear(); using namespace isc::hooks; - for (HookLibsCollection::const_iterator it = - hooks_config_.get().begin(); + for (HookLibsCollection::const_iterator it = hooks_config_.get().begin(); it != hooks_config_.get().end(); ++it) { new_config.hooks_config_.add(it->first, it->second); }