icinga2/test/perfdata-gelfwriter.cpp
Johannes Schmidt 79921ef09a Relax all timeouts for PerfdataWriterConnection test-cases
This isn't strictly necessary, but since tests are now running
in parallel, it doesn't hurt to give slower machines more time
to complete these tests and this gives a little more headroom
for potential changes that subtly affect the behavor of the
components involved (like boost new versions).
2026-04-29 12:46:29 +02:00

48 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: 2026 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
#include <BoostTestTargetConfig.h>
#include "perfdata/gelfwriter.hpp"
#include "test/base-testloggerfixture.hpp"
#include "test/perfdata-perfdatawriterfixture.hpp"
#include "test/utils.hpp"
using namespace icinga;
BOOST_FIXTURE_TEST_SUITE(perfdata_gelfwriter, PerfdataWriterFixture<GelfWriter>,
*boost::unit_test::label("perfdata")
*boost::unit_test::label("network")
)
BOOST_AUTO_TEST_CASE(connect)
{
ResumeWriter();
ReceiveCheckResults(1, ServiceState::ServiceCritical);
Accept();
Dictionary::Ptr resp = JsonDecode(GetDataUntil('\0'));
// Just some basic sanity tests. It's not important to check if everything is entirely
// correct here.
BOOST_CHECK_CLOSE(resp->Get("timestamp").Get<double>(), Utility::GetTime(), 0.5);
BOOST_CHECK_EQUAL(resp->Get("_check_command"), "dummy");
BOOST_CHECK_EQUAL(resp->Get("_hostname"), "h1");
PauseWriter();
}
BOOST_AUTO_TEST_CASE(pause_with_pending_work)
{
ResumeWriter();
// Process check-results until the writer is stuck.
BOOST_REQUIRE_MESSAGE(GetWriterStuck(20s), "Failed to get Writer stuck.");
// Now stop reading and try to pause OpenTsdbWriter.
PauseWriter();
REQUIRE_LOG_MESSAGE("Connection stopped\\.", 10s);
REQUIRE_LOG_MESSAGE("'GelfWriter' paused\\.", 1s);
}
BOOST_AUTO_TEST_SUITE_END()