BIND 10 trac3359, updated. 44267f77cf3490f3a79014acf39be61027a372f4 [3359] Basic lease4 test moved to common lease test suite.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Mar 6 10:15:37 UTC 2014
The branch, trac3359 has been updated
via 44267f77cf3490f3a79014acf39be61027a372f4 (commit)
from c62714b4a8458c4cc777d32fe11b4aab61b91fad (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 44267f77cf3490f3a79014acf39be61027a372f4
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Thu Mar 6 10:14:26 2014 +0000
[3359] Basic lease4 test moved to common lease test suite.
-----------------------------------------------------------------------
Summary of changes:
.../dhcpsrv/tests/memfile_lease_mgr_unittest.cc | 13 ++++
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc | 71 +-------------------
src/lib/dhcpsrv/tests/test_utils.cc | 69 +++++++++++++++++++
src/lib/dhcpsrv/tests/test_utils.h | 9 +++
4 files changed, 93 insertions(+), 69 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index 81b7beb..7113b75 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -108,4 +108,17 @@ TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetId) {
testGetLease4ClientIdHWAddrSubnetId();
}
+/// @brief Basic Lease4 Checks
+///
+/// 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(MemfileLeaseMgrTest, DISABLED_lease4NullClientId) {
+
+ /// @todo Test is disabled, because memfile does not support disk storage, so
+ /// all leases are lost after reopen()
+ testLease4NullClientId();
+}
+
+
}; // end of anonymous namespace
diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
index ca3c09f..621bbed 100644
--- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
@@ -330,81 +330,14 @@ TEST_F(MySqlLeaseMgrTest, testAddGetDelete6) {
testAddGetDelete6(false);
}
+
/// @brief Basic Lease4 Checks
///
/// 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(MySqlLeaseMgrTest, lease4NullClientId) {
- // Get the leases to be used for the test.
- vector<Lease4Ptr> leases = createLeases4();
-
- // Let's clear client-id pointers
- leases[1]->client_id_ = ClientIdPtr();
- leases[2]->client_id_ = ClientIdPtr();
- leases[3]->client_id_ = ClientIdPtr();
-
- // 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();
-
- Lease4Ptr l_returned = lmptr_->getLease4(ioaddress4_[1]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[1], l_returned);
-
- l_returned = lmptr_->getLease4(ioaddress4_[2]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[2], l_returned);
-
- l_returned = lmptr_->getLease4(ioaddress4_[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]));
-
- // Check that we can get the lease by HWAddr
- HWAddr tmp(leases[2]->hwaddr_, HTYPE_ETHER);
- Lease4Collection returned = lmptr_->getLease4(tmp);
- ASSERT_EQ(1, returned.size());
- detailCompareLease(leases[2], *returned.begin());
-
- l_returned = lmptr_->getLease4(tmp, leases[2]->subnet_id_);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[2], l_returned);
-
-
- // Check that we can update the lease
- // Modify some fields in lease 1 (not the address) and update it.
- ++leases[1]->subnet_id_;
- leases[1]->valid_lft_ *= 2;
- lmptr_->updateLease4(leases[1]);
-
- // ... and check that the lease is indeed updated
- l_returned = lmptr_->getLease4(ioaddress4_[1]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[1], l_returned);
-
-
-
- // Delete a lease, check that it's gone, and that we can't delete it
- // a second time.
- EXPECT_TRUE(lmptr_->deleteLease(ioaddress4_[1]));
- l_returned = lmptr_->getLease4(ioaddress4_[1]);
- EXPECT_FALSE(l_returned);
- EXPECT_FALSE(lmptr_->deleteLease(ioaddress4_[1]));
-
- // Check that the second address is still there.
- l_returned = lmptr_->getLease4(ioaddress4_[2]);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[2], l_returned);
-
+ testLease4NullClientId();
}
/// @brief Verify that too long hostname for Lease4 is not accepted.
diff --git a/src/lib/dhcpsrv/tests/test_utils.cc b/src/lib/dhcpsrv/tests/test_utils.cc
index cf7a61f..06d10fc 100644
--- a/src/lib/dhcpsrv/tests/test_utils.cc
+++ b/src/lib/dhcpsrv/tests/test_utils.cc
@@ -526,6 +526,75 @@ GenericLeaseMgrTest::testGetLease4NullClientId() {
}
void
+GenericLeaseMgrTest::testLease4NullClientId() {
+ // Get the leases to be used for the test.
+ vector<Lease4Ptr> leases = createLeases4();
+
+ // Let's clear client-id pointers
+ leases[1]->client_id_ = ClientIdPtr();
+ leases[2]->client_id_ = ClientIdPtr();
+ leases[3]->client_id_ = ClientIdPtr();
+
+ // 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();
+
+ Lease4Ptr l_returned = lmptr_->getLease4(ioaddress4_[1]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[1], l_returned);
+
+ l_returned = lmptr_->getLease4(ioaddress4_[2]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[2], l_returned);
+
+ l_returned = lmptr_->getLease4(ioaddress4_[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]));
+
+ // Check that we can get the lease by HWAddr
+ HWAddr tmp(leases[2]->hwaddr_, HTYPE_ETHER);
+ Lease4Collection returned = lmptr_->getLease4(tmp);
+ ASSERT_EQ(1, returned.size());
+ detailCompareLease(leases[2], *returned.begin());
+
+ l_returned = lmptr_->getLease4(tmp, leases[2]->subnet_id_);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[2], l_returned);
+
+ // Check that we can update the lease
+ // Modify some fields in lease 1 (not the address) and update it.
+ ++leases[1]->subnet_id_;
+ leases[1]->valid_lft_ *= 2;
+ lmptr_->updateLease4(leases[1]);
+
+ // ... and check that the lease is indeed updated
+ l_returned = lmptr_->getLease4(ioaddress4_[1]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[1], l_returned);
+
+ // Delete a lease, check that it's gone, and that we can't delete it
+ // a second time.
+ EXPECT_TRUE(lmptr_->deleteLease(ioaddress4_[1]));
+ l_returned = lmptr_->getLease4(ioaddress4_[1]);
+ EXPECT_FALSE(l_returned);
+ EXPECT_FALSE(lmptr_->deleteLease(ioaddress4_[1]));
+
+ // Check that the second address is still there.
+ l_returned = lmptr_->getLease4(ioaddress4_[2]);
+ ASSERT_TRUE(l_returned);
+ detailCompareLease(leases[2], l_returned);
+}
+
+void
GenericLeaseMgrTest::testGetLease4HWAddr() {
// Let's initialize two different leases 4 and just add the first ...
Lease4Ptr leaseA = initializeLease4(straddress4_[5]);
diff --git a/src/lib/dhcpsrv/tests/test_utils.h b/src/lib/dhcpsrv/tests/test_utils.h
index 9d93a2f..d159c32 100644
--- a/src/lib/dhcpsrv/tests/test_utils.h
+++ b/src/lib/dhcpsrv/tests/test_utils.h
@@ -127,6 +127,15 @@ public:
/// @brief Test lease retrieval using client id, HW address and subnet id.
void testGetLease4ClientIdHWAddrSubnetId();
+ /// @brief Basic Lease4 Checks
+ ///
+ /// 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)
+ ///
+ /// @todo: check if it does overlap with @ref testGetLease4NullClientId()
+ void testLease4NullClientId();
+
/// @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