EXPECT_EQ(0., r);
}
+// Test that the allocator still works with a single pool of a single address.
+TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolSingleAddress) {
+ FreeLeaseQueueAllocator alloc(Lease::TYPE_V4, subnet_);
+
+ subnet_->delPools(Lease::TYPE_V4);
+ auto addr = IOAddress("192.0.2.10");
+ auto pool = boost::make_shared<Pool4>(addr, addr);
+ subnet_->addPool(pool);
+
+ ASSERT_NO_THROW(alloc.initAfterConfigure());
+
+ // The unique address is returned.
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")));
+ // Forever...
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")));
+
+ // Create and add the lease for the address.
+ auto lease = createLease4(addr, 0);
+ EXPECT_TRUE(LeaseMgrFactory::instance().addLease(lease));
+
+ // Now the address is busy,
+ auto candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0"));
+ EXPECT_TRUE(candidate.isV4Zero());
+
+ double r = alloc.getOccupancyRate(addr, cc_);
+ EXPECT_EQ(1., r);
+}
+
// Test that the allocator respects client class guards.
TEST_F(FreeLeaseQueueAllocatorTest4, clientClasses) {
FreeLeaseQueueAllocator alloc(Lease::TYPE_V4, subnet_);
EXPECT_TRUE(candidate.isV6Zero());
}
+// Test that the allocator still works with a single pool of a single address.
+TEST_F(FreeLeaseQueueAllocatorTest6, singlePoolSingleAddress) {
+ FreeLeaseQueueAllocator alloc(Lease::TYPE_NA, subnet_);
+
+ subnet_->delPools(Lease::TYPE_NA);
+ auto addr = IOAddress("2001:db8:1::1");
+ auto pool = boost::make_shared<Pool6>(Lease::TYPE_NA, addr, addr);
+ subnet_->addPool(pool);
+
+ ASSERT_NO_THROW(alloc.initAfterConfigure());
+
+ // The unique address is returned.
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, duid_, IOAddress("::")));
+ // Forever...
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, duid_, IOAddress("::")));
+
+ // Create and add the lease for the address.
+ auto lease = createLease6(Lease::TYPE_NA, addr, 0);
+ EXPECT_TRUE(LeaseMgrFactory::instance().addLease(lease));
+
+ // Now the address is busy,
+ auto candidate = alloc.pickAddress(cc_, duid_, IOAddress("::"));
+ EXPECT_TRUE(candidate.isV6Zero());
+}
+
// Test that the allocator respects client class guards.
TEST_F(FreeLeaseQueueAllocatorTest6, clientClasses) {
FreeLeaseQueueAllocator alloc(Lease::TYPE_NA, subnet_);
EXPECT_EQ((assigned ? 2560. : 2561.) / 68096., r);
}
+// Test that the allocator still works with a single pd pool of a single prefix.
+TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolSinglePrefix) {
+ FreeLeaseQueueAllocator alloc(Lease::TYPE_PD, subnet_);
+
+ subnet_->delPools(Lease::TYPE_PD);
+ auto addr = IOAddress("3000::");
+ auto pool = boost::make_shared<Pool6>(Lease::TYPE_PD, addr, 120, 120);
+ subnet_->addPool(pool);
+
+ ASSERT_NO_THROW(alloc.initAfterConfigure());
+
+ // The unique prefix is returned.
+ EXPECT_EQ(addr, alloc.pickPrefix(cc_, pool, duid_,
+ Allocator::PREFIX_LEN_HIGHER,
+ IOAddress("::"), 0));
+ // Forever...
+ EXPECT_EQ(addr, alloc.pickPrefix(cc_, pool, duid_,
+ Allocator::PREFIX_LEN_HIGHER,
+ IOAddress("::"), 0));
+
+ // Create and add the lease for the prefix.
+ auto lease = createLease6(Lease::TYPE_PD, addr, 0);
+ EXPECT_TRUE(LeaseMgrFactory::instance().addLease(lease));
+
+ // Now the prefix is busy,
+ auto candidate = alloc.pickPrefix(cc_, pool, duid_,
+ Allocator::PREFIX_LEN_HIGHER,
+ IOAddress("::"), 0);
+ EXPECT_TRUE(candidate.isV6Zero());
+
+ double r = alloc.getOccupancyRate(addr, 128, cc_);
+ EXPECT_EQ(1., r);
+}
+
// Test that the allocator respects client class guards.
TEST_F(FreeLeaseQueueAllocatorTest6, pdPoolsClientClasses) {
FreeLeaseQueueAllocator alloc(Lease::TYPE_PD, subnet_);
EXPECT_TRUE(candidate.isV4Zero());
}
+// Test that the allocator still works with a single pool of a single address.
+TEST_F(RandomAllocatorTest4, singlePoolSingleAddress) {
+ RandomAllocator alloc(Lease::TYPE_V4, subnet_);
+
+ subnet_->delPools(Lease::TYPE_V4);
+ auto addr = IOAddress("192.0.2.10");
+ auto pool = boost::make_shared<Pool4>(addr, addr);
+ subnet_->addPool(pool);
+
+ // The unique address is returned.
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")));
+ // Forever...
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")));
+}
+
// Test that the allocator respects client classes while it picks
// pools and addresses.
TEST_F(RandomAllocatorTest4, clientClasses) {
}
}
+// Test that the allocator still works with a single pool of a single address.
+TEST_F(RandomAllocatorTest6, singlePoolSingleAddress) {
+ RandomAllocator alloc(Lease::TYPE_NA, subnet_);
+
+ subnet_->delPools(Lease::TYPE_NA);
+ auto addr = IOAddress("2001:db8:1::1");
+ auto pool = boost::make_shared<Pool6>(Lease::TYPE_NA, addr, addr);
+ subnet_->addPool(pool);
+
+ // The unique address is returned.
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, duid_, IOAddress("::")));
+ // Forever...
+ EXPECT_EQ(addr, alloc.pickAddress(cc_, duid_, IOAddress("::")));
+}
+
// Test that the allocator respects client classes while it picks
// pools and addresses.
TEST_F(RandomAllocatorTest6, clientClasses) {
EXPECT_EQ(65536, prefixes.size());
}
+// Test that the allocator still works with a single pd pool of a single prefix.
+TEST_F(RandomAllocatorTest6, singlePdPoolSinglePrefix) {
+ RandomAllocator alloc(Lease::TYPE_PD, subnet_);
+
+ subnet_->delPools(Lease::TYPE_PD);
+ auto addr = IOAddress("3000::");
+ auto pool = boost::make_shared<Pool6>(Lease::TYPE_PD, addr, 120, 120);
+ subnet_->addPool(pool);
+
+ // The unique prefix is returned.
+ EXPECT_EQ(addr, alloc.pickPrefix(cc_, pool, duid_,
+ Allocator::PREFIX_LEN_HIGHER,
+ IOAddress("::"), 0));
+ // Forever...
+ EXPECT_EQ(addr, alloc.pickPrefix(cc_, pool, duid_,
+ Allocator::PREFIX_LEN_HIGHER,
+ IOAddress("::"), 0));
+}
+
// Test allocating delegated prefixes from multiple pools.
TEST_F(RandomAllocatorTest6, manyPdPools) {
RandomAllocator alloc(Lease::TYPE_PD, subnet_);