#include <dhcpsrv/option_space_container.h>
#include <dhcpsrv/parsers/dbaccess_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
+#include <dhcpsrv/parsers/expiration_config_parser.h>
#include <dhcpsrv/parsers/host_reservation_parser.h>
#include <dhcpsrv/parsers/host_reservations_list_parser.h>
#include <dhcpsrv/parsers/ifaces_config_parser.h>
parser = new BooleanParser(config_id, globalContext()->boolean_values_);
} else if (config_id.compare("control-socket") == 0) {
parser = new ControlSocketParser(config_id);
+ } else if (config_id.compare("expired-leases-processing") == 0) {
+ parser = new ExpirationConfigParser();
} else {
isc_throw(DhcpConfigError,
"unsupported global configuration parameter: "
#include <dhcp/tests/iface_mgr_test_config.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/cfgmgr.h>
+#include <dhcpsrv/cfg_expiration.h>
#include <dhcpsrv/cfg_hosts.h>
#include <dhcpsrv/cfg_subnets4.h>
#include <dhcpsrv/testutils/config_result_check.h>
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
+// Check that configuration for the expired leases processing may be
+// specified.
+TEST_F(Dhcp4ParserTest, expiredLeasesProcessing) {
+ // Create basic configuration with the expiration specific parameters.
+ string config = "{ " + genIfaceConfig() + "," +
+ "\"expired-leases-processing\": "
+ "{"
+ " \"reclaim-timer-wait-time\": 20,"
+ " \"flush-reclaimed-timer-wait-time\": 35,"
+ " \"hold-reclaimed-time\": 1800,"
+ " \"max-reclaim-leases\": 50,"
+ " \"max-reclaim-time\": 100,"
+ " \"unwarned-reclaim-cycles\": 10"
+ "},"
+ "\"subnet4\": [ ]"
+ "}";
+
+ ElementPtr json = Element::fromJSON(config);
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
+
+ // Returned value should be 0 (success)
+ checkResult(status, 0);
+
+ // The value of decline-probation-perion must be equal to the
+ // value specified.
+ CfgExpirationPtr cfg = CfgMgr::instance().getStagingCfg()->getCfgExpiration();
+ ASSERT_TRUE(cfg);
+
+ // Verify that parameters are correct.
+ EXPECT_EQ(20, cfg->getReclaimTimerWaitTime());
+ EXPECT_EQ(35, cfg->getFlushReclaimedTimerWaitTime());
+ EXPECT_EQ(1800, cfg->getHoldReclaimedTime());
+ EXPECT_EQ(50, cfg->getMaxReclaimLeases());
+ EXPECT_EQ(100, cfg->getMaxReclaimTime());
+ EXPECT_EQ(10, cfg->getUnwarnedReclaimCycles());
+}
+
+// Check that invalid configuration for the expired leases processing is
+// causing an error.
+TEST_F(Dhcp4ParserTest, expiredLeasesProcessingError) {
+ // Create basic configuration with the expiration specific parameters.
+ // One of the parameters holds invalid value.
+ string config = "{ " + genIfaceConfig() + "," +
+ "\"expired-leases-processing\": "
+ "{"
+ " \"reclaim-timer-wait-time\": -5,"
+ " \"flush-reclaimed-timer-wait-time\": 35,"
+ " \"hold-reclaimed-time\": 1800,"
+ " \"max-reclaim-leases\": 50,"
+ " \"max-reclaim-time\": 100,"
+ " \"unwarned-reclaim-cycles\": 10"
+ "},"
+ "\"subnet4\": [ ]"
+ "}";
+
+ ElementPtr json = Element::fromJSON(config);
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp4Server(*srv_, json));
+
+ // Returned value should be 0 (error)
+ checkResult(status, 1);
+
+ // Check that the error contains error position.
+ EXPECT_TRUE(errorContainsPosition(status, "<string>"));
+}
+
}
#include <dhcpsrv/parsers/dbaccess_parser.h>
#include <dhcpsrv/parsers/dhcp_config_parser.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
+#include <dhcpsrv/parsers/expiration_config_parser.h>
#include <dhcpsrv/parsers/host_reservation_parser.h>
#include <dhcpsrv/parsers/host_reservations_list_parser.h>
#include <dhcpsrv/parsers/ifaces_config_parser.h>
parser = new RSOOListConfigParser(config_id);
} else if (config_id.compare("control-socket") == 0) {
parser = new ControlSocketParser(config_id);
+ } else if (config_id.compare("expired-leases-processing") == 0) {
+ parser = new ExpirationConfigParser();
} else {
isc_throw(DhcpConfigError,
"unsupported global configuration parameter: "
#include <dhcp6/dhcp6_srv.h>
#include <dhcpsrv/addr_utilities.h>
#include <dhcpsrv/cfgmgr.h>
+#include <dhcpsrv/cfg_expiration.h>
#include <dhcpsrv/cfg_hosts.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/subnet_selector.h>
EXPECT_TRUE(errorContainsPosition(status, "<string>"));
}
+// Check that configuration for the expired leases processing may be
+// specified.
+TEST_F(Dhcp6ParserTest, expiredLeasesProcessing) {
+ // Create basic configuration with the expiration specific parameters.
+ string config = "{ " + genIfaceConfig() + "," +
+ "\"expired-leases-processing\": "
+ "{"
+ " \"reclaim-timer-wait-time\": 20,"
+ " \"flush-reclaimed-timer-wait-time\": 35,"
+ " \"hold-reclaimed-time\": 1800,"
+ " \"max-reclaim-leases\": 50,"
+ " \"max-reclaim-time\": 100,"
+ " \"unwarned-reclaim-cycles\": 10"
+ "},"
+ "\"subnet6\": [ ]"
+ "}";
+
+ ElementPtr json = Element::fromJSON(config);
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+
+ // Returned value should be 0 (success)
+ checkResult(status, 0);
+
+ // The value of decline-probation-perion must be equal to the
+ // value specified.
+ CfgExpirationPtr cfg = CfgMgr::instance().getStagingCfg()->getCfgExpiration();
+ ASSERT_TRUE(cfg);
+
+ // Verify that parameters are correct.
+ EXPECT_EQ(20, cfg->getReclaimTimerWaitTime());
+ EXPECT_EQ(35, cfg->getFlushReclaimedTimerWaitTime());
+ EXPECT_EQ(1800, cfg->getHoldReclaimedTime());
+ EXPECT_EQ(50, cfg->getMaxReclaimLeases());
+ EXPECT_EQ(100, cfg->getMaxReclaimTime());
+ EXPECT_EQ(10, cfg->getUnwarnedReclaimCycles());
+}
+
+// Check that invalid configuration for the expired leases processing is
+// causing an error.
+TEST_F(Dhcp6ParserTest, expiredLeasesProcessingError) {
+ // Create basic configuration with the expiration specific parameters.
+ // One of the parameters holds invalid value.
+ string config = "{ " + genIfaceConfig() + "," +
+ "\"expired-leases-processing\": "
+ "{"
+ " \"reclaim-timer-wait-time\": -5,"
+ " \"flush-reclaimed-timer-wait-time\": 35,"
+ " \"hold-reclaimed-time\": 1800,"
+ " \"max-reclaim-leases\": 50,"
+ " \"max-reclaim-time\": 100,"
+ " \"unwarned-reclaim-cycles\": 10"
+ "},"
+ "\"subnet6\": [ ]"
+ "}";
+
+ ElementPtr json = Element::fromJSON(config);
+
+ ConstElementPtr status;
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
+
+ // Returned value should be 0 (error)
+ checkResult(status, 1);
+
+ // Check that the error contains error position.
+ EXPECT_TRUE(errorContainsPosition(status, "<string>"));
+}
+
};