From ee25dc7dba8726cb95c75e6fbccc6ed156f0d75e Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Sun, 19 Jul 2015 11:14:33 +0200 Subject: [PATCH] [3958] Extra test for large (80 bits pool) configuration implemented. --- .../dhcpsrv/tests/alloc_engine6_unittest.cc | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index cf10138f4e..b146638278 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -1587,6 +1587,29 @@ TEST_F(AllocEngine6Test, largePDPool) { ASSERT_EQ(1, leases.size()); } +// This test checks that the allocation engine can delegate addresses +// from ridiculously large pool. The configuration provides 2^80 or +// 1208925819614629174706176 addresses. We used to have a bug that would +// confuse the allocation engine if the number of available addresses +// was larger than 2^32. +TEST_F(AllocEngine6Test, largePoolOver32bits) { + AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + + // Configure 2001:db8::/32 subnet + subnet_.reset(new Subnet6(IOAddress("2001:db8::"), 32, 1, 2, 3, 4)); + + // Configure the NA pool of /48. So there are 2^80 addresses there. Make + // sure that we still can handle cases where number of available addresses + // is over max_uint64 + Pool6Ptr pool(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::"), 48)); + subnet_->addPool(pool); + + // We should have got exactly one lease. + Lease6Collection leases = allocateTest(engine, pool, IOAddress("::"), + false, true); + ASSERT_EQ(1, leases.size()); +} + }; // namespace test }; // namespace dhcp }; // namespace isc -- 2.47.2