tmp << "lease backends:" << endl;
tmp << LeaseMgrFactory::getDBVersions() << endl;
tmp << "host backends:" << endl;
- tmp << HostDataSourceFactory::getDBVersions() << endl;
+ tmp << HostDataSourceFactory::getDBVersions();
// @todo: more details about database runtime
}
#include <config.h>
#include <asiolink/io_address.h>
#include <cc/data.h>
-#include <database/database_connection.h>
#include <dhcp/dhcp4.h>
#include <dhcp/testutils/iface_mgr_test_config.h>
#include <dhcpsrv/cfgmgr.h>
#ifdef HAVE_MYSQL
// This test checks that the client can acquire and decline the lease.
TEST_F(DeclineTest, declineNoIdentifierChangeMySQL) {
- Initializer<MySqlLeaseMgrInit> init;
+ MySqlLeaseMgrInit init;
Dhcp4Client client(Dhcp4Client::SELECTING);
acquireAndDecline(client, "01:02:03:04:05:06", "12:14",
"01:02:03:04:05:06", "12:14",
#ifdef HAVE_PGSQL
// This test checks that the client can acquire and decline the lease.
TEST_F(DeclineTest, declineNoIdentifierChangePgSQL) {
- Initializer<PgSqlLeaseMgrInit> init;
+ PgSqlLeaseMgrInit init;
Dhcp4Client client(Dhcp4Client::SELECTING);
acquireAndDecline(client, "01:02:03:04:05:06", "12:14",
"01:02:03:04:05:06", "12:14",
void
Dhcpv4SrvTest::checkConfigFiles() {
#if defined (HAVE_MYSQL)
- Initializer<MySqlHostDataSourceInit> mysql_init;
+ MySqlHostDataSourceInit mysql_init;
#endif
#if defined (HAVE_PGSQL)
- Initializer<PgSqlHostDataSourceInit> pgsql_init;
+ PgSqlHostDataSourceInit pgsql_init;
#endif
DBInitializer dbi;
IfaceMgrTestConfig test_config(true);
#include <config.h>
#include <asiolink/io_address.h>
#include <cc/data.h>
-#include <database/database_connection.h>
#include <dhcp/dhcp4.h>
#include <dhcp/testutils/iface_mgr_test_config.h>
#include <dhcpsrv/cfgmgr.h>
}
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
// Test that the client using the same hardware address but multiple
}
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
// Test that the client using the same hardware address but multiple
#include <asiolink/io_address.h>
#include <asiolink/io_service.h>
#include <cc/command_interpreter.h>
-#include <database/database_connection.h>
#include <dhcp/dhcp4.h>
#include <dhcp/hwaddr.h>
#include <dhcp/iface_mgr.h>
const std::string& backend_second);
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
std::string
tmp << "lease backends:" << endl;
tmp << LeaseMgrFactory::getDBVersions() << endl;
tmp << "host backends:" << endl;
- tmp << HostDataSourceFactory::getDBVersions() << endl;
+ tmp << HostDataSourceFactory::getDBVersions();
// @todo: more details about database runtime
}
#include <config.h>
#include <asiolink/io_address.h>
#include <cc/data.h>
-#include <database/database_connection.h>
#include <dhcp/testutils/iface_mgr_test_config.h>
#include <dhcp6/json_config_parser.h>
#include <dhcp6/tests/dhcp6_message_test.h>
#ifdef HAVE_MYSQL
// This test checks that the client can acquire and decline the lease.
TEST_F(DeclineTest, basicMySQL) {
- Initializer<MySqlLeaseMgrInit> init;
+ MySqlLeaseMgrInit init;
Dhcp6Client client;
acquireAndDecline(client, "01:02:03:04:05:06", 1234, "01:02:03:04:05:06",
1234, VALID_ADDR, SHOULD_PASS, 1);
#ifdef HAVE_PGSQL
TEST_F(DeclineTest, basicPgSQL) {
- Initializer<PgSqlLeaseMgrInit> init;
+ PgSqlLeaseMgrInit init;
Dhcp6Client client;
acquireAndDecline(client, "01:02:03:04:05:06", 1234, "01:02:03:04:05:06",
1234, VALID_ADDR, SHOULD_PASS, 2);
void
Dhcpv6SrvTest::checkConfigFiles() {
#if defined (HAVE_MYSQL)
- Initializer<MySqlHostDataSourceInit> mysql_init;
+ MySqlHostDataSourceInit mysql_init;
#endif
#if defined (HAVE_PGSQL)
- Initializer<PgSqlHostDataSourceInit> pgsql_init;
+ PgSqlHostDataSourceInit pgsql_init;
#endif
DBInitializer dbi;
IfaceMgrTestConfig test_config(true);
#include <asiolink/io_address.h>
#include <cc/command_interpreter.h>
-#include <database/database_connection.h>
#include <dhcp/dhcp6.h>
#include <dhcp/duid.h>
#include <dhcp/iface_mgr.h>
const std::string& backend_second);
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
-
+ MySqlLeaseMgrInit init_;
};
std::string
}
/// @brief Initializer.
- Initializer<MySqlHostDataSourceInit> init_;
+ MySqlHostDataSourceInit init_;
};
/// @brief Check that database can be opened
/// MySqlHostMgr test fixture set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
TEST(MySqlHostDataSource, OpenDatabase) {
- Initializer<MySqlHostDataSourceInit> init;
+ MySqlHostDataSourceInit init;
// Schema needs to be created for the test to work.
destroyMySQLSchema();
createMySQLSchema();
/// MySqlHostMgr test fixture set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
TEST(MySqlHostDataSource, OpenDatabaseMultiThreading) {
- Initializer<MySqlHostDataSourceInit> init;
+ MySqlHostDataSourceInit init;
// Enable Multi-Threading.
MultiThreadingTest mt(true);
/// in a unit test is next to impossible. That has to be done
/// as a system test.
TEST(MySqlHostDataSource, NoCallbackOnOpenFail) {
- Initializer<MySqlHostDataSourceInit> init;
+ MySqlHostDataSourceInit init;
// Schema needs to be created for the test to work.
destroyMySQLSchema();
createMySQLSchema();
/// in a unit test is next to impossible. That has to be done
/// as a system test.
TEST(MySqlHostDataSource, NoCallbackOnOpenFailMultiThreading) {
- Initializer<MySqlHostDataSourceInit> init;
+ MySqlHostDataSourceInit init;
// Enable Multi-Threading.
MultiThreadingTest mt(true);
virtual void TearDown();
/// @brief Initializer.
- Initializer<MySqlHostDataSourceInit> init_;
+ MySqlHostDataSourceInit init_;
};
void
}
/// @brief Initializer.
- Initializer<MySqlHostDataSourceInit> init_;
+ MySqlHostDataSourceInit init_;
};
// This test verifies that reservations for a particular client can
}
/// @brief Initializer.
- Initializer<MySqlHostDataSourceInit> init_;
+ MySqlHostDataSourceInit init_;
};
// Tests that memfile lease manager and MySQL host data source can be created from a
}
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
// This test checks that simple allocation handles BOOTP queries.
}
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
/// @brief Test fixture class for extended info tests.
class MySqlExtendedInfoTest : public isc::dhcp::test::GenericExtendedInfoTest<NakedMySqlLeaseMgr> {
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
/// @brief Verifies that the lease manager can start.
}
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
/// @brief Check that database can be opened
/// MySqlLeaseMgr test fixture set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
TEST(MySqlOpenTest, OpenDatabase) {
- Initializer<MySqlLeaseMgrInit> init;
+ MySqlLeaseMgrInit init;
// Explicitly disable Multi-Threading.
MultiThreadingMgr::instance().setMode(false);
/// @brief Check that database can be opened with Multi-Threading
TEST(MySqlOpenTest, OpenDatabaseMultiThreading) {
- Initializer<MySqlLeaseMgrInit> init;
+ MySqlLeaseMgrInit init;
// Enable Multi-Threading.
MultiThreadingTest mt(true);
}
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
/// @brief Verifies that loss of connectivity to MySQL is handled correctly.
}
/// @brief Initializer.
- Initializer<MySqlLeaseMgrInit> init_;
+ MySqlLeaseMgrInit init_;
};
// Tests that MySQL lease manager and host data source can be created from a
}
/// @brief Initializer.
- Initializer<PgSqlHostDataSourceInit> init_;
+ PgSqlHostDataSourceInit init_;
};
/// @brief Check that database can be opened
/// PgSqlHostMgr test fixture set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
TEST(PgSqlHostDataSource, OpenDatabase) {
- Initializer<PgSqlHostDataSourceInit> init;
+ PgSqlHostDataSourceInit init;
// Schema needs to be created for the test to work.
destroyPgSQLSchema();
createPgSQLSchema();
/// PgSqlHostMgr test fixture set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
TEST(PgSqlHostDataSource, OpenDatabaseMultiThreading) {
- Initializer<PgSqlHostDataSourceInit> init;
+ PgSqlHostDataSourceInit init;
// Enable Multi-Threading.
MultiThreadingTest mt(true);
/// in a unit test is next to impossible. That has to be done
/// as a system test.
TEST(PgSqlHostDataSource, NoCallbackOnOpenFail) {
- Initializer<PgSqlHostDataSourceInit> init;
+ PgSqlHostDataSourceInit init;
// Schema needs to be created for the test to work.
destroyPgSQLSchema();
createPgSQLSchema();
/// in a unit test is next to impossible. That has to be done
/// as a system test.
TEST(PgSqlHostDataSource, NoCallbackOnOpenFailMultiThreading) {
- Initializer<PgSqlHostDataSourceInit> init;
+ PgSqlHostDataSourceInit init;
// Enable Multi-Threading.
MultiThreadingTest mt(true);
virtual void TearDown();
/// @brief Initializer.
- Initializer<PgSqlHostDataSourceInit> init_;
+ PgSqlHostDataSourceInit init_;
};
void
}
/// @brief Initializer.
- Initializer<PgSqlHostDataSourceInit> init_;
+ PgSqlHostDataSourceInit init_;
};
// This test verifies that reservations for a particular client can
}
/// @brief Initializer.
- Initializer<PgSqlHostDataSourceInit> init_;
+ PgSqlHostDataSourceInit init_;
};
// Tests that memfile lease manager and PostgreSQL host data source can be created from a
}
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
// This test checks that simple allocation handles BOOTP queries.
}
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
/// @brief Test fixture class for extended info tests.
class PgSqlExtendedInfoTest : public isc::dhcp::test::GenericExtendedInfoTest<NakedPgSqlLeaseMgr> {
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
/// @brief Verifies that the lease manager can start.
}
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
/// @brief Check that database can be opened
/// PgSqlLeaseMgr test fixture set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
TEST(PgSqlOpenTest, OpenDatabase) {
- Initializer<PgSqlLeaseMgrInit> init;
+ PgSqlLeaseMgrInit init;
// Explicitly disable Multi-Threading.
MultiThreadingMgr::instance().setMode(false);
/// @brief Check that database can be opened with Multi-Threading
TEST(PgSqlOpenTest, OpenDatabaseMultiThreading) {
- Initializer<PgSqlLeaseMgrInit> init;
+ PgSqlLeaseMgrInit init;
// Enable Multi-Threading.
MultiThreadingTest mt(true);
}
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
/// @brief Verifies that loss of connectivity to PostgreSQL is handled correctly.
}
/// @brief Initializer.
- Initializer<PgSqlLeaseMgrInit> init_;
+ PgSqlLeaseMgrInit init_;
};
// Tests that PostgreSQL lease manager and host data source can be created from a
}
};
-/// @brief RAII class to register a database backend by dynamically
-/// constructing an initialization object.
-///
-/// Used mostly in unittests.
-///
-/// @tparam T The initialization class which registers the database backend
-/// on constructor and deregisters it on destructor.
-template <typename T>
-struct Initializer {
- /// @brief Constructor.
- Initializer() : init_(new T()) {
- }
-
- /// @brief Destructor.
- ~Initializer() = default;
-
- /// @brief Smart pointer to an instance of an initializer.
- std::unique_ptr<T> init_;
-};
-
} // namespace db
} // namespace isc
std::stringstream txt;
for (auto const& x : map_) {
- if (!txt.str().empty()) {
- txt << " ";
+ auto version = x.second.second();
+ if (!txt.str().empty() && !version.empty()) {
+ txt << endl;
+ }
+ if (!version.empty()) {
+ txt << "- " << version;
}
- txt << x.second.second();
}
return (txt.str());
std::stringstream txt;
for (auto const& x : map_) {
- if (!txt.str().empty()) {
- txt << " ";
+ auto version = x.second.second();
+ if (!txt.str().empty() && !version.empty()) {
+ txt << endl;
+ }
+ if (!version.empty()) {
+ txt << "- " << version;
}
- txt << x.second.second();
}
return (txt.str());
EXPECT_TRUE(registerFactory2());
EXPECT_NO_THROW(HostDataSourceFactory::add(sources_, "type=mem2"));
- EXPECT_EQ("version 2", HostDataSourceFactory::getDBVersions());
+ EXPECT_EQ("- version 2", HostDataSourceFactory::getDBVersions());
EXPECT_TRUE(registerFactory());
- EXPECT_EQ("version 1 version 2", HostDataSourceFactory::getDBVersions());
+ EXPECT_EQ("- version 1\n- version 2", HostDataSourceFactory::getDBVersions());
// Delete them
EXPECT_TRUE(HostDataSourceFactory::del(sources_, "mem1"));
EXPECT_TRUE(LeaseMgrFactory::haveInstance());
EXPECT_EQ(LeaseMgrFactory::instance().getType(), "mem2");
- EXPECT_EQ("version 2 Memfile backend 3.0", LeaseMgrFactory::getDBVersions());
+ EXPECT_EQ("- version 2\n- Memfile backend 3.0", LeaseMgrFactory::getDBVersions());
EXPECT_TRUE(registerFactory());
- EXPECT_EQ("version 1 version 2 Memfile backend 3.0", LeaseMgrFactory::getDBVersions());
+ EXPECT_EQ("- version 1\n- version 2\n- Memfile backend 3.0", LeaseMgrFactory::getDBVersions());
// Delete them
EXPECT_NO_THROW(LeaseMgrFactory::destroy());
EXPECT_TRUE(LeaseMgrFactory::haveInstance());
EXPECT_EQ(LeaseMgrFactory::instance().getType(), "mem2");
- EXPECT_EQ("version 2 Memfile backend 5.0", LeaseMgrFactory::getDBVersions());
+ EXPECT_EQ("- version 2\n- Memfile backend 5.0", LeaseMgrFactory::getDBVersions());
EXPECT_TRUE(registerFactory());
- EXPECT_EQ("version 1 version 2 Memfile backend 5.0", LeaseMgrFactory::getDBVersions());
+ EXPECT_EQ("- version 1\n- version 2\n- Memfile backend 5.0", LeaseMgrFactory::getDBVersions());
// Delete them
EXPECT_NO_THROW(LeaseMgrFactory::destroy());