From 71803b97f1c9e31f2027da48bb742353f9c43e62 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 23 Sep 2025 13:31:26 +0100 Subject: Write unparsable lines to the entity table Diagnostics and the ability to ingest later. --- test/test-ingest.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'test/test-ingest.cpp') diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp index 1ac6167..722763a 100644 --- a/test/test-ingest.cpp +++ b/test/test-ingest.cpp @@ -3,6 +3,7 @@ #include #include "test-util.hpp" +#include #include #include @@ -29,10 +30,31 @@ namespace std { { return std::apply( [&strm](auto &&... elems) -> decltype(auto) { - return ((strm << elems << '\n'), ...); + return ((strm << '{' << elems << ", "), ...) << '}'; }, values); } + + template + ostream & + operator<<(ostream & strm, const DB::Row & row) + { + return [&](std::integer_sequence) -> decltype(auto) { + return ((strm << '{' << row.template get() << ", "), ...) << '}'; + }(std::make_integer_sequence()); + } +} + +namespace DB { + template + bool + operator!=(const Row & row, const std::tuple & expected) + { + return [&](std::integer_sequence) { + return std::make_tuple(row.template get()...); + }(std::make_integer_sequence()) + != expected; + } } BOOST_DATA_TEST_CASE(QuotedStringsGood, @@ -222,6 +244,18 @@ BOOST_AUTO_TEST_CASE(FetchMockUserAgentDetail) } } +BOOST_AUTO_TEST_CASE(DiscardUnparsable) +{ + BOOST_REQUIRE_NO_THROW(ingestLogLine("does not parse")); + auto dbconn = dbpool->get(); + auto select = dbconn->select("SELECT id, value FROM entities WHERE type = 'unparsable_line'"); + constexpr std::array, 1> EXPECTED {{ + {1664299262, "does not parse"}, + }}; + auto rows = select->as(); + BOOST_CHECK_EQUAL_COLLECTIONS(rows.begin(), rows.end(), EXPECTED.begin(), EXPECTED.end()); +} + BOOST_AUTO_TEST_SUITE_END(); BOOST_AUTO_TEST_CASE(FetchRealUserAgentDetail, *boost::unit_test::disabled()) -- cgit v1.2.3