Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
08349e87
Commit
08349e87
authored
Jan 13, 2015
by
Marcin Siodelski
Browse files
[3668] Added a test for disabled LFC timer.
parent
40a3b30d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
View file @
08349e87
...
...
@@ -39,19 +39,19 @@ using namespace isc::dhcp::test;
namespace
{
/// @brief Class derived from @c Memfile_LeaseMgr to test timer
s
.
/// @brief Class derived from @c Memfile_LeaseMgr to test
LFC
timer.
///
/// This class provides a custom callback function which is invoked
/// when the timer for Lease File Cleanup goes off. It is used to
/// test that the timer is correctly installed.
class
Test
MemfileLeaseMgr
:
public
Memfile_LeaseMgr
{
class
LFC
MemfileLeaseMgr
:
public
Memfile_LeaseMgr
{
public:
/// @brief Constructor.
///
/// Sets the counter for callbacks to 0.
Test
MemfileLeaseMgr
(
const
ParameterMap
&
parameters
)
:
Memfile_LeaseMgr
(
parameters
)
{
LFC
MemfileLeaseMgr
(
const
ParameterMap
&
parameters
)
:
Memfile_LeaseMgr
(
parameters
)
,
lfc_cnt_
(
0
)
{
}
/// @brief Returns the number of callback executions.
...
...
@@ -285,20 +285,47 @@ TEST_F(MemfileLeaseMgrTest, lfcTimer) {
pmap
[
"name"
]
=
getLeaseFilePath
(
"leasefile4_0.csv"
);
pmap
[
"lfc-interval"
]
=
"1"
;
boost
::
s
har
ed_ptr
<
Test
MemfileLeaseMgr
>
lease_mgr
(
new
Test
MemfileLeaseMgr
(
pmap
));
boost
::
s
cop
ed_ptr
<
LFC
MemfileLeaseMgr
>
lease_mgr
(
new
LFC
MemfileLeaseMgr
(
pmap
));
io_service_
=
lease_mgr
->
getIOService
();
// Run the test for at most 2.9 seconds.
setTestTime
(
2900
);
// Run the IO service to execute timers.
io_service_
->
run
();
// Within 2.9 we should record two LFC executions.
EXPECT_EQ
(
2
,
lease_mgr
->
getLFCCount
());
}
// This test checks if the LFC timer is disabled (doesn't trigger)
// cleanups when the lfc-interval is set to 0.
TEST_F
(
MemfileLeaseMgrTest
,
lfcTimerDisabled
)
{
LeaseMgr
::
ParameterMap
pmap
;
pmap
[
"type"
]
=
"memfile"
;
pmap
[
"universe"
]
=
"4"
;
pmap
[
"name"
]
=
getLeaseFilePath
(
"leasefile4_0.csv"
);
// Set the LFC interval to 0, which should effectively disable it.
pmap
[
"lfc-interval"
]
=
"0"
;
boost
::
scoped_ptr
<
LFCMemfileLeaseMgr
>
lease_mgr
(
new
LFCMemfileLeaseMgr
(
pmap
));
io_service_
=
lease_mgr
->
getIOService
();
// Run the test for at most 1.9 seconds.
setTestTime
(
1900
);
// Run the IO service to execute timers.
io_service_
->
run
();
// There should be no LFC execution recorded.
EXPECT_EQ
(
0
,
lease_mgr
->
getLFCCount
());
}
// Checks that adding/getting/deleting a Lease6 object works.
TEST_F
(
MemfileLeaseMgrTest
,
addGetDelete6
)
{
startBackend
(
V6
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment