icinga2/test/utils.hpp
Johannes Schmidt 75b2ec6d96 Add unit-tests for PerfdataWriterConnection
There's a set of two tests for each perfdatawriter, just
to make sure they can connect and send data that looks reasonably
correct, and to make sure pausing actually works while the connection
is stuck.

Then there's a more in-depth suite of tests for PerfdataWriterConnection
itself, to verify that connection handling works well in all types
of scenarios.

Co-authored-by: Yonas Habteab <yonas.habteab@icinga.com>
2026-03-17 12:11:30 +01:00

37 lines
909 B
C++

// SPDX-FileCopyrightText: 2025 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "icinga/host.hpp"
#include <ctime>
#include <functional>
#include <string>
tm make_tm(std::string s);
struct GlobalTimezoneFixture
{
/**
* Timezone used for testing DST changes.
*
* DST changes in America/Los_Angeles:
* 2021-03-14: 01:59:59 PST (UTC-8) -> 03:00:00 PDT (UTC-7)
* 2021-11-07: 01:59:59 PDT (UTC-7) -> 01:00:00 PST (UTC-8)
*/
static const char *TestTimezoneWithDST;
GlobalTimezoneFixture(const char *fixed_tz = "");
~GlobalTimezoneFixture();
char *tz;
};
std::string GetRandomString(std::string prefix, std::size_t length);
void ReceiveCheckResults(
const icinga::Checkable::Ptr& host,
std::size_t num,
icinga::ServiceState state,
const std::function<void(const icinga::CheckResult::Ptr&)>& fn = {}
);