factory_.create("type=memfile universe=6 persist=false");
}
+void
+AllocEngine6Test::initSubnet(const asiolink::IOAddress& subnet,
+ const asiolink::IOAddress& pool_start,
+ const asiolink::IOAddress& pool_end) {
+ CfgMgr& cfg_mgr = CfgMgr::instance();
+
+ subnet_ = Subnet6Ptr(new Subnet6(subnet, 56, 1, 2, 3, 4));
+ pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, pool_start, pool_end));
+
+ subnet_->addPool(pool_);
+
+ pd_pool_ = Pool6Ptr(new Pool6(Lease::TYPE_PD, subnet, 56, 64));
+ subnet_->addPool(pd_pool_);
+
+ cfg_mgr.getStagingCfg()->getCfgSubnets6()->add(subnet_);
+ cfg_mgr.commit();
+}
+
Lease6Collection
AllocEngine6Test::allocateTest(AllocEngine& engine, const Pool6Ptr& pool,
const asiolink::IOAddress& hint, bool fake,
if (!from_mgr) {
return (leases);
}
-
+
// Now check that the lease in LeaseMgr has the same parameters
detailCompareLease(*it, from_mgr);
} else {
}
}
}
-
+
return (leases);
}
false, false, "", fake);
EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLeases6(ctx)));
-
+
// Check that we got a lease
EXPECT_TRUE(lease);
if (!lease) {
Lease6Ptr used(new Lease6(type, used_addr,
duid2, 1, 2, 3, 4, now, subnet_->getID()));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
-
+
// Another client comes in and request an address that is in pool, but
// unfortunately it is used already. The same address must not be allocated
// twice.
AllocEngine::ClientContext6 ctx(subnet_, duid_, iaid_, requested, type,
false, false, "", false);
EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLeases6(ctx)));
-
+
// Check that we got a lease
ASSERT_TRUE(lease);
-
+
// Allocated address must be different
EXPECT_NE(used_addr, lease->addr_);
AllocEngine4Test::initSubnet(const asiolink::IOAddress& pool_start,
const asiolink::IOAddress& pool_end) {
CfgMgr& cfg_mgr = CfgMgr::instance();
-
+
subnet_ = Subnet4Ptr(new Subnet4(IOAddress("192.0.2.0"), 24, 1, 2, 3));
pool_ = Pool4Ptr(new Pool4(pool_start, pool_end));
subnet_->addPool(pool_);
namespace test {
/// @file alloc_engine_utils.h
-///
+///
/// @brief This is a header file for all Allocation Engine tests.
-///
+///
/// There used to be one, huge (over 3kloc) alloc_engine_unittest.cc. It is now
/// split into serveral smaller files:
/// alloc_engine_utils.h - contains test class definitions (this file)
/// @param pool_end Last address in the address pool.
void initSubnet(const asiolink::IOAddress& subnet,
const asiolink::IOAddress& pool_start,
- const asiolink::IOAddress& pool_end) {
- CfgMgr& cfg_mgr = CfgMgr::instance();
-
- subnet_ = Subnet6Ptr(new Subnet6(subnet, 56, 1, 2, 3, 4));
- pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, pool_start, pool_end));
-
- subnet_->addPool(pool_);
-
- pd_pool_ = Pool6Ptr(new Pool6(Lease::TYPE_PD, subnet, 56, 64));
- subnet_->addPool(pd_pool_);
-
- cfg_mgr.getStagingCfg()->getCfgSubnets6()->add(subnet_);
- cfg_mgr.commit();
-
- }
+ const asiolink::IOAddress& pool_end);
/// @brief Initializes FQDN data for a test.
///