From: Thomas Markwalder Date: Tue, 12 Mar 2019 15:52:37 +0000 (-0400) Subject: [#526,!269] More clean up X-Git-Tag: Kea-1.6.0-beta~391^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bee6240bd81f4c644fe2188252f92479d7f1373b;p=thirdparty%2Fkea.git [#526,!269] More clean up General clean up, changed CQL params to be same order as MySQL. --- diff --git a/src/bin/dhcp4/tests/dora_unittest.cc b/src/bin/dhcp4/tests/dora_unittest.cc index 04ef1fe615..e7becde891 100644 --- a/src/bin/dhcp4/tests/dora_unittest.cc +++ b/src/bin/dhcp4/tests/dora_unittest.cc @@ -2266,15 +2266,16 @@ public: /// /// 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(); } }; diff --git a/src/lib/cql/testutils/cql_schema.cc b/src/lib/cql/testutils/cql_schema.cc index 87a3b64cdc..4dff591c5a 100644 --- a/src/lib/cql/testutils/cql_schema.cc +++ b/src/lib/cql/testutils/cql_schema.cc @@ -32,7 +32,7 @@ validCqlConnectionString() { } 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); @@ -40,7 +40,7 @@ destroyCqlSchema(bool force, bool 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); diff --git a/src/lib/cql/testutils/cql_schema.h b/src/lib/cql/testutils/cql_schema.h index 995c1fc92f..dec6c70d2f 100644 --- a/src/lib/cql/testutils/cql_schema.h +++ b/src/lib/cql/testutils/cql_schema.h @@ -39,10 +39,10 @@ std::string validCqlConnectionString(); /// -# 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 /// @@ -64,10 +64,10 @@ void destroyCqlSchema(bool force, bool show_err = false); /// -# 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 /// diff --git a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc index f0223012be..3e25aa3b17 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc @@ -38,8 +38,8 @@ public: /// /// 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()); @@ -60,7 +60,8 @@ public: << endl; } HostDataSourceFactory::destroy(); - destroyCqlSchema(false, true); + // If data wipe enabled, delete transient data otherwise destroy the schema + destroyCqlSchema(); } }; diff --git a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc index 2179f6415f..4fa64ecd4f 100644 --- a/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc @@ -36,8 +36,8 @@ public: /// /// 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()); @@ -58,7 +58,8 @@ public: << endl; } LeaseMgrFactory::destroy(); - destroyCqlSchema(false, true); + // If data wipe enabled, delete transient data otherwise destroy the schema + destroyCqlSchema(); } }; diff --git a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc index d457f04f82..3b93a66614 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc @@ -39,7 +39,7 @@ public: /// 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()); @@ -61,7 +61,7 @@ public: } HostDataSourceFactory::destroy(); // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(false); + destroyMySQLSchema(); } }; diff --git a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc index a97197976c..9353557bce 100644 --- a/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc +++ b/src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc @@ -37,7 +37,7 @@ public: /// 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()); @@ -59,7 +59,7 @@ public: } LeaseMgrFactory::destroy(); // If data wipe enabled, delete transient data otherwise destroy the schema. - destroyMySQLSchema(false); + destroyMySQLSchema(); } }; diff --git a/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc index 0fe732c72c..b9b552e353 100644 --- a/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc @@ -53,9 +53,8 @@ class CqlHostDataSourceTest : public GenericHostDataSourceTest { 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 { @@ -83,7 +82,8 @@ public: } HostMgr::delAllBackends(); hdsptr_.reset(); - destroyCqlSchema(false, true); + // If data wipe enabled, delete transient data otherwise destroy the schema + destroyCqlSchema(); } /// @brief Constructor @@ -187,9 +187,8 @@ public: 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. @@ -259,7 +258,7 @@ TEST(CqlHostDataSource, OpenDatabase) { NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD))); // Tidy up after the test - destroyCqlSchema(false, true); + destroyCqlSchema(); } /// @brief Check conversion functions diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index dccf207736..18b1c4a070 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -55,8 +55,8 @@ class CqlLeaseMgrTest : public GenericLeaseMgrTest { 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 { @@ -81,7 +81,8 @@ public: // 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 @@ -340,7 +341,7 @@ public: 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. @@ -443,7 +444,7 @@ TEST(CqlOpenTest, OpenDatabase) { CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD))); // Tidy up after the test - destroyCqlSchema(false, true); + destroyCqlSchema(); } /// @brief Check the getType() method diff --git a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc index c21d8c4786..ab7d3e1b0a 100644 --- a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc @@ -1217,9 +1217,8 @@ void 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 { @@ -1238,7 +1237,9 @@ void 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