mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[#2588] Updated code and unit tests
This commit is contained in:
@@ -3147,6 +3147,7 @@ void AllocEngine::reclaimLeaseInDatabase(const LeasePtrType& lease,
|
|||||||
lease->fqdn_fwd_ = false;
|
lease->fqdn_fwd_ = false;
|
||||||
lease->fqdn_rev_ = false;
|
lease->fqdn_rev_ = false;
|
||||||
lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
|
lease->state_ = Lease::STATE_EXPIRED_RECLAIMED;
|
||||||
|
lease->setContext(ElementPtr());
|
||||||
lease_update_fun(lease);
|
lease_update_fun(lease);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@@ -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
|
// 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
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace isc;
|
using namespace isc;
|
||||||
using namespace isc::asiolink;
|
using namespace isc::asiolink;
|
||||||
|
using namespace isc::data;
|
||||||
using namespace isc::dhcp;
|
using namespace isc::dhcp;
|
||||||
using namespace isc::dhcp::test;
|
using namespace isc::dhcp::test;
|
||||||
using namespace isc::dhcp_ddns;
|
using namespace isc::dhcp_ddns;
|
||||||
@@ -426,7 +427,7 @@ public:
|
|||||||
static bool leaseReclaimed(const LeasePtrType& lease) {
|
static bool leaseReclaimed(const LeasePtrType& lease) {
|
||||||
return (lease && lease->stateExpiredReclaimed() &&
|
return (lease && lease->stateExpiredReclaimed() &&
|
||||||
lease->hostname_.empty() && !lease->fqdn_fwd_ &&
|
lease->hostname_.empty() && !lease->fqdn_fwd_ &&
|
||||||
!lease->fqdn_rev_);
|
!lease->fqdn_rev_ && !lease->getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Lease algorithm checking if lease state is Declined.
|
/// @brief Lease algorithm checking if lease state is Declined.
|
||||||
@@ -1279,7 +1280,11 @@ ExpirationAllocEngine6Test::createLeases() {
|
|||||||
Lease6Ptr lease(new Lease6(Lease::TYPE_NA, address, duid, 1, 50, 60,
|
Lease6Ptr lease(new Lease6(Lease::TYPE_NA, address, duid, 1, 50, 60,
|
||||||
SubnetID(1), true, true,
|
SubnetID(1), true, true,
|
||||||
generateHostnameForLeaseIndex(i)));
|
generateHostnameForLeaseIndex(i)));
|
||||||
|
ElementPtr user_context = Element::createMap();
|
||||||
|
user_context->set("index", Element::create(static_cast<int>(i)));
|
||||||
|
lease->setContext(user_context);
|
||||||
leases_.push_back(lease);
|
leases_.push_back(lease);
|
||||||
|
|
||||||
// Copy the lease before adding it to the lease manager. We want to
|
// Copy the lease before adding it to the lease manager. We want to
|
||||||
// make sure that modifications to the leases held in the leases_
|
// make sure that modifications to the leases held in the leases_
|
||||||
// container doesn't affect the leases in the lease manager.
|
// container doesn't affect the leases in the lease manager.
|
||||||
@@ -1841,6 +1846,9 @@ ExpirationAllocEngine4Test::createLeases() {
|
|||||||
Lease4Ptr lease(new Lease4(address, hwaddr, ClientIdPtr(), 60,
|
Lease4Ptr lease(new Lease4(address, hwaddr, ClientIdPtr(), 60,
|
||||||
time(NULL), SubnetID(1), true, true,
|
time(NULL), SubnetID(1), true, true,
|
||||||
generateHostnameForLeaseIndex(i)));
|
generateHostnameForLeaseIndex(i)));
|
||||||
|
ElementPtr user_context = Element::createMap();
|
||||||
|
user_context->set("index", Element::create(static_cast<int>(i)));
|
||||||
|
lease->setContext(user_context);
|
||||||
leases_.push_back(lease);
|
leases_.push_back(lease);
|
||||||
// Copy the lease before adding it to the lease manager. We want to
|
// Copy the lease before adding it to the lease manager. We want to
|
||||||
// make sure that modifications to the leases held in the leases_
|
// make sure that modifications to the leases held in the leases_
|
||||||
@@ -2320,4 +2328,4 @@ TEST_F(ExpirationAllocEngine4Test, reclaimDeclinedHook2) {
|
|||||||
testReclaimDeclinedHook(true); // true = use skip callout
|
testReclaimDeclinedHook(true); // true = use skip callout
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // end of anonymous namespace
|
} // end of anonymous namespace
|
||||||
|
Reference in New Issue
Block a user