]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#526,!269] More clean up
authorThomas Markwalder <tmark@isc.org>
Tue, 12 Mar 2019 15:52:37 +0000 (11:52 -0400)
committerThomas Markwalder <tmark@isc.org>
Tue, 12 Mar 2019 15:52:37 +0000 (11:52 -0400)
    General clean up, changed CQL params to be same order as MySQL.

src/bin/dhcp4/tests/dora_unittest.cc
src/lib/cql/testutils/cql_schema.cc
src/lib/cql/testutils/cql_schema.h
src/lib/dhcpsrv/benchmarks/cql_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/cql_lease_mgr_benchmark.cc
src/lib/dhcpsrv/benchmarks/mysql_host_data_source_benchmark.cc
src/lib/dhcpsrv/benchmarks/mysql_lease_mgr_benchmark.cc
src/lib/dhcpsrv/tests/cql_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/host_mgr_unittest.cc

index 04ef1fe615af14fa0d5c33b351e0061e7d43b476..e7becde891911cd52cbbdbb0af412eb2b3ab9672 100644 (file)
@@ -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();
     }
 };
 
index 87a3b64cdccf423bbf1cf13287686c287c9d0ab1..4dff591c5a93aabb0a9a44b31c92033b23b997bc 100644 (file)
@@ -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);
index 995c1fc92f1e79337105ac66cc775a75ab665849..dec6c70d2faf2b09ba52ad5d5f5f40a6285d4529 100644 (file)
@@ -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
 ///
index f0223012be639222219cf08f31cd5cb474e9ed1f..3e25aa3b170b3945bd8d3d065c301887c3b667c3 100644 (file)
@@ -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();
     }
 };
 
index 2179f6415faf89a5540e496f676e69f580b998aa..4fa64ecd4f7685a22ad981a25950461ae5ff2ec5 100644 (file)
@@ -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();
     }
 };
 
index d457f04f829d8432ae1921bcaad61d91df0e26af..3b93a66614d1f2ddd6c5690f59dceb25c39e5f0b 100644 (file)
@@ -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();
     }
 };
 
index a97197976ce426677095111f8fe46106cd0dd8df..9353557bce7cbda2f7defd6a36a037d809df543f 100644 (file)
@@ -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();
     }
 };
 
index 0fe732c72c4cd0ec47ae1c126c19481bae746f5f..b9b552e3530f3581b900026cf791b0c8c2c0b558 100644 (file)
@@ -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
index dccf2077363403c0761922dc37205797cab14d05..18b1c4a070d3b354c0c31d434f1d1a10d8e7ec72 100644 (file)
@@ -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
index c21d8c47863e932667a3bdd291be907e3bc54949..ab7d3e1b0a895511a13e5a61fa1b17b433c57d44 100644 (file)
@@ -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