fix(site-event-logging): resolve SiteEventLogging-012..014 — fault dropped-event tasks, escape LIKE wildcards, re-triage startup-purge finding (Won't Fix)

This commit is contained in:
Joseph Doherty
2026-05-17 03:18:41 -04:00
parent a58cec5776
commit 6d63fef934
6 changed files with 226 additions and 23 deletions

View File

@@ -254,6 +254,50 @@ public class EventLogQueryServiceTests : IDisposable
Assert.Equal("{\"stack\":\"trace\"}", entry.Details);
}
[Fact]
public async Task Query_KeywordSearch_TreatsUnderscoreAsLiteral_NotWildcard()
{
// SiteEventLogging-013: a SQL LIKE '_' matches any single character. A
// keyword search for a literal underscore (common in identifiers such as
// "store_and_forward") must NOT match strings that merely have any
// character in that position.
await _eventLogger.LogEventAsync("script", "Info", null, "store_and_forward", "Buffer queued");
await _eventLogger.LogEventAsync("script", "Info", null, "storeXandYforward", "Other event");
var response = _queryService.ExecuteQuery(MakeRequest(keyword: "store_and_forward"));
Assert.True(response.Success);
Assert.Single(response.Entries);
Assert.Equal("store_and_forward", response.Entries[0].Source);
}
[Fact]
public async Task Query_KeywordSearch_TreatsPercentAsLiteral_NotWildcard()
{
// SiteEventLogging-013: a SQL LIKE '%' matches any run of characters. A
// keyword search containing a literal '%' must match only the literal.
await _eventLogger.LogEventAsync("script", "Warning", null, "ScriptActor:Run", "CPU at 90% utilisation");
await _eventLogger.LogEventAsync("script", "Warning", null, "ScriptActor:Run", "CPU at 90 then 0 utilisation");
var response = _queryService.ExecuteQuery(MakeRequest(keyword: "90% utilisation"));
Assert.True(response.Success);
Assert.Single(response.Entries);
Assert.Contains("90% utilisation", response.Entries[0].Message);
}
[Fact]
public async Task Query_KeywordSearch_StillMatchesPlainSubstring()
{
// Escaping wildcards must not break ordinary substring search.
await SeedEvents();
var response = _queryService.ExecuteQuery(MakeRequest(keyword: "timeout"));
Assert.True(response.Success);
Assert.Single(response.Entries);
}
private void InsertEventAt(DateTimeOffset timestamp, string eventType, string severity, string? instanceId, string source, string message)
{
_eventLogger.WithConnection(connection =>