Skip to content

Commit

Permalink
tests: Add the new unittests to the CMakefile.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Jan 27, 2025
1 parent 9eb018c commit 1683249
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ add_boost_test(base
icinga_checkresult/service_flapping_notification
icinga_checkresult/suppressed_notification
icinga_dependencies/multi_parent
icinga_dependencies/default_redundancy_group_registration_unregistration
icinga_dependencies/simple_redundancy_group_registration_unregistration
icinga_dependencies/mixed_redundancy_group_registration_unregsitration
icinga_notification/strings
icinga_notification/state_filter
icinga_notification/type_filter
Expand Down
28 changes: 27 additions & 1 deletion test/icinga-dependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ BOOST_AUTO_TEST_CASE(multi_parent)

BOOST_CHECK(childHost->IsReachable() == false);

Dependency::Ptr duplicateDep (CreateDependency(parentHost1, childHost, "dep4"));
duplicateDep->SetIgnoreSoftStates(false, true);
RegisterDependency(duplicateDep, "");
parentHost1->SetStateType(StateTypeSoft);

// It should still be unreachable, due to the duplicated dependency object above with ignore_soft_states set to false.
BOOST_CHECK(childHost->IsReachable() == false);
parentHost1->SetStateType(StateTypeHard);
DependencyGroup::Unregister(duplicateDep);

/* The only DNS server is DOWN.
* Expected result: childHost is unreachable.
*/
Expand Down Expand Up @@ -146,12 +156,28 @@ BOOST_AUTO_TEST_CASE(default_redundancy_group_registration_unregistration)
AssertCheckableRedundancyGroup(childHostC, 2, 1, 2);
BOOST_CHECK_EQUAL(1, DependencyGroup::GetRegistrySize());

Checkable::Ptr childHostD(CreateHost("D"));
Dependency::Ptr depDA(CreateDependency(depCA->GetParent(), childHostD, "depDA"));
RegisterDependency(depDA, "");
AssertCheckableRedundancyGroup(childHostD, 1, 1, 1);
BOOST_CHECK_EQUAL(2, DependencyGroup::GetRegistrySize());

Dependency::Ptr depDB(CreateDependency(depCB->GetParent(), childHostD, "depDB"));
RegisterDependency(depDB, "");
AssertCheckableRedundancyGroup(childHostD, 2, 1, 4);
AssertCheckableRedundancyGroup(childHostC, 2, 1, 4);
BOOST_CHECK_EQUAL(1, DependencyGroup::GetRegistrySize());

DependencyGroup::Unregister(depCA);
AssertCheckableRedundancyGroup(childHostC, 1, 1, 1);
DependencyGroup::Unregister(depDA);
AssertCheckableRedundancyGroup(childHostC, 1, 1, 2);
AssertCheckableRedundancyGroup(childHostD, 1, 1, 2);
BOOST_CHECK_EQUAL(1, DependencyGroup::GetRegistrySize());

DependencyGroup::Unregister(depCB);
DependencyGroup::Unregister(depDB);
AssertCheckableRedundancyGroup(childHostC, 0, 0, 0);
AssertCheckableRedundancyGroup(childHostD, 0, 0, 0);
BOOST_CHECK_EQUAL(0, DependencyGroup::GetRegistrySize());
}

Expand Down

0 comments on commit 1683249

Please sign in to comment.