From: Marcin Siodelski Date: Thu, 20 Oct 2022 18:30:19 +0000 (+0200) Subject: [#2348] Removed type from engine constructor X-Git-Tag: Kea-2.3.3~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63b09a9bc2bdf28547b2c2c299d5b631ebac187b;p=thirdparty%2Fkea.git [#2348] Removed type from engine constructor --- diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index fe4a99f1c3..7c1bfb60ae 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -637,8 +637,7 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t server_port, uint16_t client_port, // Instantiate allocation engine. The number of allocation attempts equal // to zero indicates that the allocation engine will use the number of // attempts depending on the pool size. - alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 0, - false /* false = IPv4 */)); + alloc_engine_.reset(new AllocEngine(0, false /* false = IPv4 */)); /// @todo call loadLibraries() when handling configuration changes diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 30e627f39d..36608b90a5 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -240,7 +240,7 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t server_port, uint16_t client_port) // Instantiate allocation engine. The number of allocation attempts equal // to zero indicates that the allocation engine will use the number of // attempts depending on the pool size. - alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 0)); + alloc_engine_.reset(new AllocEngine(0)); /// @todo call loadLibraries() when handling configuration changes diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 327028f238..65aae2d8d5 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -90,7 +90,7 @@ AllocEngineHooks Hooks; namespace isc { namespace dhcp { -AllocEngine::AllocEngine(AllocType, uint64_t attempts, bool ipv6) +AllocEngine::AllocEngine(uint64_t attempts, bool ipv6) : attempts_(attempts), incomplete_v4_reclamations_(0), incomplete_v6_reclamations_(0) { diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h index 6fb9653890..ef4ba1b299 100644 --- a/src/lib/dhcpsrv/alloc_engine.h +++ b/src/lib/dhcpsrv/alloc_engine.h @@ -44,19 +44,9 @@ namespace dhcp { /// This class represents a DHCP allocation engine. It is responsible /// for picking subnets, choosing and allocating a lease, extending, /// renewing, releasing and possibly expiring leases. -/// -/// @todo: Does not handle out of leases well -/// @todo: Does not handle out of allocation attempts well class AllocEngine : public boost::noncopyable { public: - /// @brief Specifies allocation type - typedef enum { - ALLOC_ITERATIVE, // iterative - one address after another - ALLOC_HASHED, // hashed - client's DUID/client-id is hashed - ALLOC_RANDOM // random - an address is randomly selected - } AllocType; - /// @brief Constructor. /// /// Instantiates necessary services, required to run DHCP server. @@ -64,11 +54,10 @@ public: /// network interaction. Will instantiate lease manager, and load /// old or create new DUID. /// - /// @param engine_type selects allocation algorithm /// @param attempts number of attempts for each lease allocation before /// we give up (0 means unlimited) /// @param ipv6 specifies if the engine should work for IPv4 or IPv6 - AllocEngine(AllocType engine_type, uint64_t attempts, bool ipv6 = true); + AllocEngine(uint64_t attempts, bool ipv6 = true); /// @brief Destructor. virtual ~AllocEngine() { } diff --git a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc index 3d857bf4c0..9abc2b7800 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc @@ -48,8 +48,7 @@ TEST_F(AllocEngine4Test, constructor) { // Create V4 (ipv6=false) Allocation Engine that will try at most // 100 attempts to pick up a lease - ASSERT_NO_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100, - false))); + ASSERT_NO_THROW(x.reset(new AllocEngine(100, false))); } // This test checks if two simple IPv4 allocations succeed and that the @@ -64,8 +63,7 @@ TEST_F(AllocEngine4Test, constructor) { // not interfere with the allocation. TEST_F(AllocEngine4Test, simpleAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Assigned addresses should be zero. @@ -151,8 +149,7 @@ TEST_F(AllocEngine4Test, simpleAlloc4) { // This test checks that simple allocation uses the default valid lifetime. TEST_F(AllocEngine4Test, defaultAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -184,8 +181,7 @@ TEST_F(AllocEngine4Test, defaultAlloc4) { // This test checks that simple allocation uses the specified valid lifetime. TEST_F(AllocEngine4Test, hintAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -221,8 +217,7 @@ TEST_F(AllocEngine4Test, hintAlloc4) { // This test checks that simple allocation uses the min valid lifetime. TEST_F(AllocEngine4Test, minAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -259,8 +254,7 @@ TEST_F(AllocEngine4Test, minAlloc4) { // This test checks that simple allocation uses the max valid lifetime. TEST_F(AllocEngine4Test, maxAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -297,8 +291,7 @@ TEST_F(AllocEngine4Test, maxAlloc4) { // This test checks that simple allocation handles BOOTP queries. TEST_F(AllocEngine4Test, bootpAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -340,8 +333,7 @@ TEST_F(AllocEngine4Test, bootpAlloc4) { // This test checks if the fake allocation (for DHCPDISCOVER) can succeed TEST_F(AllocEngine4Test, fakeAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Assigned addresses should be zero. @@ -383,8 +375,7 @@ TEST_F(AllocEngine4Test, fakeAlloc4) { // in pool and free) can succeed TEST_F(AllocEngine4Test, allocWithValidHint4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, @@ -417,8 +408,7 @@ TEST_F(AllocEngine4Test, allocWithValidHint4) { // in pool, but is currently used can succeed TEST_F(AllocEngine4Test, allocWithUsedHint4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Let's create a lease and put it in the LeaseMgr @@ -463,8 +453,7 @@ TEST_F(AllocEngine4Test, allocWithUsedHint4) { // can succeed. The invalid hint should be ignored completely. TEST_F(AllocEngine4Test, allocBogusHint4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Client would like to get a 10.1.1.1 lease, which does not belong to any @@ -495,8 +484,7 @@ TEST_F(AllocEngine4Test, allocBogusHint4) { // This test checks that NULL values are handled properly TEST_F(AllocEngine4Test, allocateLease4Nulls) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Allocations without subnet are not allowed @@ -569,8 +557,7 @@ TEST_F(AllocEngine4Test, allocateLease4Nulls) { // an existing lease and assigned-leases increments accordingly TEST_F(AllocEngine4Test, simpleRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); EXPECT_TRUE(testStatistics("assigned-addresses", 0, subnet_->getID())); @@ -619,8 +606,7 @@ TEST_F(AllocEngine4Test, simpleRenew4) { // This test checks simple renewal uses the default valid lifetime. TEST_F(AllocEngine4Test, defaultRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -657,8 +643,7 @@ TEST_F(AllocEngine4Test, defaultRenew4) { // This test checks simple renewal uses the specified valid lifetime. TEST_F(AllocEngine4Test, hintRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -699,8 +684,7 @@ TEST_F(AllocEngine4Test, hintRenew4) { // This test checks simple renewal uses the min valid lifetime. TEST_F(AllocEngine4Test, minRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -742,8 +726,7 @@ TEST_F(AllocEngine4Test, minRenew4) { // This test checks simple renewal uses the max valid lifetime. TEST_F(AllocEngine4Test, maxRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -785,8 +768,7 @@ TEST_F(AllocEngine4Test, maxRenew4) { // This test checks simple renewal handles BOOTP queries. TEST_F(AllocEngine4Test, bootpRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -843,8 +825,7 @@ TEST_F(AllocEngine4Test, bootpRenew4) { // This test checks if really small pools are working TEST_F(AllocEngine4Test, smallPool4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); IOAddress addr("192.0.2.17"); @@ -888,8 +869,7 @@ TEST_F(AllocEngine4Test, smallPool4) { // to find out a new lease fails. TEST_F(AllocEngine4Test, outOfAddresses4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); IOAddress addr("192.0.2.17"); @@ -949,7 +929,7 @@ public: /// @brief Initializes configuration (2 subnets, 1 shared network) SharedNetworkAlloc4Test() - :engine_(AllocEngine::ALLOC_ITERATIVE, 0, false) { + :engine_(0, false) { // Create two subnets, each with a single address pool. The first subnet // has only one address in its address pool to make it easier to simulate // address exhaustion. @@ -1603,8 +1583,7 @@ TEST_F(SharedNetworkAlloc4Test, requestSharedNetworkReservationsNoColl) { // allocation) TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); IOAddress addr("192.0.2.15"); @@ -1672,8 +1651,7 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) { // This test checks if an expired lease can be reused in REQUEST (actual allocation) TEST_F(AllocEngine4Test, requestReuseExpiredLease4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); IOAddress addr("192.0.2.105"); @@ -1742,8 +1720,7 @@ TEST_F(AllocEngine4Test, requestReuseExpiredLease4) { // to DHCPDISCOVER (fake allocation) TEST_F(AllocEngine4Test, discoverReuseDeclinedLease4) { - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false)); + AllocEnginePtr engine(new AllocEngine( 0, false)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -1780,8 +1757,7 @@ TEST_F(AllocEngine4Test, discoverReuseDeclinedLease4) { TEST_F(AllocEngine4Test, discoverReuseDeclinedLease4Stats) { // Now prepare for DISCOVER processing - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false)); + AllocEnginePtr engine(new AllocEngine( 0, false)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -1821,8 +1797,7 @@ TEST_F(AllocEngine4Test, discoverReuseDeclinedLease4Stats) { // to REQUEST (actual allocation) TEST_F(AllocEngine4Test, requestReuseDeclinedLease4) { - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false)); + AllocEnginePtr engine(new AllocEngine( 0, false)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -1857,8 +1832,7 @@ TEST_F(AllocEngine4Test, requestReuseDeclinedLease4) { // is reused when responding to DHCPREQUEST (actual allocation) TEST_F(AllocEngine4Test, requestReuseDeclinedLease4Stats) { - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false)); + AllocEnginePtr engine(new AllocEngine( 0, false)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -1908,7 +1882,7 @@ TEST_F(AllocEngine4Test, identifyClientLease) { 100, time(NULL), subnet_->getID())); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress::IPV4_ZERO_ADDRESS(), false, false, "", true); @@ -1987,7 +1961,7 @@ TEST_F(AllocEngine4Test, requestOtherClientLease) { LeaseMgrFactory::instance().addLease(lease); LeaseMgrFactory::instance().addLease(lease2); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // First client requests the lease which belongs to the second client. AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("192.0.2.102"), @@ -2037,7 +2011,7 @@ TEST_F(AllocEngine4Test, reservedAddressNoHint) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Try to allocate a lease without specifying a hint. This is actually // incorrect behavior of the client to not send an address it wants to @@ -2076,7 +2050,7 @@ TEST_F(AllocEngine4Test,reservedAddressNoHintFakeAllocation) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Query allocation engine for the lease to be assigned to this // client without specifying the address to be assigned. @@ -2117,7 +2091,7 @@ TEST_F(AllocEngine4Test, reservedAddressHint) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); AllocEngine::ClientContext4 ctx1(subnet_, clientid_, hwaddr_, IOAddress("192.0.2.234"), false, false, @@ -2178,7 +2152,7 @@ TEST_F(AllocEngine4Test, reservedAddressHintFakeAllocation) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Query the allocation engine for the lease to be assigned to the client // and specify a hint being a different address than the reserved one. @@ -2226,7 +2200,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLease) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Request allocation of the reserved address. AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, @@ -2275,7 +2249,7 @@ TEST_F(AllocEngine4Test, reservedAddressHijacked) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Try to allocate the reserved lease to client B. AllocEngine::ClientContext4 ctx1(subnet_, clientid_, hwaddr_, @@ -2356,7 +2330,7 @@ TEST_F(AllocEngine4Test, reservedAddressHijackedFakeAllocation) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Query allocation engine for the lease to be allocated to the client B. // The allocation engine is not able to allocate the lease to the client @@ -2415,7 +2389,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseInvalidHint) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Try to allocate a lease and specify a different address than reserved // and different from the one that client is currently using. @@ -2495,7 +2469,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseFakeAllocation) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Try to allocate a lease and use a completely different address // as a hint. @@ -2560,7 +2534,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseNoHint) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Try to allocate a lease with providing no hint. AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, @@ -2612,7 +2586,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseNoHintFakeAllocation) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Query the allocation engine for the lease to be allocated for the // client. @@ -2674,7 +2648,7 @@ TEST_F(AllocEngine4Test, reservedAddressConflictResolution) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Client B sends a DHCPREQUEST to allocate a reserved lease. The // allocation engine can't allocate a reserved lease for this client @@ -2780,7 +2754,7 @@ TEST_F(AllocEngine4Test, reservedAddressVsDynamicPool) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Different client tries to allocate a lease. Note, that we're using // an iterative allocator which would pick the first address from the @@ -2812,7 +2786,7 @@ TEST_F(AllocEngine4Test, reservedAddressHintUsedByOtherClient) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Different client is requesting this address. AllocEngine::ClientContext4 ctx1(subnet_, ClientIdPtr(), hwaddr_, @@ -2855,7 +2829,7 @@ TEST_F(AllocEngine4Test, reservedAddressHintUsedByOtherClient) { // address when the pool is exhausted, and the only available // address is reserved for a different client. TEST_F(AllocEngine4Test, reservedAddressShortPool) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Create short pool with only one address. initSubnet(IOAddress("192.0.2.100"), IOAddress("192.0.2.100")); @@ -2909,7 +2883,7 @@ TEST_F(AllocEngine4Test, reservedAddressShortPool) { // dynamic pool if the client's reservation is made for a hostname but // not for an address. TEST_F(AllocEngine4Test, reservedHostname) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Create a reservation for a hostname. Address is set to 0 which // indicates that there is no reservation. @@ -2944,7 +2918,7 @@ TEST_F(AllocEngine4Test, reservedHostname) { // the value of NULL in the host_ field of the client context. TEST_F(AllocEngine4Test, findReservation) { // Create the instance of the allocation engine. - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Context is required to call the AllocEngine::findReservation. AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, @@ -3023,8 +2997,7 @@ TEST_F(AllocEngine4Test, findReservation) { // statistic for allocated addresses is increased appropriately. TEST_F(AllocEngine4Test, simpleAlloc4Stats) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -3061,8 +3034,7 @@ TEST_F(AllocEngine4Test, simpleAlloc4Stats) { // and that it doesn't increase allocated-addresses statistic. TEST_F(AllocEngine4Test, fakeAlloc4Stat) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, @@ -3116,7 +3088,7 @@ TEST_F(AllocEngine4Test, reservedAddressExistingLeaseStat) { false, false, "")); LeaseMgrFactory::instance().addLease(lease); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Let's pretend 100 addresses were allocated already string name = StatsMgr::generateName("subnet", subnet_->getID(), @@ -3168,7 +3140,7 @@ TEST_F(AllocEngine4Test, globalReservationReservedAddressDiscover) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); @@ -3216,7 +3188,7 @@ TEST_F(AllocEngine4Test, globalReservationReservedAddressRequest) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); @@ -3268,7 +3240,7 @@ TEST_F(AllocEngine4Test, globalReservationDynamicDiscover) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); @@ -3317,7 +3289,7 @@ TEST_F(AllocEngine4Test, globalReservationDynamicRequest) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); @@ -3369,7 +3341,7 @@ TEST_F(AllocEngine4Test, mixedReservationReservedAddressDiscover) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); subnet_->setReservationsInSubnet(true); @@ -3419,7 +3391,7 @@ TEST_F(AllocEngine4Test, mixedReservationReservedAddressRequest) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); subnet_->setReservationsInSubnet(true); @@ -3476,7 +3448,7 @@ TEST_F(AllocEngine4Test, bothReservationReservedAddressDiscover) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); subnet_->setReservationsInSubnet(true); @@ -3530,7 +3502,7 @@ TEST_F(AllocEngine4Test, bothReservationReservedAddressRequest) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); subnet_->setReservationsGlobal(true); subnet_->setReservationsInSubnet(true); @@ -3676,7 +3648,7 @@ TEST_F(AllocEngine4Test, updateExtendedInfo4) { }}; // Create the allocation engine, context and lease. - NakedAllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + NakedAllocEngine engine(0, false); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress::IPV4_ZERO_ADDRESS(), @@ -3820,7 +3792,7 @@ TEST_F(AllocEngine4Test, storeExtendedInfoEnabled4) { }}; // Create the allocation engine, context and lease. - NakedAllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + NakedAllocEngine engine(0, false); // All of the scenarios require storage to be enabled. subnet_->setStoreExtendedInfo(true); @@ -3925,7 +3897,7 @@ TEST_F(AllocEngine4Test, storeExtendedInfoDisabled4) { }}; // Create the allocation engine, context and lease. - NakedAllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + NakedAllocEngine engine(0, false); // All of the scenarios require storage to be disabled. subnet_->setStoreExtendedInfo(false); @@ -3974,8 +3946,7 @@ TEST_F(AllocEngine4Test, storeExtendedInfoDisabled4) { // using cache threshold. TEST_F(AllocEngine4Test, discoverCacheThreshold4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4020,8 +3991,7 @@ TEST_F(AllocEngine4Test, discoverCacheThreshold4) { // using cache threshold. TEST_F(AllocEngine4Test, requestCacheThreshold4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4077,8 +4047,7 @@ TEST_F(AllocEngine4Test, requestCacheThreshold4) { // using cache max age. TEST_F(AllocEngine4Test, discoverCacheMaxAge4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4123,8 +4092,7 @@ TEST_F(AllocEngine4Test, discoverCacheMaxAge4) { // using both cache threshold and max age. TEST_F(AllocEngine4Test, requestCacheBoth4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4180,8 +4148,7 @@ TEST_F(AllocEngine4Test, requestCacheBoth4) { // using too small cache threshold. TEST_F(AllocEngine4Test, discoverCacheBadThreshold4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4216,8 +4183,7 @@ TEST_F(AllocEngine4Test, discoverCacheBadThreshold4) { // using too small cache max age. TEST_F(AllocEngine4Test, requestCacheBadMaxAge4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4260,8 +4226,7 @@ TEST_F(AllocEngine4Test, requestCacheBadMaxAge4) { // when the valid lifetime was reduced. TEST_F(AllocEngine4Test, discoverCacheReducedValid4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 200. @@ -4296,8 +4261,7 @@ TEST_F(AllocEngine4Test, discoverCacheReducedValid4) { // when DDNS parameter changed. TEST_F(AllocEngine4Test, requestCacheFwdDDNS4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4337,8 +4301,7 @@ TEST_F(AllocEngine4Test, requestCacheFwdDDNS4) { // when DDNS parameter changed. TEST_F(AllocEngine4Test, discoverCacheRevDDNS4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4376,8 +4339,7 @@ TEST_F(AllocEngine4Test, discoverCacheRevDDNS4) { // when hostname changed. TEST_F(AllocEngine4Test, requestCacheHostname4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); // Set valid lifetime to 500. @@ -4418,7 +4380,7 @@ TEST_F(AllocEngine4Test, requestCacheHostname4) { // Verifies that AllocEngine::getValidLft(ctx4) returns the appropriate // lifetime value based on the context content. TEST_F(AllocEngine4Test, getValidLft4) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0, false); + AllocEngine engine(0, false); // Let's make three classes, two with valid-lifetime and one without, // and add them to the dictionary. @@ -4704,8 +4666,7 @@ TEST_F(AllocEngine4Test, getTemplateClassValidLft4) { // This test checks that deleteRelease handles BOOTP leases. TEST_F(AllocEngine4Test, bootpDelete) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -4771,8 +4732,7 @@ public: // This test checks that simple allocation handles BOOTP queries. TEST_F(MySqlAllocEngine4Test, bootpAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -4816,8 +4776,7 @@ TEST_F(MySqlAllocEngine4Test, bootpAlloc4) { // This test checks simple renewal handles BOOTP queries. TEST_F(MySqlAllocEngine4Test, bootpRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -4874,8 +4833,7 @@ TEST_F(MySqlAllocEngine4Test, bootpRenew4) { // This test checks that deleteRelease handles BOOTP leases. TEST_F(MySqlAllocEngine4Test, bootpDelete) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -4942,8 +4900,7 @@ public: // This test checks that simple allocation handles BOOTP queries. TEST_F(PgSqlAllocEngine4Test, bootpAlloc4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -4987,8 +4944,7 @@ TEST_F(PgSqlAllocEngine4Test, bootpAlloc4) { // This test checks simple renewal handles BOOTP queries. TEST_F(PgSqlAllocEngine4Test, bootpRenew4) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), @@ -5045,8 +5001,7 @@ TEST_F(PgSqlAllocEngine4Test, bootpRenew4) { // This test checks that deleteRelease handles BOOTP leases. TEST_F(PgSqlAllocEngine4Test, bootpDelete) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 0, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(0, false))); ASSERT_TRUE(engine); AllocEngine::ClientContext4 ctx(subnet_, clientid_, hwaddr_, IOAddress("0.0.0.0"), diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 73b81b48cc..b107200b0b 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -60,7 +60,7 @@ TEST(ClientContext6Test, addAllocatedResource) { TEST_F(AllocEngine6Test, constructor) { boost::scoped_ptr x; - ASSERT_NO_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100, true))); + ASSERT_NO_THROW(x.reset(new AllocEngine(100, true))); } // This test checks if two simple IPv6 allocations succeed and that the @@ -241,7 +241,7 @@ TEST_F(AllocEngine6Test, pdAllocBogusHint6) { // This test checks that NULL values are handled properly TEST_F(AllocEngine6Test, allocateAddress6Nulls) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Allocations without subnet are not allowed @@ -823,7 +823,7 @@ TEST_F(AllocEngine6Test, IterativeAllocator_manyPools6) { // This test checks if really small pools are working TEST_F(AllocEngine6Test, smallPool6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -866,7 +866,7 @@ TEST_F(AllocEngine6Test, smallPool6) { // to find out a new lease fails. TEST_F(AllocEngine6Test, outOfAddresses6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -915,7 +915,7 @@ TEST_F(AllocEngine6Test, outOfAddresses6) { // This test checks if an expired lease can be reused in SOLICIT (fake allocation) TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -987,7 +987,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) { // This test checks if an expired lease can be reused using default lifetimes. TEST_F(AllocEngine6Test, defaultReuseExpiredLease6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -1033,7 +1033,7 @@ TEST_F(AllocEngine6Test, defaultReuseExpiredLease6) { // This test checks if an expired lease can be reused using specified lifetimes. TEST_F(AllocEngine6Test, hintReuseExpiredLease6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -1079,7 +1079,7 @@ TEST_F(AllocEngine6Test, hintReuseExpiredLease6) { // This test checks if an expired lease can be reused using min lifetimes. TEST_F(AllocEngine6Test, minReuseExpiredLease6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -1125,7 +1125,7 @@ TEST_F(AllocEngine6Test, minReuseExpiredLease6) { // This test checks if an expired lease can be reused using max lifetimes. TEST_F(AllocEngine6Test, maxReuseExpiredLease6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -1171,7 +1171,7 @@ TEST_F(AllocEngine6Test, maxReuseExpiredLease6) { // This test checks if an expired lease can be reused in REQUEST (actual allocation) TEST_F(AllocEngine6Test, requestReuseExpiredLease6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -1320,7 +1320,7 @@ TEST_F(AllocEngine6Test, renewExtendLeaseLifetime) { ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); // This is what the client will send in his renew message. AllocEngine::HintContainer hints; @@ -1348,7 +1348,7 @@ TEST_F(AllocEngine6Test, defaultRenewLeaseLifetime) { ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); subnet_->setPreferred(Triplet(200, 300, 400)); subnet_->setValid(Triplet(300, 400, 500)); @@ -1383,7 +1383,7 @@ TEST_F(AllocEngine6Test, hintRenewLeaseLifetime) { ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); subnet_->setPreferred(Triplet(200, 300, 400)); subnet_->setValid(Triplet(300, 400, 500)); @@ -1418,7 +1418,7 @@ TEST_F(AllocEngine6Test, minRenewLeaseLifetime) { ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); subnet_->setPreferred(Triplet(200, 300, 400)); subnet_->setValid(Triplet(300, 400, 500)); @@ -1453,7 +1453,7 @@ TEST_F(AllocEngine6Test, maxRenewLeaseLifetime) { ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); subnet_->setPreferred(Triplet(200, 300, 400)); subnet_->setValid(Triplet(300, 400, 500)); @@ -1493,7 +1493,7 @@ TEST_F(AllocEngine6Test, renewExtendLeaseLifetimeForReservation) { ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); // This is what the client will send in his renew message. AllocEngine::HintContainer hints; @@ -1525,7 +1525,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolSolicitNoHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); Lease6Ptr lease = simpleAlloc6Test(pool_, IOAddress("::"), true); ASSERT_TRUE(lease); @@ -1547,7 +1547,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolRequestNoHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1585,7 +1585,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolSolicitValidHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1624,7 +1624,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolRequestValidHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1665,7 +1665,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolSolicitMatchingHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1704,7 +1704,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolRequestMatchingHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1745,7 +1745,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolSolicitNoHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8::abcd"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1781,7 +1781,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolRequestNoHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8::abcd"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1817,7 +1817,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolSolicitValidHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8::abcd"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1856,7 +1856,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolRequestValidHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8::abcd"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1895,7 +1895,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolSolicitMatchingHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8::abcd"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1934,7 +1934,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolRequestMatchingHint) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8::abcd"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -1966,7 +1966,7 @@ TEST_F(AllocEngine6Test, reservedAddressOutOfPoolRequestMatchingHint) { // Check that he is assigned a new lease for B // - verify that the number of assigned address behaves as expected TEST_F(AllocEngine6Test, reservedAddressInPoolReassignedThis) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -2045,7 +2045,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolReassignedThis) { // Check that his existing lease for lease A is removed // Check that he is assigned a new lease TEST_F(AllocEngine6Test, reservedAddressInPoolReassignedOther) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Assigned count should be zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -2130,7 +2130,7 @@ TEST_F(AllocEngine6Test, reservedAddressInPoolReassignedOther) { // we run out of addresses and remaining 14 clients will get nothing. // Finally, we check that client A still can get his reserved address. TEST_F(AllocEngine6Test, reservedAddress) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, true); + AllocEngine engine(100, true); // Create reservation for the client. This is in-pool reservation, // as the pool is 2001:db8:1::10 - 2001:db8:1::20. @@ -2198,7 +2198,7 @@ TEST_F(AllocEngine6Test, reservedAddress) { // Checks if the allocateLeases throws exceptions for invalid input data. TEST_F(AllocEngine6Test, allocateLeasesInvalidData) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, true); + AllocEngine engine(100, true); // That looks like a valid context. AllocEngine::ClientContext6 ctx(subnet_, duid_, false, false, "", false, @@ -2249,7 +2249,7 @@ TEST_F(AllocEngine6Test, allocateLeasesInvalidData) { // Checks whether an address can be renewed (simple case, no reservation tricks) TEST_F(AllocEngine6Test, addressRenewal) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); // Assigned count should zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -2301,7 +2301,7 @@ TEST_F(AllocEngine6Test, reservedAddressRenewal) { // as the pool is 2001:db8:1::10 - 2001:db8:1::20. createHost6(true, IPv6Resrv::TYPE_NA, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); // Assigned count should zero. EXPECT_TRUE(testStatistics("assigned-nas", 0, subnet_->getID())); @@ -2362,7 +2362,7 @@ TEST_F(AllocEngine6Test, DISABLED_reserved2AddressesSolicit) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); AllocEngine::ClientContext6 ctx1(subnet_, duid_, false, false, "", true, Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234))); @@ -2415,7 +2415,7 @@ TEST_F(AllocEngine6Test, reserved2Addresses) { CfgMgr::instance().getStagingCfg()->getCfgHosts()->add(host); CfgMgr::instance().commit(); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); AllocEngine::ClientContext6 ctx1(subnet_, duid_, false, false, "", false, Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234))); @@ -2459,7 +2459,7 @@ TEST_F(AllocEngine6Test, reserved2Addresses) { // reservation for this client) TEST_F(AllocEngine6Test, reservedAddressRenewChange) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); Lease6Collection leases; @@ -2484,7 +2484,7 @@ TEST_F(AllocEngine6Test, reservedAddressRenewChange) { // reservation for this address for another client) TEST_F(AllocEngine6Test, reservedAddressRenewReserved) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100); + AllocEngine engine(100); Lease6Collection leases; @@ -2543,7 +2543,7 @@ TEST_F(AllocEngine6Test, reservedAddressByMacInPoolSolicitNoHint) { createHost6HWAddr(true, IPv6Resrv::TYPE_NA, hwaddr_, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); Lease6Ptr lease = simpleAlloc6Test(pool_, IOAddress("::"), true); ASSERT_TRUE(lease); @@ -2566,7 +2566,7 @@ TEST_F(AllocEngine6Test, reservedAddressByMacInPoolRequestNoHint) { createHost6HWAddr(true, IPv6Resrv::TYPE_NA, hwaddr_, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); Lease6Ptr lease = simpleAlloc6Test(pool_, IOAddress("::"), false); ASSERT_TRUE(lease); @@ -2589,7 +2589,7 @@ TEST_F(AllocEngine6Test, reservedAddressByMacInPoolSolicitValidHint) { createHost6HWAddr(true, IPv6Resrv::TYPE_NA, hwaddr_, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Let's pretend the client sends hint 2001:db8:1::10. Lease6Ptr lease = simpleAlloc6Test(pool_, IOAddress("2001:db8:1::10"), true); @@ -2615,7 +2615,7 @@ TEST_F(AllocEngine6Test, reservedAddressByMacInPoolRequestValidHint) { createHost6HWAddr(true, IPv6Resrv::TYPE_NA, hwaddr_, IOAddress("2001:db8:1::1c"), 128); - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, false); + AllocEngine engine(100, false); // Let's pretend the client sends hint 2001:db8:1::10. Lease6Ptr lease = simpleAlloc6Test(pool_, IOAddress("2001:db8:1::10"), false); @@ -2632,7 +2632,7 @@ TEST_F(AllocEngine6Test, reservedAddressByMacInPoolRequestValidHint) { // value. This test verifies that the prefix can be allocated in that // case. TEST_F(AllocEngine6Test, largePDPool) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0); + AllocEngine engine(0); // Remove the default PD pool. subnet_->delPools(Lease::TYPE_PD); @@ -2654,7 +2654,7 @@ TEST_F(AllocEngine6Test, largePDPool) { // confuse the allocation engine if the number of available addresses // was larger than 2^32. TEST_F(AllocEngine6Test, largePoolOver32bits) { - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 0); + AllocEngine engine(0); // Configure 2001:db8::/32 subnet subnet_ = Subnet6::create(IOAddress("2001:db8::"), 32, 1, 2, 3, 4); @@ -2705,7 +2705,7 @@ TEST_F(AllocEngine6Test, largeAllocationAttemptsOverride) { // allocator will pick the addresses already allocated until it finds the // available address. Since, we have restricted the number of attempts the // allocation should fail. - AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 3); + AllocEngine engine(3); Lease6Collection leases = allocateTest(engine, pool_, IOAddress("::"), false, true); ASSERT_TRUE(leases.empty()); @@ -2724,7 +2724,7 @@ TEST_F(AllocEngine6Test, largeAllocationAttemptsOverride) { // This time, lets allow more attempts, and expect that the allocation will // be successful. - AllocEngine engine2(AllocEngine::ALLOC_ITERATIVE, 6); + AllocEngine engine2(6); leases = allocateTest(engine2, pool_, IOAddress("::"), false, true); ASSERT_EQ(1, leases.size()); } @@ -2732,7 +2732,7 @@ TEST_F(AllocEngine6Test, largeAllocationAttemptsOverride) { // This test checks if an expired declined lease can be reused in SOLICIT (fake allocation) TEST_F(AllocEngine6Test, solicitReuseDeclinedLease6) { - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)); + AllocEnginePtr engine(new AllocEngine(100)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -2768,7 +2768,7 @@ TEST_F(AllocEngine6Test, solicitReuseDeclinedLease6) { // to REQUEST (actual allocation) TEST_F(AllocEngine6Test, requestReuseDeclinedLease6) { - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100, true)); + AllocEnginePtr engine(new AllocEngine(100, true)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -2801,8 +2801,7 @@ TEST_F(AllocEngine6Test, requestReuseDeclinedLease6) { TEST_F(AllocEngine6Test, solicitReuseDeclinedLease6Stats) { // Now prepare for SOLICIT processing - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, true)); + AllocEnginePtr engine(new AllocEngine(100, true)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -2847,8 +2846,7 @@ TEST_F(AllocEngine6Test, solicitReuseDeclinedLease6Stats) { TEST_F(AllocEngine6Test, requestReuseDeclinedLease6Stats) { // Prepare for REQUEST processing. - AllocEnginePtr engine(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, true)); + AllocEnginePtr engine(new AllocEngine(100, true)); ASSERT_TRUE(engine); // Now prepare a configuration with single address pool. @@ -2901,7 +2899,7 @@ TEST_F(AllocEngine6Test, requestReuseDeclinedLease6Stats) { // data across reboots. TEST_F(AllocEngine6Test, reuseReclaimedExpiredViaRequest) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); IOAddress addr("2001:db8:1::ad"); @@ -2982,7 +2980,7 @@ TEST_F(AllocEngine6Test, reuseReclaimedExpiredViaRequest) { class SharedNetworkAlloc6Test : public AllocEngine6Test { public: SharedNetworkAlloc6Test() - :engine_(AllocEngine::ALLOC_ITERATIVE, 0) { + :engine_(0) { subnet1_ = Subnet6::create(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4); subnet2_ = Subnet6::create(IOAddress("2001:db8:2::"), 56, 1, 2, 3, 4); @@ -3472,7 +3470,7 @@ TEST_F(SharedNetworkAlloc6Test, requestRunningOut) { // renew a dynamic lease from their selected subnet. TEST_F(AllocEngine6Test, hostDynamicAddress) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3563,7 +3561,7 @@ TEST_F(AllocEngine6Test, hostDynamicAddress) { // 3. Renew the same lease via RENEW/REBIND (calls renewLeases6) TEST_F(AllocEngine6Test, globalHostDynamicAddress) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3648,7 +3646,7 @@ TEST_F(AllocEngine6Test, globalHostDynamicAddress) { // renew a lease for an arbitrary address. TEST_F(AllocEngine6Test, globalHostReservedAddress) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3706,7 +3704,7 @@ TEST_F(AllocEngine6Test, globalHostReservedAddress) { // renew a lease for an arbitrary prefix. TEST_F(AllocEngine6Test, globalHostReservedPrefix) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3768,7 +3766,7 @@ TEST_F(AllocEngine6Test, globalHostReservedPrefix) { // renew a lease for an address in the subnet. TEST_F(AllocEngine6Test, mixedHostReservedAddress) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3828,7 +3826,7 @@ TEST_F(AllocEngine6Test, mixedHostReservedAddress) { // renew a lease for a prefix in the subnet. TEST_F(AllocEngine6Test, mixedHostReservedPrefix) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr host(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3891,7 +3889,7 @@ TEST_F(AllocEngine6Test, mixedHostReservedPrefix) { // can get and renew a lease for an address in the subnet. TEST_F(AllocEngine6Test, bothHostReservedAddress) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr ghost(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -3960,7 +3958,7 @@ TEST_F(AllocEngine6Test, bothHostReservedAddress) { // can get and renew a lease for a prefix in the subnet. TEST_F(AllocEngine6Test, bothHostReservedPrefix) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); HostPtr ghost(new Host(&duid_->getDuid()[0], duid_->getDuid().size(), @@ -4035,7 +4033,7 @@ class AllocEngine6ExtendedInfoTest : public AllocEngine6Test { public: /// @brief Constructor AllocEngine6ExtendedInfoTest() - : engine_(AllocEngine::ALLOC_ITERATIVE, 100, true), + : engine_(100, true), duid1_(), duid2_(), duid3_(), relay1_(), relay2_(), relay3_(), duid1_addr_("::"), duid2_addr_("::") { duid1_.reset(new DUID(std::vector(8, 0x84))); @@ -4078,7 +4076,7 @@ public: duid2_addr_ = IOAddress("2001:db8:1::11"); // Create the allocation engine, context and lease. - NakedAllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100, true); + NakedAllocEngine engine(100, true); } /// Configuration elements. These are initialized in the constructor @@ -4526,7 +4524,7 @@ TEST_F(AllocEngine6ExtendedInfoTest, reuseExpiredLease6) { // Checks whether fake allocation does not use the cache feature. TEST_F(AllocEngine6Test, solicitNoCache) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -4568,7 +4566,7 @@ TEST_F(AllocEngine6Test, solicitNoCache) { // Checks whether a lease can be reused (request) using cache threshold. TEST_F(AllocEngine6Test, requestCacheThreshold6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 33%. @@ -4618,7 +4616,7 @@ TEST_F(AllocEngine6Test, requestCacheThreshold6) { // Checks whether a lease can be reused (renew) using cache threshold. TEST_F(AllocEngine6Test, renewCacheThreshold6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -4671,7 +4669,7 @@ TEST_F(AllocEngine6Test, renewCacheThreshold6) { // Checks whether a lease can be reused (request) using cache max age. TEST_F(AllocEngine6Test, requestCacheMaxAge6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the max age to 150. @@ -4721,7 +4719,7 @@ TEST_F(AllocEngine6Test, requestCacheMaxAge6) { // Checks whether a lease can be reused (renew) using cache max age. TEST_F(AllocEngine6Test, renewCacheMaxAge6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the max age to 150. @@ -4775,7 +4773,7 @@ TEST_F(AllocEngine6Test, renewCacheMaxAge6) { // and max age. TEST_F(AllocEngine6Test, requestCacheBoth6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -4829,7 +4827,7 @@ TEST_F(AllocEngine6Test, requestCacheBoth6) { // and max age. TEST_F(AllocEngine6Test, renewCacheBoth6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -4886,7 +4884,7 @@ TEST_F(AllocEngine6Test, renewCacheBoth6) { // cache threshold. TEST_F(AllocEngine6Test, requestCacheBadThreshold6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 10%. @@ -4930,7 +4928,7 @@ TEST_F(AllocEngine6Test, requestCacheBadThreshold6) { // cache threshold. TEST_F(AllocEngine6Test, renewCacheBadThreshold6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 10%. @@ -4977,7 +4975,7 @@ TEST_F(AllocEngine6Test, renewCacheBadThreshold6) { // cache max age. TEST_F(AllocEngine6Test, requestCacheBadMaxAge6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5021,7 +5019,7 @@ TEST_F(AllocEngine6Test, requestCacheBadMaxAge6) { // cache max age. TEST_F(AllocEngine6Test, renewCacheBadMaxAge6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5069,7 +5067,7 @@ TEST_F(AllocEngine6Test, renewCacheBadMaxAge6) { // This works only when the lifetime is recomputed. TEST_F(AllocEngine6Test, renewCacheReducedValid6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set valid lifetime to 200. @@ -5114,7 +5112,7 @@ TEST_F(AllocEngine6Test, renewCacheReducedValid6) { // This works only when the lifetime is recomputed. TEST_F(AllocEngine6Test, renewCacheReducedPreferred6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set preferred lifetime to 100. @@ -5160,7 +5158,7 @@ TEST_F(AllocEngine6Test, renewCacheReducedPreferred6) { // Checks whether a lease can't be reused (request) when DDNS parameter changed. TEST_F(AllocEngine6Test, requestCacheFwdDDNS6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5200,7 +5198,7 @@ TEST_F(AllocEngine6Test, requestCacheFwdDDNS6) { // Checks whether a lease can't be reused (renew) when DDNS parameter changed. TEST_F(AllocEngine6Test, renewCacheFwdDDNS6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5243,7 +5241,7 @@ TEST_F(AllocEngine6Test, renewCacheFwdDDNS6) { // Checks whether a lease can't be reused (request) when DDNS parameter changed. TEST_F(AllocEngine6Test, requestCacheRevDDNS6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5283,7 +5281,7 @@ TEST_F(AllocEngine6Test, requestCacheRevDDNS6) { // Checks whether a lease can't be reused (renew) when DDNS parameter changed. TEST_F(AllocEngine6Test, renewCacheRevDDNS6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5326,7 +5324,7 @@ TEST_F(AllocEngine6Test, renewCacheRevDDNS6) { // Checks whether a lease can't be reused (request) when hostname changed. TEST_F(AllocEngine6Test, requestCacheHostname6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5368,7 +5366,7 @@ TEST_F(AllocEngine6Test, requestCacheHostname6) { // Checks whether a lease can't be reused (renew) when hostname changed. TEST_F(AllocEngine6Test, renewCacheHostname6) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Set the threshold to 25%. @@ -5414,7 +5412,7 @@ TEST_F(AllocEngine6Test, renewCacheHostname6) { // valid lifetime value based on the context content. TEST_F(AllocEngine6Test, getValidLifetime) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Let's make three classes, two with valid-lifetime and one without, @@ -5679,7 +5677,7 @@ TEST_F(AllocEngine6Test, getTemplateClassValidLifetime) { // preferred lifetime value based on the context content. TEST_F(AllocEngine6Test, getPreferredLifetime) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Let's make three classes, two with preferred-lifetime and one without, diff --git a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc index 0ce5d5c1cb..dc67c30434 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_expiration_unittest.cc @@ -188,8 +188,7 @@ public: LeaseMgrFactory::create(lease_mgr_params); // Create allocation engine instance. - engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, true)); + engine_.reset(new AllocEngine(100, true)); } /// @brief Destructor diff --git a/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc index 935296dcba..168b14a80e 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_hooks_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2015-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2015-2022 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -183,7 +183,7 @@ TEST_F(HookAllocEngine6Test, lease6_select) { // Create allocation engine (hook names are registered in its ctor) boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Initialize Hooks Manager @@ -260,7 +260,7 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) { // Create allocation engine (hook names are registered in its ctor) boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Initialize Hooks Manager @@ -306,7 +306,7 @@ TEST_F(HookAllocEngine6Test, skip_lease6_select) { // Create allocation engine (hook names are registered in its ctor) boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Initialize Hooks Manager @@ -498,8 +498,7 @@ TEST_F(HookAllocEngine4Test, lease4_select) { // Create allocation engine (hook names are registered in its ctor) boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100, false))); ASSERT_TRUE(engine); // Initialize Hooks Manager @@ -573,8 +572,7 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) { // Create allocation engine (hook names are registered in its ctor) boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100, false))); ASSERT_TRUE(engine); // Initialize Hooks Manager @@ -623,8 +621,7 @@ TEST_F(HookAllocEngine4Test, skip_lease4_select) { // Create allocation engine (hook names are registered in its ctor) boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100, false))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100, false))); ASSERT_TRUE(engine); // Initialize Hooks Manager diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc index 54bce3c370..2bca46fddb 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc @@ -294,8 +294,7 @@ AllocEngine6Test::simpleAlloc6Test(const Pool6Ptr& pool, const IOAddress& hint, uint8_t expected_len = pool->getLength(); boost::scoped_ptr engine; - EXPECT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100))); + EXPECT_NO_THROW(engine.reset(new AllocEngine(100))); // We can't use ASSERT macros in non-void methods EXPECT_TRUE(engine); if (!engine) { @@ -345,8 +344,7 @@ AllocEngine6Test::simpleAlloc6Test(const Pool6Ptr& pool, const DuidPtr& duid, uint8_t expected_len = pool->getLength(); boost::scoped_ptr engine; - EXPECT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, - 100))); + EXPECT_NO_THROW(engine.reset(new AllocEngine(100))); // We can't use ASSERT macros in non-void methods EXPECT_TRUE(engine); if (!engine) { @@ -453,7 +451,7 @@ AllocEngine6Test::allocWithUsedHintTest(Lease::Type type, IOAddress used_addr, IOAddress requested, uint8_t expected_pd_len) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Let's create a lease and put it in the LeaseMgr @@ -502,7 +500,7 @@ void AllocEngine6Test::allocBogusHint6(Lease::Type type, asiolink::IOAddress hint, uint8_t expected_pd_len) { boost::scoped_ptr engine; - ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100))); + ASSERT_NO_THROW(engine.reset(new AllocEngine(100))); ASSERT_TRUE(engine); // Client would like to get a 3000::abc lease, which does not belong to any diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.h b/src/lib/dhcpsrv/tests/alloc_engine_utils.h index 754b3832f4..f1908f043f 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_utils.h +++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.h @@ -75,11 +75,10 @@ public: class NakedAllocEngine : public AllocEngine { public: /// @brief the sole constructor - /// @param engine_type specifies engine type (e.g. iterative) /// @param attempts number of lease selection attempts before giving up /// @param ipv6 specifies if the engine is IPv6 or IPv4 - NakedAllocEngine(AllocEngine::AllocType engine_type, unsigned int attempts, bool ipv6 = true) - : AllocEngine(engine_type, attempts, ipv6) { + NakedAllocEngine(unsigned int attempts, bool ipv6 = true) + : AllocEngine(attempts, ipv6) { } // Expose internal classes for testing purposes