Skip to content

Commit 1683249

Browse files
committed
tests: Add the new unittests to the CMakefile.txt
1 parent 9eb018c commit 1683249

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ add_boost_test(base
230230
icinga_checkresult/service_flapping_notification
231231
icinga_checkresult/suppressed_notification
232232
icinga_dependencies/multi_parent
233+
icinga_dependencies/default_redundancy_group_registration_unregistration
234+
icinga_dependencies/simple_redundancy_group_registration_unregistration
235+
icinga_dependencies/mixed_redundancy_group_registration_unregsitration
233236
icinga_notification/strings
234237
icinga_notification/state_filter
235238
icinga_notification/type_filter

test/icinga-dependencies.cpp

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ BOOST_AUTO_TEST_CASE(multi_parent)
9898

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

101+
Dependency::Ptr duplicateDep (CreateDependency(parentHost1, childHost, "dep4"));
102+
duplicateDep->SetIgnoreSoftStates(false, true);
103+
RegisterDependency(duplicateDep, "");
104+
parentHost1->SetStateType(StateTypeSoft);
105+
106+
// It should still be unreachable, due to the duplicated dependency object above with ignore_soft_states set to false.
107+
BOOST_CHECK(childHost->IsReachable() == false);
108+
parentHost1->SetStateType(StateTypeHard);
109+
DependencyGroup::Unregister(duplicateDep);
110+
101111
/* The only DNS server is DOWN.
102112
* Expected result: childHost is unreachable.
103113
*/
@@ -146,12 +156,28 @@ BOOST_AUTO_TEST_CASE(default_redundancy_group_registration_unregistration)
146156
AssertCheckableRedundancyGroup(childHostC, 2, 1, 2);
147157
BOOST_CHECK_EQUAL(1, DependencyGroup::GetRegistrySize());
148158

159+
Checkable::Ptr childHostD(CreateHost("D"));
160+
Dependency::Ptr depDA(CreateDependency(depCA->GetParent(), childHostD, "depDA"));
161+
RegisterDependency(depDA, "");
162+
AssertCheckableRedundancyGroup(childHostD, 1, 1, 1);
163+
BOOST_CHECK_EQUAL(2, DependencyGroup::GetRegistrySize());
164+
165+
Dependency::Ptr depDB(CreateDependency(depCB->GetParent(), childHostD, "depDB"));
166+
RegisterDependency(depDB, "");
167+
AssertCheckableRedundancyGroup(childHostD, 2, 1, 4);
168+
AssertCheckableRedundancyGroup(childHostC, 2, 1, 4);
169+
BOOST_CHECK_EQUAL(1, DependencyGroup::GetRegistrySize());
170+
149171
DependencyGroup::Unregister(depCA);
150-
AssertCheckableRedundancyGroup(childHostC, 1, 1, 1);
172+
DependencyGroup::Unregister(depDA);
173+
AssertCheckableRedundancyGroup(childHostC, 1, 1, 2);
174+
AssertCheckableRedundancyGroup(childHostD, 1, 1, 2);
151175
BOOST_CHECK_EQUAL(1, DependencyGroup::GetRegistrySize());
152176

153177
DependencyGroup::Unregister(depCB);
178+
DependencyGroup::Unregister(depDB);
154179
AssertCheckableRedundancyGroup(childHostC, 0, 0, 0);
180+
AssertCheckableRedundancyGroup(childHostD, 0, 0, 0);
155181
BOOST_CHECK_EQUAL(0, DependencyGroup::GetRegistrySize());
156182
}
157183

0 commit comments

Comments
 (0)