Test sending out reminder notifications in a given interval. */
| 249 | /* Test sending out reminder notifications in a given interval. |
| 250 | */ |
| 251 | BOOST_AUTO_TEST_CASE(notify_send_reminders) |
| 252 | { |
| 253 | SetNotificationInverval(0.15); |
| 254 | ReceiveCheckResults(2, ServiceCritical); |
| 255 | |
| 256 | // The first run of the timer sets up the next reminder notification. |
| 257 | NotificationTimerHandler(); |
| 258 | BOOST_REQUIRE(WaitForExpectedNotificationCount(1)); |
| 259 | BOOST_REQUIRE_EQUAL(GetLastNotification(), NotificationProblem); |
| 260 | |
| 261 | // Rerunning the timer before the next interval should not trigger a reminder notification. |
| 262 | NotificationTimerHandler(); |
| 263 | BOOST_REQUIRE(AssertNoReSendSuppressedLogPattern()); |
| 264 | BOOST_REQUIRE_EQUAL(GetNotificationCount(), 1); |
| 265 | BOOST_REQUIRE_EQUAL(GetLastNotification(), NotificationProblem); |
| 266 | |
| 267 | // After waiting until the interval has passed, a reminder will be queued. |
| 268 | WaitUntilNextReminderScheduled(); |
| 269 | NotificationTimerHandler(); |
| 270 | BOOST_REQUIRE(WaitForExpectedNotificationCount(2)); |
| 271 | BOOST_REQUIRE_EQUAL(GetLastNotification(), NotificationProblem); |
| 272 | |
| 273 | // Now we test that reminders are only sent for Critical states. |
| 274 | // Hard state is switched to OK. |
| 275 | ReceiveCheckResults(1, ServiceOK); |
| 276 | NotificationTimerHandler(); |
| 277 | BOOST_REQUIRE(WaitForExpectedNotificationCount(3)); |
| 278 | BOOST_REQUIRE_EQUAL(GetLastNotification(), NotificationRecovery); |
| 279 | |
| 280 | // Now we wait for one interval and check that no reminder has been sent. |
| 281 | WaitUntilNextReminderScheduled(); |
| 282 | NotificationTimerHandler(); |
| 283 | BOOST_REQUIRE(AssertNoReSendSuppressedLogPattern()); |
| 284 | BOOST_REQUIRE_EQUAL(GetNotificationCount(), 3); |
| 285 | BOOST_REQUIRE_EQUAL(GetLastNotification(), NotificationRecovery); |
| 286 | } |
| 287 | |
| 288 | /* Tests if delayed notifications are sent out. |
| 289 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected