"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/icinga-checkresult.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

icinga-checkresult.cpp  (icinga2-2.11.5):icinga-checkresult.cpp  (icinga2-2.12.0)
skipping to change at line 60 skipping to change at line 60
host->SetMaxCheckAttempts(1); host->SetMaxCheckAttempts(1);
host->Activate(); host->Activate();
host->SetAuthority(true); host->SetAuthority(true);
host->SetStateRaw(ServiceOK); host->SetStateRaw(ServiceOK);
host->SetStateType(StateTypeHard); host->SetStateType(StateTypeHard);
std::cout << "Before first check result (ok, hard)" << std::endl; std::cout << "Before first check result (ok, hard)" << std::endl;
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "First check result (unknown)" << std::endl; std::cout << "First check result (unknown)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown)); host->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationProblem); CheckNotification(host, true, NotificationProblem);
std::cout << "Second check result (ok)" << std::endl; std::cout << "Second check result (ok)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceOK)); host->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationRecovery); CheckNotification(host, true, NotificationRecovery);
std::cout << "Third check result (critical)" << std::endl; std::cout << "Third check result (critical)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceCritical)); host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationProblem); CheckNotification(host, true, NotificationProblem);
std::cout << "Fourth check result (ok)" << std::endl; std::cout << "Fourth check result (ok)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceOK)); host->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationRecovery); CheckNotification(host, true, NotificationRecovery);
c.disconnect(); c.disconnect();
} }
BOOST_AUTO_TEST_CASE(host_2attempts) BOOST_AUTO_TEST_CASE(host_2attempts)
{ {
boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2)); boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2));
Host::Ptr host = new Host(); Host::Ptr host = new Host();
skipping to change at line 109 skipping to change at line 114
host->SetMaxCheckAttempts(2); host->SetMaxCheckAttempts(2);
host->Activate(); host->Activate();
host->SetAuthority(true); host->SetAuthority(true);
host->SetStateRaw(ServiceOK); host->SetStateRaw(ServiceOK);
host->SetStateType(StateTypeHard); host->SetStateType(StateTypeHard);
std::cout << "Before first check result (ok, hard)" << std::endl; std::cout << "Before first check result (ok, hard)" << std::endl;
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "First check result (unknown)" << std::endl; std::cout << "First check result (unknown)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown)); host->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeSoft); BOOST_CHECK(host->GetStateType() == StateTypeSoft);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "Second check result (critical)" << std::endl; std::cout << "Second check result (critical)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceCritical)); host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationProblem); CheckNotification(host, true, NotificationProblem);
std::cout << "Third check result (ok)" << std::endl; std::cout << "Third check result (ok)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceOK)); host->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationRecovery); CheckNotification(host, true, NotificationRecovery);
std::cout << "Fourth check result (critical)" << std::endl; std::cout << "Fourth check result (critical)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceCritical)); host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeSoft); BOOST_CHECK(host->GetStateType() == StateTypeSoft);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "Fifth check result (ok)" << std::endl; std::cout << "Fifth check result (ok)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceOK)); host->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
c.disconnect(); c.disconnect();
} }
BOOST_AUTO_TEST_CASE(host_3attempts) BOOST_AUTO_TEST_CASE(host_3attempts)
{ {
boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2)); boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2));
Host::Ptr host = new Host(); Host::Ptr host = new Host();
skipping to change at line 165 skipping to change at line 176
host->SetMaxCheckAttempts(3); host->SetMaxCheckAttempts(3);
host->Activate(); host->Activate();
host->SetAuthority(true); host->SetAuthority(true);
host->SetStateRaw(ServiceOK); host->SetStateRaw(ServiceOK);
host->SetStateType(StateTypeHard); host->SetStateType(StateTypeHard);
std::cout << "Before first check result (ok, hard)" << std::endl; std::cout << "Before first check result (ok, hard)" << std::endl;
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "First check result (unknown)" << std::endl; std::cout << "First check result (unknown)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceUnknown)); host->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeSoft); BOOST_CHECK(host->GetStateType() == StateTypeSoft);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "Second check result (critical)" << std::endl; std::cout << "Second check result (critical)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceCritical)); host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeSoft); BOOST_CHECK(host->GetStateType() == StateTypeSoft);
BOOST_CHECK(host->GetCheckAttempt() == 2); BOOST_CHECK(host->GetCheckAttempt() == 2);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "Third check result (critical)" << std::endl; std::cout << "Third check result (critical)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceCritical)); host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationProblem); CheckNotification(host, true, NotificationProblem);
std::cout << "Fourth check result (ok)" << std::endl; std::cout << "Fourth check result (ok)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceOK)); host->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, true, NotificationRecovery); CheckNotification(host, true, NotificationRecovery);
std::cout << "Fifth check result (critical)" << std::endl; std::cout << "Fifth check result (critical)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceCritical)); host->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(host->GetState() == HostDown); BOOST_CHECK(host->GetState() == HostDown);
BOOST_CHECK(host->GetStateType() == StateTypeSoft); BOOST_CHECK(host->GetStateType() == StateTypeSoft);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
std::cout << "Sixth check result (ok)" << std::endl; std::cout << "Sixth check result (ok)" << std::endl;
host->ProcessCheckResult(MakeCheckResult(ServiceOK)); host->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(host->GetState() == HostUp); BOOST_CHECK(host->GetState() == HostUp);
BOOST_CHECK(host->GetStateType() == StateTypeHard); BOOST_CHECK(host->GetStateType() == StateTypeHard);
BOOST_CHECK(host->GetCheckAttempt() == 1); BOOST_CHECK(host->GetCheckAttempt() == 1);
BOOST_CHECK(host->IsReachable() == true);
CheckNotification(host, false); CheckNotification(host, false);
c.disconnect(); c.disconnect();
} }
BOOST_AUTO_TEST_CASE(service_1attempt) BOOST_AUTO_TEST_CASE(service_1attempt)
{ {
boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2)); boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2));
Service::Ptr service = new Service(); Service::Ptr service = new Service();
skipping to change at line 228 skipping to change at line 246
service->SetMaxCheckAttempts(1); service->SetMaxCheckAttempts(1);
service->Activate(); service->Activate();
service->SetAuthority(true); service->SetAuthority(true);
service->SetStateRaw(ServiceOK); service->SetStateRaw(ServiceOK);
service->SetStateType(StateTypeHard); service->SetStateType(StateTypeHard);
std::cout << "Before first check result (ok, hard)" << std::endl; std::cout << "Before first check result (ok, hard)" << std::endl;
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "First check result (unknown)" << std::endl; std::cout << "First check result (unknown)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown)); service->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
BOOST_CHECK(service->GetState() == ServiceUnknown); BOOST_CHECK(service->GetState() == ServiceUnknown);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationProblem); CheckNotification(service, true, NotificationProblem);
std::cout << "Second check result (ok)" << std::endl; std::cout << "Second check result (ok)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceOK)); service->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationRecovery); CheckNotification(service, true, NotificationRecovery);
std::cout << "Third check result (critical)" << std::endl; std::cout << "Third check result (critical)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceCritical)); service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(service->GetState() == ServiceCritical); BOOST_CHECK(service->GetState() == ServiceCritical);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationProblem); CheckNotification(service, true, NotificationProblem);
std::cout << "Fourth check result (ok)" << std::endl; std::cout << "Fourth check result (ok)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceOK)); service->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationRecovery); CheckNotification(service, true, NotificationRecovery);
c.disconnect(); c.disconnect();
} }
BOOST_AUTO_TEST_CASE(service_2attempts) BOOST_AUTO_TEST_CASE(service_2attempts)
{ {
boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2)); boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2));
Service::Ptr service = new Service(); Service::Ptr service = new Service();
skipping to change at line 277 skipping to change at line 300
service->SetMaxCheckAttempts(2); service->SetMaxCheckAttempts(2);
service->Activate(); service->Activate();
service->SetAuthority(true); service->SetAuthority(true);
service->SetStateRaw(ServiceOK); service->SetStateRaw(ServiceOK);
service->SetStateType(StateTypeHard); service->SetStateType(StateTypeHard);
std::cout << "Before first check result (ok, hard)" << std::endl; std::cout << "Before first check result (ok, hard)" << std::endl;
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "First check result (unknown)" << std::endl; std::cout << "First check result (unknown)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown)); service->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
BOOST_CHECK(service->GetState() == ServiceUnknown); BOOST_CHECK(service->GetState() == ServiceUnknown);
BOOST_CHECK(service->GetStateType() == StateTypeSoft); BOOST_CHECK(service->GetStateType() == StateTypeSoft);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "Second check result (critical)" << std::endl; std::cout << "Second check result (critical)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceCritical)); service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(service->GetState() == ServiceCritical); BOOST_CHECK(service->GetState() == ServiceCritical);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationProblem); CheckNotification(service, true, NotificationProblem);
std::cout << "Third check result (ok)" << std::endl; std::cout << "Third check result (ok)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceOK)); service->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationRecovery); CheckNotification(service, true, NotificationRecovery);
std::cout << "Fourth check result (critical)" << std::endl; std::cout << "Fourth check result (critical)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceCritical)); service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(service->GetState() == ServiceCritical); BOOST_CHECK(service->GetState() == ServiceCritical);
BOOST_CHECK(service->GetStateType() == StateTypeSoft); BOOST_CHECK(service->GetStateType() == StateTypeSoft);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "Fifth check result (ok)" << std::endl; std::cout << "Fifth check result (ok)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceOK)); service->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
c.disconnect(); c.disconnect();
} }
BOOST_AUTO_TEST_CASE(service_3attempts) BOOST_AUTO_TEST_CASE(service_3attempts)
{ {
boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2)); boost::signals2::connection c = Checkable::OnNotificationsRequested.conne ct(std::bind(&NotificationHandler, _1, _2));
Service::Ptr service = new Service(); Service::Ptr service = new Service();
skipping to change at line 333 skipping to change at line 362
service->SetMaxCheckAttempts(3); service->SetMaxCheckAttempts(3);
service->Activate(); service->Activate();
service->SetAuthority(true); service->SetAuthority(true);
service->SetStateRaw(ServiceOK); service->SetStateRaw(ServiceOK);
service->SetStateType(StateTypeHard); service->SetStateType(StateTypeHard);
std::cout << "Before first check result (ok, hard)" << std::endl; std::cout << "Before first check result (ok, hard)" << std::endl;
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "First check result (unknown)" << std::endl; std::cout << "First check result (unknown)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceUnknown)); service->ProcessCheckResult(MakeCheckResult(ServiceUnknown));
BOOST_CHECK(service->GetState() == ServiceUnknown); BOOST_CHECK(service->GetState() == ServiceUnknown);
BOOST_CHECK(service->GetStateType() == StateTypeSoft); BOOST_CHECK(service->GetStateType() == StateTypeSoft);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "Second check result (critical)" << std::endl; std::cout << "Second check result (critical)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceCritical)); service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(service->GetState() == ServiceCritical); BOOST_CHECK(service->GetState() == ServiceCritical);
BOOST_CHECK(service->GetStateType() == StateTypeSoft); BOOST_CHECK(service->GetStateType() == StateTypeSoft);
BOOST_CHECK(service->GetCheckAttempt() == 2); BOOST_CHECK(service->GetCheckAttempt() == 2);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "Third check result (critical)" << std::endl; std::cout << "Third check result (critical)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceCritical)); service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(service->GetState() == ServiceCritical); BOOST_CHECK(service->GetState() == ServiceCritical);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationProblem); CheckNotification(service, true, NotificationProblem);
std::cout << "Fourth check result (ok)" << std::endl; std::cout << "Fourth check result (ok)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceOK)); service->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, true, NotificationRecovery); CheckNotification(service, true, NotificationRecovery);
std::cout << "Fifth check result (critical)" << std::endl; std::cout << "Fifth check result (critical)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceCritical)); service->ProcessCheckResult(MakeCheckResult(ServiceCritical));
BOOST_CHECK(service->GetState() == ServiceCritical); BOOST_CHECK(service->GetState() == ServiceCritical);
BOOST_CHECK(service->GetStateType() == StateTypeSoft); BOOST_CHECK(service->GetStateType() == StateTypeSoft);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
std::cout << "Sixth check result (ok)" << std::endl; std::cout << "Sixth check result (ok)" << std::endl;
service->ProcessCheckResult(MakeCheckResult(ServiceOK)); service->ProcessCheckResult(MakeCheckResult(ServiceOK));
BOOST_CHECK(service->GetState() == ServiceOK); BOOST_CHECK(service->GetState() == ServiceOK);
BOOST_CHECK(service->GetStateType() == StateTypeHard); BOOST_CHECK(service->GetStateType() == StateTypeHard);
BOOST_CHECK(service->GetCheckAttempt() == 1); BOOST_CHECK(service->GetCheckAttempt() == 1);
BOOST_CHECK(service->IsReachable() == true);
CheckNotification(service, false); CheckNotification(service, false);
c.disconnect(); c.disconnect();
} }
BOOST_AUTO_TEST_CASE(host_flapping_notification) BOOST_AUTO_TEST_CASE(host_flapping_notification)
{ {
#ifndef I2_DEBUG #ifndef I2_DEBUG
BOOST_WARN_MESSAGE(false, "This test can only be run in a debug build!"); BOOST_WARN_MESSAGE(false, "This test can only be run in a debug build!");
#else /* I2_DEBUG */ #else /* I2_DEBUG */
 End of changes. 36 change blocks. 
0 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)