Commit f016c3cd authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[3399] Prototype for a test that loads example config files.

parent 2b204662
......@@ -122,4 +122,6 @@ dhcp4_unittests_LDADD += $(top_builddir)/src/lib/hooks/
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/
noinst_DATA = configs-list.txt
noinst_PROGRAMS = $(TESTS)
# This is a list of config files that the unit-tests (specifically
# JSONFileBackendTest.loadAllConfigs) is going to load.
......@@ -234,4 +234,51 @@ TEST_F(JSONFileBackendTest, configBroken) {
EXPECT_THROW(srv->init(TEST_FILE), BadValue);
// This unit-test reads all files enumerated in configs-test.txt file, loads
// each of them and verify that they can be loaded.
// @todo: Unfortunately, we have this test disabled, because all loaded
// configs use memfile, which attempts to create lease file in
// /usr/local/var/bind10/kea-leases4.csv. We have couple options here:
// a) disable persistence in example configs - a very bad thing to do
// as users will forget to reenable it and then will be surprised when their
// leases disappear
// b) change configs to store lease file in /tmp. It's almost as bad as the
// previous one. Users will then be displeased when all their leases are
// wiped. (most systems wipe /tmp during boot)
// c) read each config and rewrite it on the fly, so persistence is disabled.
// This is probably the way to go, but this is a work for a dedicated ticket.
// Hence I'm leaving the test in, but it is disabled.
TEST_F(JSONFileBackendTest, DISABLED_loadAllConfigs) {
// Create server first
boost::scoped_ptr<ControlledDhcpv4Srv> srv;
srv.reset(new ControlledDhcpv4Srv(0))
const char* configs_list = "configs-list.txt";
fstream configs(configs_list, ios::in);
std::string config_name;
while (std::getline(configs, config_name)) {
// Ignore empty and commented lines
if (config_name.empty() || config_name[0] == '#') {
// Unit-tests usually do not print out anything, but in this case I
// think printing out tests configs is warranted.
std::cout << "Loading config file " << config_name << std::endl;
try {
} catch (const std::exception& ex) {
ADD_FAILURE() << "Exception thrown" << ex.what() << endl;
} // End of anonymous namespace
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