summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2026-05-02 18:58:21 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2026-05-02 18:58:21 +0100
commit4675ab65ea5e807e0d457845a0ca84edcf1262c9 (patch)
treec8e0adae9cfefe6643f03b797283b3012e07b2d3 /test
parent5c0206f48dc7f90009629d0a74bdc1dd6b4f67ea (diff)
downloadwebstat-4675ab65ea5e807e0d457845a0ca84edcf1262c9.tar.bz2
webstat-4675ab65ea5e807e0d457845a0ca84edcf1262c9.tar.xz
webstat-4675ab65ea5e807e0d457845a0ca84edcf1262c9.zip
Ingest log lines in a background thread
This prevents halting reading input during data insertion.
Diffstat (limited to 'test')
-rw-r--r--test/test-ingest.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp
index 6ed50ab..60338a2 100644
--- a/test/test-ingest.cpp
+++ b/test/test-ingest.cpp
@@ -297,7 +297,7 @@ BOOST_AUTO_TEST_CASE(ParkLogLine)
{
queuedLines.emplace_back(LOGLINE1);
queuedLines.emplace_back(LOGLINE2);
- const auto path = parkQueuedLogLines();
+ const auto path = parkLogLines(queuedLines);
BOOST_REQUIRE(path);
BOOST_TEST_INFO(*path);
BOOST_REQUIRE(std::filesystem::exists(*path));
@@ -317,7 +317,7 @@ BOOST_AUTO_TEST_CASE(IngestParked, *boost::unit_test::depends_on("I/ParkLogLine"
{
queuedLines.emplace_back(LOGLINE1);
queuedLines.emplace_back(LOGLINE2);
- BOOST_REQUIRE(parkQueuedLogLines());
+ BOOST_REQUIRE(parkLogLines(queuedLines));
BOOST_CHECK(!std::filesystem::is_empty(settings.fallbackDir));
BOOST_REQUIRE(queuedLines.empty());
const auto result = jobReadParkedLines();
@@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(IngestParkedJob,
const auto now = Job::LastRunTime::clock::now();
ingestParkedLines.lastRun = now - 1s;
queuedLines.emplace_back(LOGLINE1);
- const auto path = parkQueuedLogLines();
+ const auto path = parkLogLines(queuedLines);
BOOST_REQUIRE(path);
BOOST_REQUIRE(queuedLines.empty());
BOOST_REQUIRE(std::filesystem::exists(*path));
@@ -374,7 +374,7 @@ BOOST_AUTO_TEST_CASE(JobErrorRescheduler, *boost::unit_test::depends_on("I/Inges
const auto now = Job::LastRunTime::clock::now();
ingestParkedLines.lastRun = now - settings.freqIngestParkedLines - 1s;
queuedLines.emplace_back(LOGLINE1);
- const auto path = parkQueuedLogLines();
+ const auto path = parkLogLines(queuedLines);
BOOST_REQUIRE(path);
std::filesystem::permissions(*path, std::filesystem::perms::owner_write);
runJobsAsNeeded();
@@ -405,7 +405,10 @@ BOOST_AUTO_TEST_CASE(FetchMockUserAgentDetail)
BOOST_AUTO_TEST_CASE(DiscardUnparsable)
{
queuedLines.emplace_back("does not parse");
- BOOST_REQUIRE_NO_THROW(tryIngestQueuedLogLines());
+ auto job = beginIngestQueuedLogLines();
+ BOOST_CHECK_EQUAL(&job.first, &*storeQueueLines.currentRun);
+ BOOST_CHECK(job.second);
+ finishAllJobs();
auto dbconn = dbpool->get();
auto select = dbconn->select("SELECT id::bigint, value FROM entities WHERE type = 'unparsable_line'");
constexpr std::array<std::tuple<EntityId, std::string_view>, 1> EXPECTED {{