From a57caf1de359e84f6bc3575e1736dec848d496c7 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Tue, 17 Jan 2023 19:32:08 +0200 Subject: [PATCH] [#1958] fixed unrelated compilation warning --- src/lib/dhcp/tests/packet_queue_testutils.h | 15 +++++----- .../dhcpsrv/tests/alloc_engine6_unittest.cc | 28 +++++++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/lib/dhcp/tests/packet_queue_testutils.h b/src/lib/dhcp/tests/packet_queue_testutils.h index 211b8cbf44..f06ae8cf34 100644 --- a/src/lib/dhcp/tests/packet_queue_testutils.h +++ b/src/lib/dhcp/tests/packet_queue_testutils.h @@ -18,7 +18,8 @@ namespace isc { namespace dhcp { namespace test { -template void checkInfo(PacketQueuePtrType queue, const std::string& exp_json) { +template +void checkInfo(PacketQueuePtrType queue, const std::string& exp_json) { ASSERT_TRUE(queue) << "packet queue ptr is null"; // Fetch the queue info and verify it has all the expected values. data::ElementPtr info; @@ -38,8 +39,8 @@ template void checkInfo(PacketQueuePtrType queue, c } -template void checkIntStat(PacketQueuePtrType queue, - const std::string& name, size_t exp_value) { +template +void checkIntStat(PacketQueuePtrType queue, const std::string& name, size_t exp_value) { ASSERT_TRUE(queue) << "packet queue ptr is null"; data::ElementPtr info; ASSERT_NO_THROW(info = queue->getInfo()); @@ -49,15 +50,15 @@ template void checkIntStat(PacketQueuePtrType queue ASSERT_NO_THROW(elem = info->get(name)) << "stat: " << name << " not in info" << std::endl; ASSERT_TRUE(elem); - int64_t value; + int64_t value = 0; ASSERT_NO_THROW(value = elem->intValue()); EXPECT_EQ(exp_value, value) << "stat: " << name << " is wrong" << std::endl;; } extern data::ElementPtr makeQueueConfig(const std::string& queue_type, size_t capacity, bool enable_queue=true); -}; // end of namespace isc::dhcp::test -}; // end of namespace isc::dhcp -}; // end of namespace isc +} // namespace test +} // namespace dhcp +} // namespace isc #endif // PACKET_QUEUE_TESTUTILS_H diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index c8e6a91a7e..f34bfcb815 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -2130,6 +2130,7 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrSmaller) { subnet_->addPool(pool2); // We should have got exactly one lease. + // Even though the hint is from the first pool, the second pool is preferred. Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:2::"), false, true, 92); ASSERT_EQ(1, leases.size()); @@ -2153,14 +2154,14 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrExistingLeaseInsteadOfSmaller) { subnet_->addPool(pool2); // Let's create a lease and put it in the LeaseMgr - // Even if the the prefix length in the hint does not match, the allocation + // Even if the prefix length in the hint does not match, the allocation // engine should use the existing lease. Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"), - duid_, iaid_, 501, 502, subnet_->getID(), HWAddrPtr(), 96)); + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 96)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // We should have got exactly one lease. - Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:2::"), + Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:3::"), false, true, 92); ASSERT_EQ(1, leases.size()); } @@ -2182,6 +2183,7 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrEqual) { subnet_->addPool(pool2); // We should have got exactly one lease. + // Even though the hint is from the first pool, the second pool is preferred. Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:2::"), false, true, 80); ASSERT_EQ(1, leases.size()); @@ -2205,14 +2207,14 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrExistingLeaseInsteadOfEqual) { subnet_->addPool(pool2); // Let's create a lease and put it in the LeaseMgr - // Even if the the prefix length in the hint does not match, the allocation + // Even if the prefix length in the hint does not match, the allocation // engine should use the existing lease. Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"), - duid_, iaid_, 501, 502, subnet_->getID(), HWAddrPtr(), 96)); + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 96)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // We should have got exactly one lease. - Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:2::"), + Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:3::"), false, true, 80); ASSERT_EQ(1, leases.size()); } @@ -2234,7 +2236,9 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrGreater) { subnet_->addPool(pool2); // We should have got exactly one lease. - Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:3::"), + // Even though the first pool also matches the condition, because of the hint, + // the second pool is preferred. + Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:3::"), false, true, 64); ASSERT_EQ(1, leases.size()); } @@ -2257,14 +2261,14 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrExistingLeaseInsteadOfGreater) { subnet_->addPool(pool2); // Let's create a lease and put it in the LeaseMgr - // Even if the lease is owned by the client, the non-matching prefix length - // in the hint should force allocation of other lease. - Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), - duid_, iaid_, 5001, 502, subnet_->getID(), HWAddrPtr(), 80)); + // Even if the prefix length in the hint does not match, the allocation + // engine should use the existing lease. + Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"), + duid_, iaid_, 300, 400, subnet_->getID(), HWAddrPtr(), 96)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used)); // We should have got exactly one lease. - Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:3::"), + Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:3::"), false, true, 64); ASSERT_EQ(1, leases.size()); }