mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 22:45:18 +00:00
[master] Merge branch 'trac4075'
This commit is contained in:
@@ -106,7 +106,7 @@ limitations on the number of leases and duration. However, this
|
|||||||
may result in longer periods of server's unresponsiveness to
|
may result in longer periods of server's unresponsiveness to
|
||||||
DHCP packets, while it processes the expired leases.
|
DHCP packets, while it processes the expired leases.
|
||||||
|
|
||||||
% ALLOC_ENGINE_V4_LEASES_RECLAMATION_START starting reclamation of expired leases (limit = %1 leases or %2 seconds)
|
% ALLOC_ENGINE_V4_LEASES_RECLAMATION_START starting reclamation of expired leases (limit = %1 leases or %2 milliseconds)
|
||||||
This debug message is issued when the allocation engine starts the
|
This debug message is issued when the allocation engine starts the
|
||||||
reclamation of the expired leases. The maximum number of leases to
|
reclamation of the expired leases. The maximum number of leases to
|
||||||
be reclaimed and the timeout is included in the message. If any of
|
be reclaimed and the timeout is included in the message. If any of
|
||||||
@@ -371,7 +371,7 @@ limitations on the number of leases and duration. However, this
|
|||||||
may result in longer periods of server's unresponsiveness to
|
may result in longer periods of server's unresponsiveness to
|
||||||
DHCP packets, while it processes the expired leases.
|
DHCP packets, while it processes the expired leases.
|
||||||
|
|
||||||
% ALLOC_ENGINE_V6_LEASES_RECLAMATION_START starting reclamation of expired leases (limit = %1 leases or %2 seconds)
|
% ALLOC_ENGINE_V6_LEASES_RECLAMATION_START starting reclamation of expired leases (limit = %1 leases or %2 milliseconds)
|
||||||
This debug message is issued when the allocation engine starts the
|
This debug message is issued when the allocation engine starts the
|
||||||
reclamation of the expired leases. The maximum number of leases to
|
reclamation of the expired leases. The maximum number of leases to
|
||||||
be reclaimed and the timeout is included in the message. If any of
|
be reclaimed and the timeout is included in the message. If any of
|
||||||
|
@@ -524,20 +524,26 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Implements "lease{4,6}_expire callout, which lasts at least
|
/// @brief Implements "lease{4,6}_expire callout, which lasts at least
|
||||||
/// 2ms.
|
/// 40ms.
|
||||||
///
|
///
|
||||||
/// This callout is useful to test scenarios where the reclamation of the
|
/// This callout is useful to test scenarios where the reclamation of the
|
||||||
/// lease needs to take a known amount of time. If the callout is installed
|
/// lease needs to take a known amount of time. If the callout is installed
|
||||||
/// it will take at least 2ms for each lease. It is then possible to calculate
|
/// it will take at least 40ms for each lease. It is then possible to calculate
|
||||||
/// the approximate time that the reclamation of all leases would take and
|
/// the approximate time that the reclamation of all leases would take and
|
||||||
/// test that the timeouts for the leases' reclamation work as expected.
|
/// test that the timeouts for the leases' reclamation work as expected.
|
||||||
///
|
///
|
||||||
|
/// The value of 40ms is relatively high, but it has been selected to
|
||||||
|
/// mitigate the problems with usleep on some virtual machines. On those
|
||||||
|
/// machines the wakeup from usleep may take significant amount of time,
|
||||||
|
/// i.e. usually around 10ms. Thus, the sleep time should be considerably
|
||||||
|
/// higher than this delay.
|
||||||
|
///
|
||||||
/// @param callout_handle Callout handle.
|
/// @param callout_handle Callout handle.
|
||||||
/// @return Zero.
|
/// @return Zero.
|
||||||
static int leaseExpireWithDelayCallout(CalloutHandle& callout_handle) {
|
static int leaseExpireWithDelayCallout(CalloutHandle& callout_handle) {
|
||||||
leaseExpireCallout(callout_handle);
|
leaseExpireCallout(callout_handle);
|
||||||
// Delay the return from the callout by 2ms.
|
// Delay the return from the callout by 40ms.
|
||||||
usleep(2000);
|
usleep(40000);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -895,7 +901,7 @@ public:
|
|||||||
HooksManager::loadLibraries(libraries);
|
HooksManager::loadLibraries(libraries);
|
||||||
|
|
||||||
// Install a callout: lease4_expire or lease6_expire. Each callout
|
// Install a callout: lease4_expire or lease6_expire. Each callout
|
||||||
// takes at least 2ms to run (it uses usleep).
|
// takes at least 40ms to run (it uses usleep).
|
||||||
std::ostringstream callout_name;
|
std::ostringstream callout_name;
|
||||||
callout_name << callout_argument_name << "_expire";
|
callout_name << callout_argument_name << "_expire";
|
||||||
EXPECT_NO_THROW(HooksManager::preCalloutsLibraryHandle().registerCallout(
|
EXPECT_NO_THROW(HooksManager::preCalloutsLibraryHandle().registerCallout(
|
||||||
@@ -904,8 +910,8 @@ public:
|
|||||||
// Reclaim leases with timeout.
|
// Reclaim leases with timeout.
|
||||||
ASSERT_NO_THROW(reclaimExpiredLeases(0, timeout, false));
|
ASSERT_NO_THROW(reclaimExpiredLeases(0, timeout, false));
|
||||||
|
|
||||||
// We reclaimed at most (timeout / 2ms) leases.
|
// We reclaimed at most (timeout / 40ms) leases.
|
||||||
const uint16_t theoretical_reclaimed = static_cast<uint16_t>(timeout / 2);
|
const uint16_t theoretical_reclaimed = static_cast<uint16_t>(timeout / 40);
|
||||||
|
|
||||||
// The actual number of leases reclaimed is likely to be lower than
|
// The actual number of leases reclaimed is likely to be lower than
|
||||||
// the theoretical number. For low theoretical number the adjusted
|
// the theoretical number. For low theoretical number the adjusted
|
||||||
@@ -1333,8 +1339,8 @@ TEST_F(ExpirationAllocEngine6Test, reclaimExpiredLeasesHooksWithSkip) {
|
|||||||
TEST_F(ExpirationAllocEngine6Test, reclaimExpiredLeasesTimeout) {
|
TEST_F(ExpirationAllocEngine6Test, reclaimExpiredLeasesTimeout) {
|
||||||
// This test needs at least 40 leases to make sense.
|
// This test needs at least 40 leases to make sense.
|
||||||
BOOST_STATIC_ASSERT(TEST_LEASES_NUM >= 40);
|
BOOST_STATIC_ASSERT(TEST_LEASES_NUM >= 40);
|
||||||
// Run with timeout of 60ms.
|
// Run with timeout of 1.2s.
|
||||||
testReclaimExpiredLeasesTimeout(60);
|
testReclaimExpiredLeasesTimeout(1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test verifies that at least one lease is reclaimed if the timeout
|
// This test verifies that at least one lease is reclaimed if the timeout
|
||||||
@@ -1734,8 +1740,8 @@ TEST_F(ExpirationAllocEngine4Test, reclaimExpiredLeasesHooksWithSkip) {
|
|||||||
TEST_F(ExpirationAllocEngine4Test, reclaimExpiredLeasesTimeout) {
|
TEST_F(ExpirationAllocEngine4Test, reclaimExpiredLeasesTimeout) {
|
||||||
// This test needs at least 40 leases to make sense.
|
// This test needs at least 40 leases to make sense.
|
||||||
BOOST_STATIC_ASSERT(TEST_LEASES_NUM >= 40);
|
BOOST_STATIC_ASSERT(TEST_LEASES_NUM >= 40);
|
||||||
// Run with timeout of 60ms.
|
// Run with timeout of 1.2s.
|
||||||
testReclaimExpiredLeasesTimeout(60);
|
testReclaimExpiredLeasesTimeout(1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test verifies that at least one lease is reclaimed if the timeout
|
// This test verifies that at least one lease is reclaimed if the timeout
|
||||||
|
Reference in New Issue
Block a user