MCPcopy Create free account
hub / github.com/Icinga/icinga2 / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

test/methods-pluginnotificationtask.cpp:19–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17BOOST_AUTO_TEST_SUITE(methods_pluginnotificationtask)
18
19BOOST_AUTO_TEST_CASE(truncate_long_output)
20{
21#ifdef __linux__
22 Host::Ptr h = new Host();
23 CheckResult::Ptr hcr = new CheckResult();
24 CheckResult::Ptr scr = new CheckResult();
25 Service::Ptr s = new Service();
26 User::Ptr u = new User();
27 NotificationCommand::Ptr nc = new NotificationCommand();
28 Notification::Ptr n = new Notification();
29 String placeHolder (1024 * 1024, 'x');
30 std::promise<String> promise;
31 auto future (promise.get_future());
32
33 hcr->SetOutput("H" + placeHolder + "h", true);
34 scr->SetOutput("S" + placeHolder + "s", true);
35
36 h->SetName("example.com", true);
37 h->SetLastCheckResult(hcr, true);
38 h->Register();
39
40 s->SetHostName("example.com", true);
41 s->SetShortName("disk", true);
42 s->SetLastCheckResult(scr, true);
43 s->OnAllConfigLoaded(); // link Host
44
45 nc->SetCommandLine(
46 new Array({
47 "echo",
48 "host_output=$host.output$",
49 "service_output=$service.output$",
50 "notification_comment=$notification.comment$",
51 "output=$output$",
52 "comment=$comment$"
53 }),
54 true
55 );
56
57 nc->SetName("mail", true);
58 nc->Register();
59
60 n->SetFieldByName("host_name", "example.com", DebugInfo());
61 n->SetFieldByName("service_name", "disk", DebugInfo());
62 n->SetFieldByName("command", "mail", DebugInfo());
63 n->OnAllConfigLoaded(); // link Service
64
65 Checkable::ExecuteCommandProcessFinishedHandler = [&promise](const Value&, const ProcessResult& pr) {
66 promise.set_value(pr.Output);
67 };
68
69 PluginNotificationTask::ScriptFunc(n, u, nullptr, NotificationCustom, "jdoe", "C" + placeHolder + "c", nullptr, false);
70 future.wait();
71
72 Checkable::ExecuteCommandProcessFinishedHandler = nullptr;
73 h->Unregister();
74 nc->Unregister();
75
76 auto output (future.get());

Callers

nothing calls this directly

Calls 8

DebugInfoClass · 0.50
SetNameMethod · 0.45
RegisterMethod · 0.45
OnAllConfigLoadedMethod · 0.45
SetFieldByNameMethod · 0.45
UnregisterMethod · 0.45
getMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected