From: Andrei Pavel Date: Tue, 10 Jan 2017 14:28:20 +0000 (+0200) Subject: minor changes X-Git-Tag: trac5494_base~11^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=53f765506e2f42ca5da55ecf5e8fe891e46a157b;p=thirdparty%2Fkea.git minor changes --- diff --git a/src/lib/dhcpsrv/cql_exchange.h b/src/lib/dhcpsrv/cql_exchange.h index 191dc5fcac..2d2e5e4b1c 100644 --- a/src/lib/dhcpsrv/cql_exchange.h +++ b/src/lib/dhcpsrv/cql_exchange.h @@ -39,7 +39,7 @@ typedef CassError (*CqlBindFunction)(CassStatement* statement, /// SELECT statements. typedef CassError (*CqlGetFunction)(const CassValue* value, void* data); -/// @brief Pair containing major and minor versions. +/// @brief Pair containing major and minor versions typedef std::pair VersionPair; /// @brief Wrapper over the bind and get functions that interface with Cassandra diff --git a/src/lib/dhcpsrv/cql_lease_mgr.h b/src/lib/dhcpsrv/cql_lease_mgr.h index 8fcf5c8d96..bd5c4b9743 100644 --- a/src/lib/dhcpsrv/cql_lease_mgr.h +++ b/src/lib/dhcpsrv/cql_lease_mgr.h @@ -590,11 +590,11 @@ private: /// declare them as "mutable".) /// @brief Exchange object for IPv4 boost::scoped_ptr exchange4_; - /// @brief Exchange object for IPv4 + /// @brief Exchange object for IPv6 boost::scoped_ptr exchange6_; /// @brief Exchange object for version boost::scoped_ptr versionExchange_; - //// @} + /// @} }; } // namespace dhcp diff --git a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc index fa2edfa3a8..a556b9959b 100644 --- a/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc @@ -18,11 +18,11 @@ #include #include -#include #include #include -#include +#include #include +#include #include #include @@ -53,7 +53,6 @@ public: /// /// Deletes everything from the database and opens it. CqlLeaseMgrTest() { - // Ensure schema is the correct one. destroyCqlSchema(false, true); createCqlSchema(false, true); @@ -95,13 +94,13 @@ public: lmptr_ = &(LeaseMgrFactory::instance()); } - // This is the CQL implementation for GenericLeaseMgrTest::testGetExpiredLeases4(). + // This is the CQL implementation for + // GenericLeaseMgrTest::testGetExpiredLeases4(). // The GenericLeaseMgrTest implementation checks for the order of expired // leases to be from the most expired to the least expired. Cassandra // doesn't support ORDER BY without imposing a EQ / IN restriction on the // columns. Because of that, the order check has been excluded. - void - testCqlGetExpiredLeases4() { + void testCqlGetExpiredLeases4() { // Get the leases to be used for the test. vector leases = createLeases4(); // Make sure we have at least 6 leases there. @@ -118,10 +117,12 @@ public: // valid lifetime to make it expired. The expiration time also // depends on the lease index, so as we can later check that the // leases are ordered by the expiration time. - leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 10 - i; + leases[i]->cltt_ = + current_time - leases[i]->valid_lft_ - 10 - i; } else { - // Set current time as cltt for remaining leases. These leases are + // Set current time as cltt for remaining leases. These leases + // are // not expired. leases[i]->cltt_ = current_time; } @@ -132,19 +133,22 @@ public: Lease4Collection expired_leases; ASSERT_NO_THROW(lmptr_->getExpiredLeases4(expired_leases, 1000)); // Leases with even indexes should be returned as expired. - ASSERT_EQ(static_cast(leases.size() / 2U), expired_leases.size()); + ASSERT_EQ(static_cast(leases.size() / 2U), + expired_leases.size()); // Update current time for the next test. current_time = time(NULL); // Also, remove expired leases collected during the previous test. expired_leases.clear(); - // This time let's reverse the expiration time and see if they will be returned + // This time let's reverse the expiration time and see if they will be + // returned // in the correct order. for (size_t i = 0U; i < leases.size(); ++i) { // Update the time of expired leases with even indexes. if (i % 2U == 0U) { - leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 1000 + i; + leases[i]->cltt_ = + current_time - leases[i]->valid_lft_ - 1000 + i; } else { // Make sure remaining leases remain unexpired. leases[i]->cltt_ = current_time + 100; @@ -152,11 +156,13 @@ public: ASSERT_NO_THROW(lmptr_->updateLease4(leases[i])); } - // Retrieve expired leases again. The limit of 0 means return all expired + // Retrieve expired leases again. The limit of 0 means return all + // expired // leases. ASSERT_NO_THROW(lmptr_->getExpiredLeases4(expired_leases, 0)); // The same leases should be returned. - ASSERT_EQ(static_cast(leases.size() / 2U), expired_leases.size()); + ASSERT_EQ(static_cast(leases.size() / 2U), + expired_leases.size()); // Remember expired leases returned. std::vector saved_expired_leases = expired_leases; @@ -173,7 +179,8 @@ public: // Mark every other expired lease as reclaimed. for (size_t i = 0U; i < saved_expired_leases.size(); ++i) { if (i % 2U != 0U) { - saved_expired_leases[i]->state_ = Lease::STATE_EXPIRED_RECLAIMED; + saved_expired_leases[i]->state_ = + Lease::STATE_EXPIRED_RECLAIMED; } ASSERT_NO_THROW(lmptr_->updateLease4(saved_expired_leases[i])); } @@ -190,18 +197,19 @@ public: // those that have even index. for (Lease4Collection::iterator lease = expired_leases.begin(); lease != expired_leases.end(); ++lease) { - int index = static_cast(std::distance(expired_leases.begin(), lease)); + int index = + static_cast(std::distance(expired_leases.begin(), lease)); EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_); } } - // This is the CQL implementation for GenericLeaseMgrTest::testGetExpiredLeases4(). + // This is the CQL implementation for + // GenericLeaseMgrTest::testGetExpiredLeases4(). // The GenericLeaseMgrTest implementation checks for the order of expired // leases to be from the most expired to the least expired. Cassandra // doesn't support ORDER BY without imposing a EQ / IN restriction on the // columns. Because of that, the order check has been excluded. - void - testCqlGetExpiredLeases6() { + void testCqlGetExpiredLeases6() { // Get the leases to be used for the test. vector leases = createLeases6(); // Make sure we have at least 6 leases there. @@ -218,10 +226,12 @@ public: // valid lifetime to make it expired. The expiration time also // depends on the lease index, so as we can later check that the // leases are ordered by the expiration time. - leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 10 - i; + leases[i]->cltt_ = + current_time - leases[i]->valid_lft_ - 10 - i; } else { - // Set current time as cltt for remaining leases. These leases are + // Set current time as cltt for remaining leases. These leases + // are // not expired. leases[i]->cltt_ = current_time; } @@ -232,19 +242,22 @@ public: Lease6Collection expired_leases; ASSERT_NO_THROW(lmptr_->getExpiredLeases6(expired_leases, 1000)); // Leases with even indexes should be returned as expired. - ASSERT_EQ(static_cast(leases.size() / 2U), expired_leases.size()); + ASSERT_EQ(static_cast(leases.size() / 2U), + expired_leases.size()); // Update current time for the next test. current_time = time(NULL); // Also, remove expired leases collected during the previous test. expired_leases.clear(); - // This time let's reverse the expiration time and see if they will be returned + // This time let's reverse the expiration time and see if they will be + // returned // in the correct order. for (size_t i = 0U; i < leases.size(); ++i) { // Update the time of expired leases with even indexes. if (i % 2U == 0U) { - leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 1000 + i; + leases[i]->cltt_ = + current_time - leases[i]->valid_lft_ - 1000 + i; } else { // Make sure remaining leases remain unexpired. @@ -253,11 +266,13 @@ public: ASSERT_NO_THROW(lmptr_->updateLease6(leases[i])); } - // Retrieve expired leases again. The limit of 0 means return all expired + // Retrieve expired leases again. The limit of 0 means return all + // expired // leases. ASSERT_NO_THROW(lmptr_->getExpiredLeases6(expired_leases, 0)); // The same leases should be returned. - ASSERT_EQ(static_cast(leases.size() / 2U), expired_leases.size()); + ASSERT_EQ(static_cast(leases.size() / 2U), + expired_leases.size()); // Remember expired leases returned. std::vector saved_expired_leases = expired_leases; @@ -274,7 +289,8 @@ public: // Mark every other expired lease as reclaimed. for (size_t i = 0U; i < saved_expired_leases.size(); ++i) { if (i % 2U != 0U) { - saved_expired_leases[i]->state_ = Lease::STATE_EXPIRED_RECLAIMED; + saved_expired_leases[i]->state_ = + Lease::STATE_EXPIRED_RECLAIMED; } ASSERT_NO_THROW(lmptr_->updateLease6(saved_expired_leases[i])); } @@ -289,7 +305,8 @@ public: // those that have even index. for (Lease6Collection::iterator lease = expired_leases.begin(); lease != expired_leases.end(); ++lease) { - int index = static_cast(std::distance(expired_leases.begin(), lease)); + int index = + static_cast(std::distance(expired_leases.begin(), lease)); EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_); } } @@ -304,7 +321,6 @@ public: /// Unlike other backend implementations, this one doesn't check for lacking /// parameters. In that scenario, Cassandra defaults to configured parameters. TEST(CqlOpenTest, OpenDatabase) { - // Schema needs to be created for the test to work. destroyCqlSchema(false, true); createCqlSchema(false, true); @@ -313,7 +329,7 @@ TEST(CqlOpenTest, OpenDatabase) { // If it fails, print the error message. try { LeaseMgrFactory::create(validCqlConnectionString()); - EXPECT_NO_THROW((void) LeaseMgrFactory::instance()); + EXPECT_NO_THROW((void)LeaseMgrFactory::instance()); LeaseMgrFactory::destroy(); } catch (const isc::Exception& ex) { FAIL() << "*** ERROR: unable to open database, reason:\n" @@ -325,10 +341,11 @@ TEST(CqlOpenTest, 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 = validCqlConnectionString() + string(" ") + - string(VALID_TIMEOUT); + std::string connection_string = validCqlConnectionString() + + std::string(" ") + + std::string(VALID_TIMEOUT); LeaseMgrFactory::create(connection_string); - EXPECT_NO_THROW((void) LeaseMgrFactory::instance()); + EXPECT_NO_THROW((void)LeaseMgrFactory::instance()); LeaseMgrFactory::destroy(); } catch (const isc::Exception& ex) { FAIL() << "*** ERROR: unable to open database, reason:\n" @@ -344,12 +361,13 @@ TEST(CqlOpenTest, OpenDatabase) { // Check that wrong specification of backend throws an exception. // (This is really a check on LeaseMgrFactory, but is convenient to // perform here.) - EXPECT_THROW(LeaseMgrFactory::create(connectionString( - NULL, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)), + EXPECT_THROW( + LeaseMgrFactory::create(connectionString(NULL, VALID_NAME, VALID_HOST, + INVALID_USER, VALID_PASSWORD)), InvalidParameter); - - EXPECT_THROW(LeaseMgrFactory::create(connectionString( - INVALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)), + EXPECT_THROW( + LeaseMgrFactory::create(connectionString( + INVALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)), InvalidType); // Check that invalid login data does not cause an exception, CQL should use @@ -514,7 +532,8 @@ TEST_F(CqlLeaseMgrTest, getLease4ClientIdSubnetId) { /// @brief Basic Lease4 Checks /// -/// Checks that the addLease, getLease4(by address), getLease4(hwaddr, subnet_id), +/// Checks that the addLease, getLease4(by address), getLease4(hwaddr, +/// subnet_id), /// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id. /// (client-id is optional and may not be present) TEST_F(CqlLeaseMgrTest, lease4NullClientId) {