General clean up, changed CQL params to be same order as MySQL.
///
/// Recreates CQL schema for a test.
DORACQLTest() : DORATest() {
- db::test::destroyCqlSchema(false, true);
- db::test::createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ db::test::createCqlSchema();
}
/// @brief Destructor.
///
/// Destroys CQL schema.
virtual ~DORACQLTest() {
- db::test::destroyCqlSchema(false, true);
+ // If data wipe enabled, delete transient data otherwise destroy the schema
+ db::test::destroyCqlSchema();
}
};
}
void
-destroyCqlSchema(bool force, bool show_err) {
+destroyCqlSchema(bool show_err, bool force) {
// If force is true or wipeCqlData() fails, destory the schema.
if (force || (!softWipeEnabled()) || wipeCqlData(show_err)) {
runCqlScript(DATABASE_SCRIPTS_DIR, "cql/dhcpdb_drop.cql", show_err);
}
void
-createCqlSchema(bool force, bool show_err) {
+createCqlSchema(bool show_err, bool force) {
// If force is true or wipeCqlData() fails, recreate the schema.
if (force || (!softWipeEnabled()) || wipeCqlData(show_err)) {
destroyCqlSchema(show_err, true);
/// -# Defining the environment variable:
/// KEA_TEST_DB_WIPE_DATA_ONLY="false"
///
-/// @param force if true, the function will skip deleting the data and
/// @param show_err flag which governs whether or not stderr is suppressed.
+/// @param force if true, the function will skip deleting the data and
/// destroy the schema.
-void destroyCqlSchema(bool force, bool show_err = false);
+void destroyCqlSchema(bool show_err = false, bool force = false);
/// @brief Create the unit test Cql Schema
///
/// -# Defining the environment variable:
/// KEA_TEST_DB_WIPE_DATA_ONLY="false"
///
+/// @param show_err flag which governs whether or not stderr is suppressed.
/// @param force flag when true, the function will recreate the database
/// schema.
-/// @param show_err flag which governs whether or not stderr is suppressed.
-void createCqlSchema(bool force, bool show_err = false);
+void createCqlSchema(bool show_err = false, bool force = false);
/// @brief Run a CQL script against the CQL unit test database
///
///
/// It cleans up schema and recreates tables, then instantiates HostMgr
void SetUp(::benchmark::State const&) override {
- destroyCqlSchema(false, true);
- createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ createCqlSchema();
try {
HostDataSourceFactory::destroy();
HostDataSourceFactory::create(validCqlConnectionString());
<< endl;
}
HostDataSourceFactory::destroy();
- destroyCqlSchema(false, true);
+ // If data wipe enabled, delete transient data otherwise destroy the schema
+ destroyCqlSchema();
}
};
///
/// It cleans up schema and recreates tables, then instantiates LeaseMgr
void SetUp(::benchmark::State const&) override {
- destroyCqlSchema(false, true);
- createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ createCqlSchema();
try {
LeaseMgrFactory::destroy();
LeaseMgrFactory::create(validCqlConnectionString());
<< endl;
}
LeaseMgrFactory::destroy();
- destroyCqlSchema(false, true);
+ // If data wipe enabled, delete transient data otherwise destroy the schema
+ destroyCqlSchema();
}
};
/// It cleans up schema and recreates tables, then instantiates HostMgr
void SetUp(::benchmark::State const&) override {
// Ensure we have the proper schema with no transient data.
- createMySQLSchema(false);
+ createMySQLSchema();
try {
HostDataSourceFactory::destroy();
HostDataSourceFactory::create(validMySQLConnectionString());
}
HostDataSourceFactory::destroy();
// If data wipe enabled, delete transient data otherwise destroy the schema.
- destroyMySQLSchema(false);
+ destroyMySQLSchema();
}
};
/// It cleans up schema and recreates tables, then instantiates LeaseMgr
void SetUp(::benchmark::State const&) override {
// Ensure we have the proper schema with no transient data.
- createMySQLSchema(false);
+ createMySQLSchema();
try {
LeaseMgrFactory::destroy();
LeaseMgrFactory::create(validMySQLConnectionString());
}
LeaseMgrFactory::destroy();
// If data wipe enabled, delete transient data otherwise destroy the schema.
- destroyMySQLSchema(false);
+ destroyMySQLSchema();
}
};
public:
/// @brief Clears the database and opens connection to it.
void initializeTest() {
- // Ensure schema is the correct one.
- destroyCqlSchema(false, true);
- createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ createCqlSchema();
// Connect to the database
try {
}
HostMgr::delAllBackends();
hdsptr_.reset();
- destroyCqlSchema(false, true);
+ // If data wipe enabled, delete transient data otherwise destroy the schema
+ destroyCqlSchema();
}
/// @brief Constructor
TEST(CqlHostDataSource, OpenDatabase) {
- // Schema needs to be created for the test to work.
- destroyCqlSchema(false, true);
- createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ createCqlSchema();
// Check that host manager open the database opens correctly and tidy up.
// If it fails, print the error message.
NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
// Tidy up after the test
- destroyCqlSchema(false, true);
+ destroyCqlSchema();
}
/// @brief Check conversion functions
public:
/// @brief Clears the database and opens connection to it.
void initializeTest() {
- // Ensure schema is the correct one.
- createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ createCqlSchema();
// Connect to the database
try {
// Rollback may fail if backend is in read only mode. That's ok.
}
LeaseMgrFactory::destroy();
- destroyCqlSchema(false, true);
+ // If data wipe enabled, delete transient data otherwise destroy the schema
+ destroyCqlSchema();
}
/// @brief Constructor
TEST(CqlOpenTest, OpenDatabase) {
// Schema needs to be created for the test to work.
- createCqlSchema(false, true);
+ createCqlSchema();
// Check that lease manager open the database opens correctly and tidy up.
// If it fails, print the error message.
CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)));
// Tidy up after the test
- destroyCqlSchema(false, true);
+ destroyCqlSchema();
}
/// @brief Check the getType() method
CQLHostMgrTest::SetUp() {
HostMgrTest::SetUp();
- // Ensure schema is the correct one.
- db::test::destroyCqlSchema(false, true);
- db::test::createCqlSchema(false, true);
+ // Ensure we have the proper schema with no transient data.
+ db::test::createCqlSchema();
// Connect to the database
try {
CQLHostMgrTest::TearDown() {
HostMgr::instance().getHostDataSource()->rollback();
HostMgr::delBackend("cql");
- db::test::destroyCqlSchema(false, true);
+
+ // If data wipe enabled, delete transient data otherwise destroy the schema
+ db::test::destroyCqlSchema();
}
// This test verifies that reservations for a particular client can