BIND 10 trac3359, updated. ae241216b7a9764e00835ffbde13011102db3983 [3359] getLease4HWAddr tests moved to common framework.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Mar 6 10:28:54 UTC 2014
The branch, trac3359 has been updated
via ae241216b7a9764e00835ffbde13011102db3983 (commit)
from 44267f77cf3490f3a79014acf39be61027a372f4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ae241216b7a9764e00835ffbde13011102db3983
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Thu Mar 6 10:28:46 2014 +0000
[3359] getLease4HWAddr tests moved to common framework.
-----------------------------------------------------------------------
Summary of changes:
.../dhcpsrv/tests/memfile_lease_mgr_unittest.cc | 12 ++-
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc | 91 ++-----------------
src/lib/dhcpsrv/tests/test_utils.cc | 92 +++++++++++++++++++-
src/lib/dhcpsrv/tests/test_utils.h | 14 ++-
4 files changed, 121 insertions(+), 88 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index 7113b75..d68a272 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -99,8 +99,16 @@ TEST_F(MemfileLeaseMgrTest, getLease4NullClientId) {
}
// Checks lease4 retrieval through HWAddr
-TEST_F(MemfileLeaseMgrTest, getLease4HWAddr) {
- testGetLease4HWAddr();
+TEST_F(MemfileLeaseMgrTest, getLease4HWAddr1) {
+ testGetLease4HWAddr1();
+}
+
+/// @brief Check GetLease4 methods - access by Hardware Address
+///
+/// Adds leases to the database and checks that they can be accessed via
+/// a combination of DUID and IAID.
+TEST_F(MemfileLeaseMgrTest, getLease4HWAddr2) {
+ testGetLease4HWAddr2();
}
// Checks lease4 retrieval with clientId, HWAddr and subnet_id
diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
index 621bbed..dfb8266 100644
--- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
@@ -370,45 +370,7 @@ TEST_F(MySqlLeaseMgrTest, lease4InvalidHostname) {
/// Checks that the addLease, getLease6 (by address) and deleteLease (with an
/// IPv6 address) works.
TEST_F(MySqlLeaseMgrTest, basicLease6) {
- // Get the leases to be used for the test.
- vector<Lease6Ptr> leases = createLeases6();
-
- // Start the tests. Add three leases to the database, read them back and
- // check they are what we think they are.
- EXPECT_TRUE(lmptr_->addLease(leases[1]));
- EXPECT_TRUE(lmptr_->addLease(leases[2]));
- EXPECT_TRUE(lmptr_->addLease(leases[3]));
- lmptr_->commit();
-
- // Reopen the database to ensure that they actually got stored.
- reopen();
-
- Lease6Ptr l_returned = lmptr_->getLease6(leasetype6_[1], ioaddress6_[1]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[1], l_returned);
-
- l_returned = lmptr_->getLease6(leasetype6_[2], ioaddress6_[2]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[2], l_returned);
-
- l_returned = lmptr_->getLease6(leasetype6_[3], ioaddress6_[3]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[3], l_returned);
-
- // Check that we can't add a second lease with the same address
- EXPECT_FALSE(lmptr_->addLease(leases[1]));
-
- // Delete a lease, check that it's gone, and that we can't delete it
- // a second time.
- EXPECT_TRUE(lmptr_->deleteLease(ioaddress6_[1]));
- l_returned = lmptr_->getLease6(leasetype6_[1], ioaddress6_[1]);
- EXPECT_FALSE(l_returned);
- EXPECT_FALSE(lmptr_->deleteLease(ioaddress6_[1]));
-
- // Check that the second address is still there.
- l_returned = lmptr_->getLease6(leasetype6_[2], ioaddress6_[2]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[2], l_returned);
+ testBasicLease6();
}
/// @brief Verify that too long hostname for Lease6 is not accepted.
@@ -437,52 +399,13 @@ TEST_F(MySqlLeaseMgrTest, lease6InvalidHostname) {
}
/// @brief Check GetLease4 methods - access by Hardware Address
-///
-/// Adds leases to the database and checks that they can be accessed via
-/// a combination of DIUID and IAID.
-TEST_F(MySqlLeaseMgrTest, getLease4Hwaddr) {
- // Get the leases to be used for the test and add to the database
- vector<Lease4Ptr> leases = createLeases4();
- for (int i = 0; i < leases.size(); ++i) {
- EXPECT_TRUE(lmptr_->addLease(leases[i]));
- }
-
- // Get the leases matching the hardware address of lease 1
- /// @todo: Simply use HWAddr directly once 2589 is implemented
- HWAddr tmp(leases[1]->hwaddr_, HTYPE_ETHER);
- Lease4Collection returned = lmptr_->getLease4(tmp);
-
- // Should be three leases, matching leases[1], [3] and [5].
- ASSERT_EQ(3, returned.size());
-
- // Easiest way to check is to look at the addresses.
- vector<string> addresses;
- for (Lease4Collection::const_iterator i = returned.begin();
- i != returned.end(); ++i) {
- addresses.push_back((*i)->addr_.toText());
- }
- sort(addresses.begin(), addresses.end());
- EXPECT_EQ(straddress4_[1], addresses[0]);
- EXPECT_EQ(straddress4_[3], addresses[1]);
- EXPECT_EQ(straddress4_[5], addresses[2]);
-
- // Repeat test with just one expected match
- /// @todo: Simply use HWAddr directly once 2589 is implemented
- returned = lmptr_->getLease4(HWAddr(leases[2]->hwaddr_, HTYPE_ETHER));
- ASSERT_EQ(1, returned.size());
- detailCompareLease(leases[2], *returned.begin());
-
- // Check that an empty vector is valid
- EXPECT_TRUE(leases[7]->hwaddr_.empty());
- /// @todo: Simply use HWAddr directly once 2589 is implemented
- returned = lmptr_->getLease4(HWAddr(leases[7]->hwaddr_, HTYPE_ETHER));
- ASSERT_EQ(1, returned.size());
- detailCompareLease(leases[7], *returned.begin());
+TEST_F(MySqlLeaseMgrTest, getLease4HWAddr1) {
+ testGetLease4HWAddr1();
+}
- // Try to get something with invalid hardware address
- vector<uint8_t> invalid(6, 0);
- returned = lmptr_->getLease4(invalid);
- EXPECT_EQ(0, returned.size());
+/// @brief Check GetLease4 methods - access by Hardware Address
+TEST_F(MySqlLeaseMgrTest, getLease4HWAddr2) {
+ testGetLease4HWAddr2();
}
// @brief Get lease4 by hardware address (2)
diff --git a/src/lib/dhcpsrv/tests/test_utils.cc b/src/lib/dhcpsrv/tests/test_utils.cc
index 06d10fc..52374d2 100644
--- a/src/lib/dhcpsrv/tests/test_utils.cc
+++ b/src/lib/dhcpsrv/tests/test_utils.cc
@@ -595,7 +595,7 @@ GenericLeaseMgrTest::testLease4NullClientId() {
}
void
-GenericLeaseMgrTest::testGetLease4HWAddr() {
+GenericLeaseMgrTest::testGetLease4HWAddr1() {
// Let's initialize two different leases 4 and just add the first ...
Lease4Ptr leaseA = initializeLease4(straddress4_[5]);
HWAddr hwaddrA(leaseA->hwaddr_, HTYPE_ETHER);
@@ -613,6 +613,52 @@ GenericLeaseMgrTest::testGetLease4HWAddr() {
}
void
+GenericLeaseMgrTest::testGetLease4HWAddr2() {
+ // Get the leases to be used for the test and add to the database
+ vector<Lease4Ptr> leases = createLeases4();
+ for (int i = 0; i < leases.size(); ++i) {
+ EXPECT_TRUE(lmptr_->addLease(leases[i]));
+ }
+
+ // Get the leases matching the hardware address of lease 1
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
+ HWAddr tmp(leases[1]->hwaddr_, HTYPE_ETHER);
+ Lease4Collection returned = lmptr_->getLease4(tmp);
+
+ // Should be three leases, matching leases[1], [3] and [5].
+ ASSERT_EQ(3, returned.size());
+
+ // Easiest way to check is to look at the addresses.
+ vector<string> addresses;
+ for (Lease4Collection::const_iterator i = returned.begin();
+ i != returned.end(); ++i) {
+ addresses.push_back((*i)->addr_.toText());
+ }
+ sort(addresses.begin(), addresses.end());
+ EXPECT_EQ(straddress4_[1], addresses[0]);
+ EXPECT_EQ(straddress4_[3], addresses[1]);
+ EXPECT_EQ(straddress4_[5], addresses[2]);
+
+ // Repeat test with just one expected match
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
+ returned = lmptr_->getLease4(HWAddr(leases[2]->hwaddr_, HTYPE_ETHER));
+ ASSERT_EQ(1, returned.size());
+ detailCompareLease(leases[2], *returned.begin());
+
+ // Check that an empty vector is valid
+ EXPECT_TRUE(leases[7]->hwaddr_.empty());
+ /// @todo: Simply use HWAddr directly once 2589 is implemented
+ returned = lmptr_->getLease4(HWAddr(leases[7]->hwaddr_, HTYPE_ETHER));
+ ASSERT_EQ(1, returned.size());
+ detailCompareLease(leases[7], *returned.begin());
+
+ // Try to get something with invalid hardware address
+ vector<uint8_t> invalid(6, 0);
+ returned = lmptr_->getLease4(invalid);
+ EXPECT_EQ(0, returned.size());
+}
+
+void
GenericLeaseMgrTest::testGetLease4ClientIdHWAddrSubnetId() {
Lease4Ptr leaseA = initializeLease4(straddress4_[4]);
Lease4Ptr leaseB = initializeLease4(straddress4_[5]);
@@ -771,6 +817,50 @@ GenericLeaseMgrTest::testBasicLease4() {
}
+void
+GenericLeaseMgrTest::testBasicLease6() {
+ // Get the leases to be used for the test.
+ vector<Lease6Ptr> leases = createLeases6();
+
+ // Start the tests. Add three leases to the database, read them back and
+ // check they are what we think they are.
+ EXPECT_TRUE(lmptr_->addLease(leases[1]));
+ EXPECT_TRUE(lmptr_->addLease(leases[2]));
+ EXPECT_TRUE(lmptr_->addLease(leases[3]));
+ lmptr_->commit();
+
+ // Reopen the database to ensure that they actually got stored.
+ reopen();
+
+ Lease6Ptr l_returned = lmptr_->getLease6(leasetype6_[1], ioaddress6_[1]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[1], l_returned);
+
+ l_returned = lmptr_->getLease6(leasetype6_[2], ioaddress6_[2]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[2], l_returned);
+
+ l_returned = lmptr_->getLease6(leasetype6_[3], ioaddress6_[3]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[3], l_returned);
+
+ // Check that we can't add a second lease with the same address
+ EXPECT_FALSE(lmptr_->addLease(leases[1]));
+
+ // Delete a lease, check that it's gone, and that we can't delete it
+ // a second time.
+ EXPECT_TRUE(lmptr_->deleteLease(ioaddress6_[1]));
+ l_returned = lmptr_->getLease6(leasetype6_[1], ioaddress6_[1]);
+ EXPECT_FALSE(l_returned);
+ EXPECT_FALSE(lmptr_->deleteLease(ioaddress6_[1]));
+
+ // Check that the second address is still there.
+ l_returned = lmptr_->getLease6(leasetype6_[2], ioaddress6_[2]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[2], l_returned);
+}
+
+
};
};
};
diff --git a/src/lib/dhcpsrv/tests/test_utils.h b/src/lib/dhcpsrv/tests/test_utils.h
index d159c32..935bbc8 100644
--- a/src/lib/dhcpsrv/tests/test_utils.h
+++ b/src/lib/dhcpsrv/tests/test_utils.h
@@ -122,7 +122,13 @@ public:
void testGetLease4NullClientId();
/// @brief Test lease retrieval using HW address.
- void testGetLease4HWAddr();
+ void testGetLease4HWAddr1();
+
+ /// @brief Check GetLease4 methods - access by Hardware Address
+ ///
+ /// Adds leases to the database and checks that they can be accessed using
+ /// HWAddr information.
+ void testGetLease4HWAddr2();
/// @brief Test lease retrieval using client id, HW address and subnet id.
void testGetLease4ClientIdHWAddrSubnetId();
@@ -136,6 +142,12 @@ public:
/// @todo: check if it does overlap with @ref testGetLease4NullClientId()
void testLease4NullClientId();
+ /// @brief Basic Lease6 Checks
+ ///
+ /// Checks that the addLease, getLease6 (by address) and deleteLease (with an
+ /// IPv6 address) works.
+ void testBasicLease6();
+
/// @brief Test that IPv6 lease can be added, retrieved and deleted.
///
/// This method checks basic IPv6 lease operations. There's check_t1_t2
More information about the bind10-changes
mailing list