BIND 10 trac3171, updated. a282ac7153171ac4445c6b6eb2220937d097fd74 [3171] checkLease6() and checkPDLease6() unified
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Sep 20 13:37:47 UTC 2013
The branch, trac3171 has been updated
via a282ac7153171ac4445c6b6eb2220937d097fd74 (commit)
via 8ed4c169acd688c7d9389991272c2e699a4dd8fc (commit)
from 3e08c03f168623554f4dac564cbfd4bc5160bf76 (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 a282ac7153171ac4445c6b6eb2220937d097fd74
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Fri Sep 20 15:37:33 2013 +0200
[3171] checkLease6() and checkPDLease6() unified
commit 8ed4c169acd688c7d9389991272c2e699a4dd8fc
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Fri Sep 20 15:08:22 2013 +0200
[3171] All dhcpsrv unit-tests now pass.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dhcpsrv/subnet.cc | 20 ++--------
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc | 50 ++++++++----------------
src/lib/dhcpsrv/tests/subnet_unittest.cc | 12 +++---
3 files changed, 25 insertions(+), 57 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc
index 44aafe7..eafa795 100644
--- a/src/lib/dhcpsrv/subnet.cc
+++ b/src/lib/dhcpsrv/subnet.cc
@@ -169,28 +169,15 @@ const PoolCollection& Subnet::getPools(Lease::Type type) const {
}
PoolCollection& Subnet::getPools(Lease::Type type) {
- switch (type) {
- case Lease::TYPE_V4:
- case Lease::TYPE_NA:
- return (pools_);
- case Lease::TYPE_TA:
- return (pools_);
- case Lease::TYPE_PD:
- return (pools_pd_);
- default:
- isc_throw(BadValue, "Invalid pool type specified: "
- << static_cast<int>(type));
- }
-}
+ // check if the type is valid (and throw if it isn't)
+ checkType(type);
-#if 0
-const PoolCollection& Subnet::getConstPools(Lease::Type type) const {
switch (type) {
case Lease::TYPE_V4:
case Lease::TYPE_NA:
return (pools_);
case Lease::TYPE_TA:
- return (pools_);
+ return (pools_ta_);
case Lease::TYPE_PD:
return (pools_pd_);
default:
@@ -198,7 +185,6 @@ const PoolCollection& Subnet::getConstPools(Lease::Type type) const {
<< static_cast<int>(type));
}
}
-#endif
PoolPtr Subnet::getPool(Lease::Type type, isc::asiolink::IOAddress hint,
bool anypool /* true */) {
diff --git a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
index 54f417b..9204f2e 100644
--- a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+++ b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
@@ -123,42 +123,24 @@ public:
/// @brief checks if Lease6 matches expected configuration
///
/// @param lease lease to be checked
- void checkLease6(const Lease6Ptr& lease) {
- // that is belongs to the right subnet
- EXPECT_EQ(lease->subnet_id_, subnet_->getID());
- EXPECT_TRUE(subnet_->inRange(lease->addr_));
- EXPECT_TRUE(subnet_->inPool(Lease::TYPE_NA, lease->addr_));
-
- // that it have proper parameters
- EXPECT_EQ(iaid_, lease->iaid_);
- EXPECT_EQ(subnet_->getValid(), lease->valid_lft_);
- EXPECT_EQ(subnet_->getPreferred(), lease->preferred_lft_);
- EXPECT_EQ(subnet_->getT1(), lease->t1_);
- EXPECT_EQ(subnet_->getT2(), lease->t2_);
- EXPECT_EQ(128, lease->prefixlen_); // this is IA_NA, not IA_PD
- EXPECT_TRUE(false == lease->fqdn_fwd_);
- EXPECT_TRUE(false == lease->fqdn_rev_);
- EXPECT_TRUE(*lease->duid_ == *duid_);
- // @todo: check cltt
- }
+ /// @param exp_type expected lease type
+ /// @param exp_pd_len expected prefix length
+ void checkLease6(const Lease6Ptr& lease, Lease::Type exp_type,
+ uint8_t exp_pd_len = 128) {
- /// @brief checks if Lease6 PD matches expected configuration
- ///
- /// @param lease lease to be checked
- void checkPDLease6(const Lease6Ptr& lease, uint8_t expected_pd_len) {
// that is belongs to the right subnet
EXPECT_EQ(lease->subnet_id_, subnet_->getID());
EXPECT_TRUE(subnet_->inRange(lease->addr_));
- EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, lease->addr_));
+ EXPECT_TRUE(subnet_->inPool(exp_type, lease->addr_));
// that it have proper parameters
+ EXPECT_EQ(exp_type, lease->type_);
EXPECT_EQ(iaid_, lease->iaid_);
EXPECT_EQ(subnet_->getValid(), lease->valid_lft_);
EXPECT_EQ(subnet_->getPreferred(), lease->preferred_lft_);
EXPECT_EQ(subnet_->getT1(), lease->t1_);
EXPECT_EQ(subnet_->getT2(), lease->t2_);
-
- EXPECT_EQ(expected_pd_len, lease->prefixlen_); // IA_PD
+ EXPECT_EQ(exp_pd_len, lease->prefixlen_); // this is IA_NA, not IA_PD
EXPECT_TRUE(false == lease->fqdn_fwd_);
EXPECT_TRUE(false == lease->fqdn_rev_);
EXPECT_TRUE(*lease->duid_ == *duid_);
@@ -300,7 +282,7 @@ TEST_F(AllocEngine6Test, simpleAlloc6) {
ASSERT_TRUE(lease);
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -334,7 +316,7 @@ TEST_F(AllocEngine6Test, pdSimpleAlloc6) {
EXPECT_EQ(Lease::TYPE_PD, lease->type_);
// Do all checks on the PD lease
- checkPDLease6(lease, pd_pool->getLength());
+ checkLease6(lease, Lease::TYPE_PD, pd_pool->getLength());
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -360,7 +342,7 @@ TEST_F(AllocEngine6Test, fakeAlloc6) {
ASSERT_TRUE(lease);
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is NOT in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -388,7 +370,7 @@ TEST_F(AllocEngine6Test, allocWithValidHint6) {
EXPECT_EQ(lease->addr_.toText(), "2001:db8:1::15");
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -431,7 +413,7 @@ TEST_F(AllocEngine6Test, allocWithUsedHint6) {
EXPECT_TRUE(lease->addr_.toText() != "2001:db8:1::1f");
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -464,7 +446,7 @@ TEST_F(AllocEngine6Test, allocBogusHint6) {
EXPECT_TRUE(lease->addr_.toText() != "3000::abc");
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -748,7 +730,7 @@ TEST_F(AllocEngine6Test, smallPool6) {
EXPECT_EQ("2001:db8:1::ad", lease->addr_.toText());
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
@@ -830,7 +812,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
EXPECT_EQ(addr.toText(), lease->addr_.toText());
// Do all checks on the lease (if subnet-id, preferred/valid times are ok etc.)
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// CASE 2: Asking specifically for this address
EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
@@ -1591,7 +1573,7 @@ TEST_F(HookAllocEngine6Test, lease6_select) {
ASSERT_TRUE(lease);
// Do all checks on the lease
- checkLease6(lease);
+ checkLease6(lease, Lease::TYPE_NA, 128);
// Check that the lease is indeed in LeaseMgr
Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(lease->type_,
diff --git a/src/lib/dhcpsrv/tests/subnet_unittest.cc b/src/lib/dhcpsrv/tests/subnet_unittest.cc
index d8497d6..0af8191 100644
--- a/src/lib/dhcpsrv/tests/subnet_unittest.cc
+++ b/src/lib/dhcpsrv/tests/subnet_unittest.cc
@@ -609,27 +609,27 @@ TEST(Subnet6Test, inRangeinPool) {
// 192.1.1.1 belongs to the subnet...
EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::1")));
// ... but it does not belong to any pool within
- EXPECT_FALSE(subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::1")));
+ EXPECT_FALSE(subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::1")));
// the last address that is in range, but out of pool
EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::f")));
- EXPECT_FALSE(subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::f")));
+ EXPECT_FALSE(subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::f")));
// the first address that is in range, in pool
EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::10")));
- EXPECT_TRUE (subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::10")));
+ EXPECT_TRUE (subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::10")));
// let's try something in the middle as well
EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::18")));
- EXPECT_TRUE (subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::18")));
+ EXPECT_TRUE (subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::18")));
// the last address that is in range, in pool
EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::20")));
- EXPECT_TRUE (subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::20")));
+ EXPECT_TRUE (subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::20")));
// the first address that is in range, but out of pool
EXPECT_TRUE(subnet->inRange(IOAddress("2001:db8::21")));
- EXPECT_FALSE(subnet->inPool(Lease::TYPE_V4, IOAddress("2001:db8::21")));
+ EXPECT_FALSE(subnet->inPool(Lease::TYPE_NA, IOAddress("2001:db8::21")));
}
// This test checks if the toText() method returns text representation
More information about the bind10-changes
mailing list