summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-10-06 20:43:52 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-10-06 20:43:52 +0100
commit63d6bf7395425be73fd6d9f5c89dc48817afffe6 (patch)
tree98a98671e7676202dcf24b1ef700a9240b999e78 /test
parent5aa9cca0d2ff25c541d7df3b63519c28eb75b656 (diff)
downloadwebstat-63d6bf7395425be73fd6d9f5c89dc48817afffe6.tar.bz2
webstat-63d6bf7395425be73fd6d9f5c89dc48817afffe6.tar.xz
webstat-63d6bf7395425be73fd6d9f5c89dc48817afffe6.zip
Add parked line import jobwebstat-0.2
Periodically, on idle, scan for and import previously parked lines.
Diffstat (limited to 'test')
-rw-r--r--test/test-ingest.cpp47
-rw-r--r--test/test-util.hpp2
2 files changed, 47 insertions, 2 deletions
diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp
index 73a37c6..388c440 100644
--- a/test/test-ingest.cpp
+++ b/test/test-ingest.cpp
@@ -259,6 +259,53 @@ BOOST_AUTO_TEST_CASE(ParkLogLineOnError)
BOOST_CHECK_EQUAL(linesParked, 1);
}
+BOOST_AUTO_TEST_CASE(IngestParked, *boost::unit_test::depends_on("I/ParkLogLine"))
+{
+ parkLogLine(LOGLINE1);
+ BOOST_REQUIRE_EQUAL(linesParked, 1);
+ BOOST_REQUIRE_EQUAL(linesParsed, 0);
+ jobIngestParkedLines();
+ BOOST_CHECK_EQUAL(linesParsed, 1);
+ BOOST_CHECK_EQUAL(linesDiscarded, 0);
+ BOOST_CHECK(!std::filesystem::exists(settings.fallbackDir / "parked-3377916038.log"));
+}
+
+BOOST_AUTO_TEST_CASE(IngestParkedJob, *boost::unit_test::depends_on("I/IngestParked"))
+{
+ const auto now = JobLastRunTime::clock::now();
+ lastRunIngestParkedLines = now - 1s;
+ parkLogLine(LOGLINE1);
+
+ runJobsIdle();
+ BOOST_REQUIRE_EQUAL(linesParked, 1);
+ BOOST_REQUIRE_EQUAL(linesParsed, 0);
+ BOOST_CHECK_EQUAL(lastRunIngestParkedLines, now - 1s);
+
+ lastRunIngestParkedLines = now - settings.freqIngestParkedLines + 2s;
+ BOOST_REQUIRE_EQUAL(linesParked, 1);
+ BOOST_REQUIRE_EQUAL(linesParsed, 0);
+ BOOST_CHECK_EQUAL(lastRunIngestParkedLines, now - settings.freqIngestParkedLines + 2s);
+
+ lastRunIngestParkedLines = now - settings.freqIngestParkedLines - 1s;
+ runJobsIdle();
+ BOOST_CHECK_EQUAL(linesParsed, 1);
+ BOOST_CHECK_EQUAL(linesDiscarded, 0);
+ BOOST_CHECK_GE(lastRunIngestParkedLines, now);
+ BOOST_CHECK(!std::filesystem::exists(settings.fallbackDir / "parked-3377916038.log"));
+}
+
+BOOST_AUTO_TEST_CASE(JobErrorRescheduler, *boost::unit_test::depends_on("I/IngestParkedJob"))
+{
+ const auto now = JobLastRunTime::clock::now();
+ lastRunIngestParkedLines = now - settings.freqIngestParkedLines - 1s;
+ parkLogLine(LOGLINE1);
+ std::filesystem::permissions(settings.fallbackDir / "parked-3377916038.log", std::filesystem::perms::owner_write);
+ runJobsIdle();
+ BOOST_CHECK(std::filesystem::exists(settings.fallbackDir / "parked-3377916038.log"));
+ BOOST_CHECK_GE(lastRunIngestParkedLines, now - (settings.freqIngestParkedLines / 2) - 1s);
+ BOOST_CHECK_LE(lastRunIngestParkedLines, now - (settings.freqIngestParkedLines / 2) + 1s);
+}
+
BOOST_AUTO_TEST_CASE(FetchMockUserAgentDetail)
{
const auto uaDetailReq = WebStat::curlGetUserAgentDetail(0,
diff --git a/test/test-util.hpp b/test/test-util.hpp
index ac96ee6..f933cba 100644
--- a/test/test-util.hpp
+++ b/test/test-util.hpp
@@ -16,8 +16,6 @@ namespace WebStat {
#undef XSTR
#undef STR
- using FilePtr = std::unique_ptr<std::FILE, DeleteWith<&fclose>>;
-
struct MockDB : public DB::PluginMock<PQ::Mock> {
MockDB();
};