]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
fixed compilation issues for cql unittests
authorTomek Mrugalski <tomasz@isc.org>
Thu, 23 Jun 2016 12:32:06 +0000 (14:32 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 23 Jun 2016 12:32:06 +0000 (14:32 +0200)
# Conflicts:
# src/lib/dhcpsrv/pgsql_lease_mgr.h

src/lib/dhcpsrv/cql_connection.cc
src/lib/dhcpsrv/cql_connection.h
src/lib/dhcpsrv/cql_lease_mgr.cc
src/lib/dhcpsrv/cql_lease_mgr.h
src/lib/dhcpsrv/mysql_connection.h
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
src/share/database/scripts/cql/Makefile.am

index 954b1917767b8b94379567e1990ff588e5a1949d..0841ecaccaab6e77d9c0ed5613cb1cca009b2707 100644 (file)
@@ -165,33 +165,6 @@ CqlConnection::prepareStatements(CqlTaggedStatement *statements) {
     }
 }
 
-string
-CqlConnection::getName() const {
-    string name = "";
-    try {
-        name = getParameter("name");
-    } catch (...) {
-        // Return an empty name
-    }
-    return (name);
-}
-
-string
-CqlConnection::getDescription() const {
-    return (string("Cassandra Database"));
-}
-
-pair<uint32_t, uint32_t>
-CqlConnection::getVersion() const {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
-              DHCPSRV_CQL_GET_VERSION);
-
-    uint32_t version = CASS_VERSION_MAJOR;
-    uint32_t minor = CASS_VERSION_MINOR;
-
-    return make_pair<uint32_t, uint32_t>(version, minor);
-}
-
 void
 CqlConnection::commit() {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_COMMIT);
index 644c0c72f71b4604f9a9562a970422b359cb9699..5e6997ec282ffe032452ae13d4e7d3bd92627cda 100644 (file)
@@ -38,8 +38,12 @@ struct CqlTaggedStatement {
 };
 
 // Defines CQL backend version: 2.3
-const uint32_t CQL_CURRENT_VERSION = CASS_VERSION_MAJOR;
-const uint32_t CQL_CURRENT_MINOR = CASS_VERSION_MINOR;
+const uint32_t CQL_DRIVER_VERSION_MAJOR = CASS_VERSION_MAJOR;
+const uint32_t CQL_DRIVER_VERSION_MINOR = CASS_VERSION_MINOR;
+
+/// Defines CQL schema version: 1.0
+const uint32_t CQL_SCHEMA_VERSION_MAJOR = 1;
+const uint32_t CQL_SCHEMA_VERSION_MINOR = 0;
 
 class CqlConnection : public DatabaseConnection {
 public:
@@ -72,34 +76,6 @@ public:
     /// @throw DbOpenError Error opening the database
     void openDatabase();
 
-    /// @brief Return backend type
-    ///
-    /// @return Type of the backend.
-    virtual std::string getType() const {
-        return (std::string("cql"));
-    }
-
-    /// @brief Returns name of the database.
-    ///
-    /// @return database name
-    virtual std::string getName() const;
-
-    /// @brief Returns description of the backend.
-    ///
-    /// This description may be multiline text that describes the backend.
-    ///
-    /// @return Description of the backend.
-    virtual std::string getDescription() const;
-
-    /// @brief Returns backend version.
-    ///
-    /// @return Version number as a pair of unsigned integers. "first" is the
-    ///         major version number, "second" the minor number.
-    ///
-    /// @throw isc::dhcp::DbOperationError An operation on the open database has
-    ///        failed.
-    virtual std::pair<uint32_t, uint32_t> getVersion() const;
-
     /// @brief Commit Transactions
     ///
     /// Commits all pending database operations.
index c3a347b54063a0a886484458a6d87d1350a827bb..53a6287f9e259573bc353cab7029cf8f8b1afcf1 100644 (file)
@@ -429,34 +429,6 @@ CqlTaggedStatement CqlLeaseMgr::tagged_statements_[] = {
     { NULL, NULL, NULL }
 };
 
-class CqlExchange : public virtual SqlExchange {
-public:
-    // Time conversion methods.
-    static void
-    convertToDatabaseTime(const time_t& cltt,
-                          const uint32_t& valid_lifetime,
-                          uint64_t& expire) {
-        // Calculate expiry time. Store it in the 64-bit value so as we can
-        // detect overflows.
-        int64_t expire_time = static_cast<int64_t>(cltt) +
-            static_cast<int64_t>(valid_lifetime);
-
-        if (expire_time > DatabaseConnection::MAX_DB_TIME) {
-            isc_throw(BadValue, "Time value is too large: " << expire_time);
-        }
-
-        expire = expire_time;
-    }
-
-    static void
-    convertFromDatabaseTime(const uint64_t& expire,
-                            const uint32_t& valid_lifetime,
-                            time_t& cltt) {
-        // Convert to local time
-        cltt = expire - static_cast<int64_t>(valid_lifetime);
-    }
-};
-
 /// @brief Common CQL and Lease Data Methods
 ///
 /// The CqlLease4Exchange and CqlLease6Exchange classes provide the
@@ -1154,8 +1126,8 @@ CqlLeaseMgr::~CqlLeaseMgr() {
 std::string
 CqlLeaseMgr::getDBVersion() {
     std::stringstream tmp;
-    tmp << "CQL backend " << CQL_CURRENT_VERSION;
-    tmp << "." << CQL_CURRENT_MINOR;
+    tmp << "CQL backend " << CQL_SCHEMA_VERSION_MAJOR;
+    tmp << "." << CQL_SCHEMA_VERSION_MINOR;
     tmp << ", library " << "cassandra_static";
     return (tmp.str());
 }
index c5fcc1a490ee9122854d0218562f7993c6499f8c..0c5f00dfc5701e40769aebd48ad701d46273bb89 100644 (file)
@@ -58,6 +58,38 @@ class CqlLeaseExchange;
 class CqlLease4Exchange;
 class CqlLease6Exchange;
 
+/// @brief Cassandra Exchange
+///
+/// This class provides the basic conversion functions between Cassandra CQL and
+/// base types.
+class CqlExchange : public virtual SqlExchange {
+public:
+    // Time conversion methods.
+    static void
+    convertToDatabaseTime(const time_t& cltt,
+                          const uint32_t& valid_lifetime,
+                          uint64_t& expire) {
+        // Calculate expiry time. Store it in the 64-bit value so as we can
+        // detect overflows.
+        int64_t expire_time = static_cast<int64_t>(cltt) +
+            static_cast<int64_t>(valid_lifetime);
+
+        if (expire_time > DatabaseConnection::MAX_DB_TIME) {
+            isc_throw(BadValue, "Time value is too large: " << expire_time);
+        }
+
+        expire = expire_time;
+    }
+
+    static void
+    convertFromDatabaseTime(const uint64_t& expire,
+                            const uint32_t& valid_lifetime,
+                            time_t& cltt) {
+        // Convert to local time
+        cltt = expire - static_cast<int64_t>(valid_lifetime);
+    }
+};
+
 /// @brief Cassandra Lease Manager
 ///
 /// This class provides the \ref isc::dhcp::LeaseMgr interface to the Cassandra
index f5e7ab022bdd8ccf7de77639bbeb2eb4a10f198f..8acb894577643a34041c9e3a159f6fdc715b4533 100755 (executable)
@@ -40,8 +40,8 @@ extern const int MLM_MYSQL_FETCH_FAILURE;
 
 /// @name Current database schema version values.
 //@{
-const uint32_t CURRENT_VERSION_VERSION = 4;
-const uint32_t CURRENT_VERSION_MINOR = 2;
+const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 4;
+const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 2;
 
 //@}
 
index 3d60dd6f49735e82c30f033f96bc565c57673b5b..410880af36e404e48e88fc4fe937111c0dd4d2a9 100755 (executable)
@@ -1253,8 +1253,8 @@ MySqlLeaseMgr::~MySqlLeaseMgr() {
 std::string
 MySqlLeaseMgr::getDBVersion() {
     std::stringstream tmp;
-    tmp << "MySQL backend " << CURRENT_VERSION_VERSION;
-    tmp << "." << CURRENT_VERSION_MINOR;
+    tmp << "MySQL backend " << MYSQL_SCHEMA_VERSION_MAJOR;
+    tmp << "." << MYSQL_SCHEMA_VERSION_MINOR;
     tmp << ", library " << mysql_get_client_info();
     return (tmp.str());
 }
index 849aee542043c8282b1c28e602d9b1d66ddb0a8d..4714378db60181a510805e09a227b2827be7e019 100644 (file)
@@ -729,8 +729,8 @@ PgSqlLeaseMgr::~PgSqlLeaseMgr() {
 std::string
 PgSqlLeaseMgr::getDBVersion() {
     std::stringstream tmp;
-    tmp << "PostgreSQL backend " << PG_CURRENT_VERSION;
-    tmp << "." << PG_CURRENT_MINOR;
+    tmp << "PostgreSQL backend " << PG_SCHEMA_VERSION_MAJOR;
+    tmp << "." << PG_SCHEMA_VERSION_MINOR;
     tmp << ", library " << PQlibVersion();
     return (tmp.str());
 }
index a82b62ea76ed9762caf5031d2d16818e8b5827aa..4923c430682ee0a775c85c4ecf21460eea19d37a 100644 (file)
@@ -142,36 +142,6 @@ TEST(CqlOpenTest, OpenDatabase) {
         INVALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
         InvalidType);
 
-    // Check that invalid login data causes an exception.
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, INVALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
-        DbOpenError);
-
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
-        DbOpenError);
-
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
-        DbOpenError);
-
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, INVALID_PASSWORD)),
-        DbOpenError);
-
-    // Check for invalid timeouts
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_1)),
-        DbInvalidTimeout);
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_2)),
-        DbInvalidTimeout);
-
-    // Check for missing parameters
-    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
-        CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
-        NoDatabaseName);
-
     // Tidy up after the test
     destroyCqlSchema(false, true);
 }
@@ -217,8 +187,8 @@ TEST_F(CqlLeaseMgrTest, checkVersion) {
     // Check version
     pair<uint32_t, uint32_t> version;
     ASSERT_NO_THROW(version = lmptr_->getVersion());
-    EXPECT_EQ(CQL_CURRENT_VERSION, version.first);
-    EXPECT_EQ(CQL_CURRENT_MINOR, version.second);
+    EXPECT_EQ(CQL_SCHEMA_VERSION_MAJOR, version.first);
+    EXPECT_EQ(CQL_SCHEMA_VERSION_MINOR, version.second);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index 7f70d24f83e6aab4ca59399d252c19e9cd2dc884..33549b415a3b5a257a998e09b03e22ea4381f6c9 100755 (executable)
@@ -116,7 +116,7 @@ TEST(MySqlOpenTest, OpenDatabase) {
     // Check that lease manager open the database opens correctly with a longer
     // timeout.  If it fails, print the error message.
     try {
-       string connection_string = validMySQLConnectionString() + string(" ") + 
+       string connection_string = validMySQLConnectionString() + string(" ") +
                                    string(VALID_TIMEOUT);
         LeaseMgrFactory::create(connection_string);
         EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
@@ -231,8 +231,8 @@ TEST_F(MySqlLeaseMgrTest, checkVersion) {
     // Check version
     pair<uint32_t, uint32_t> version;
     ASSERT_NO_THROW(version = lmptr_->getVersion());
-    EXPECT_EQ(CURRENT_VERSION_VERSION, version.first);
-    EXPECT_EQ(CURRENT_VERSION_MINOR, version.second);
+    EXPECT_EQ(MYSQL_SCHEMA_VERSION_MAJOR, version.first);
+    EXPECT_EQ(MYSQL_SCHEMA_VERSION_MINOR, version.second);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index b31d94868b90903d36653c44cef733e361dc47fb..d44d5dff353b393f46c609e5f3084d36c5d76941 100755 (executable)
@@ -190,8 +190,8 @@ TEST_F(PgSqlLeaseMgrTest, checkVersion) {
     // Check version
     pair<uint32_t, uint32_t> version;
     ASSERT_NO_THROW(version = lmptr_->getVersion());
-    EXPECT_EQ(PG_CURRENT_VERSION, version.first);
-    EXPECT_EQ(PG_CURRENT_MINOR, version.second);
+    EXPECT_EQ(PG_SCHEMA_VERSION_MAJOR, version.first);
+    EXPECT_EQ(PG_SCHEMA_VERSION_MINOR, version.second);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -403,4 +403,3 @@ TEST_F(PgSqlLeaseMgrTest, getExpiredLeases6) {
 }
 
 }; // namespace
-
index ee335b0a83bcc60a349af391a2b6451992fe2963..400bcfcc6dbeaead23cdb6286f2365d23cfbda51 100644 (file)
@@ -1,6 +1,7 @@
 SUBDIRS = .
 
 sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/cql
-sqlscripts_DATA = dhcpdb_create.cql dhcpdb_drop.cql
+sqlscripts_DATA = dhcpdb_create.cql
+sqlscripts_DATA += dhcpdb_drop.cql
 
 EXTRA_DIST = ${sqlscripts_DATA}