|
@@ -22,6 +22,8 @@
|
|
|
#include <dhcpsrv/lease_mgr_factory.h>
|
|
|
#include <dhcpsrv/memfile_lease_mgr.h>
|
|
|
|
|
|
+#include <dhcpsrv/tests/test_utils.h>
|
|
|
+
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
#include <gtest/gtest.h>
|
|
@@ -35,6 +37,7 @@ using namespace std;
|
|
|
using namespace isc;
|
|
|
using namespace isc::asiolink;
|
|
|
using namespace isc::dhcp;
|
|
|
+using namespace isc::dhcp::test;
|
|
|
|
|
|
namespace {
|
|
|
|
|
@@ -108,26 +111,6 @@ TEST_F(AllocEngineTest, constructor) {
|
|
|
ASSERT_NO_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
|
}
|
|
|
|
|
|
-/// @todo: This method is taken from mysql_lease_mgr_utilities.cc from ticket
|
|
|
-/// #2342. Get rid of one instance once the code is merged
|
|
|
-void
|
|
|
-detailCompareLease6(const Lease6Ptr& first, const Lease6Ptr& second) {
|
|
|
- EXPECT_EQ(first->type_, second->type_);
|
|
|
-
|
|
|
- // Compare address strings - odd things happen when they are different
|
|
|
- // as the EXPECT_EQ appears to call the operator uint32_t() function,
|
|
|
- // which causes an exception to be thrown for IPv6 addresses.
|
|
|
- EXPECT_EQ(first->addr_.toText(), second->addr_.toText());
|
|
|
- EXPECT_EQ(first->prefixlen_, second->prefixlen_);
|
|
|
- EXPECT_EQ(first->iaid_, second->iaid_);
|
|
|
- EXPECT_TRUE(*first->duid_ == *second->duid_);
|
|
|
- EXPECT_EQ(first->preferred_lft_, second->preferred_lft_);
|
|
|
- EXPECT_EQ(first->valid_lft_, second->valid_lft_);
|
|
|
- EXPECT_EQ(first->cltt_, second->cltt_);
|
|
|
- EXPECT_EQ(first->subnet_id_, second->subnet_id_);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
// This test checks if the simple allocation can succeed
|
|
|
TEST_F(AllocEngineTest, simpleAlloc) {
|
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
@@ -148,7 +131,7 @@ TEST_F(AllocEngineTest, simpleAlloc) {
|
|
|
ASSERT_TRUE(from_mgr);
|
|
|
|
|
|
// Now check that the lease in LeaseMgr has the same parameters
|
|
|
- detailCompareLease6(lease, from_mgr);
|
|
|
+ detailCompareLease(lease, from_mgr);
|
|
|
}
|
|
|
|
|
|
// This test checks if the fake allocation (for SOLICIT) can succeed
|
|
@@ -196,7 +179,7 @@ TEST_F(AllocEngineTest, allocWithValidHint) {
|
|
|
ASSERT_TRUE(from_mgr);
|
|
|
|
|
|
// Now check that the lease in LeaseMgr has the same parameters
|
|
|
- detailCompareLease6(lease, from_mgr);
|
|
|
+ detailCompareLease(lease, from_mgr);
|
|
|
}
|
|
|
|
|
|
// This test checks if the allocation with a hint that is in range,
|
|
@@ -235,7 +218,7 @@ TEST_F(AllocEngineTest, allocWithUsedHint) {
|
|
|
ASSERT_TRUE(from_mgr);
|
|
|
|
|
|
// Now check that the lease in LeaseMgr has the same parameters
|
|
|
- detailCompareLease6(lease, from_mgr);
|
|
|
+ detailCompareLease(lease, from_mgr);
|
|
|
}
|
|
|
|
|
|
// This test checks if the allocation with a hint that is out the blue
|
|
@@ -265,7 +248,7 @@ TEST_F(AllocEngineTest, allocBogusHint) {
|
|
|
ASSERT_TRUE(from_mgr);
|
|
|
|
|
|
// Now check that the lease in LeaseMgr has the same parameters
|
|
|
- detailCompareLease6(lease, from_mgr);
|
|
|
+ detailCompareLease(lease, from_mgr);
|
|
|
}
|
|
|
|
|
|
// This test verifies that the allocator picks addresses that belong to the
|
|
@@ -370,7 +353,7 @@ TEST_F(AllocEngineTest, smallPool) {
|
|
|
ASSERT_TRUE(from_mgr);
|
|
|
|
|
|
// Now check that the lease in LeaseMgr has the same parameters
|
|
|
- detailCompareLease6(lease, from_mgr);
|
|
|
+ detailCompareLease(lease, from_mgr);
|
|
|
}
|
|
|
|
|
|
// This test checks if all addresses in a pool are currently used, the attempt
|
|
@@ -487,7 +470,7 @@ TEST_F(AllocEngineTest, requestReuseExpiredLease) {
|
|
|
ASSERT_TRUE(from_mgr);
|
|
|
|
|
|
// Now check that the lease in LeaseMgr has the same parameters
|
|
|
- detailCompareLease6(lease, from_mgr);
|
|
|
+ detailCompareLease(lease, from_mgr);
|
|
|
}
|
|
|
|
|
|
}; // end of anonymous namespace
|