sqlinsight-pro/tests/SQLInsight.Rules.Tests/RuleCatalogTests.cs
Søren Eggert Lundsteen Olsen e6840e40d7 SQL Server error log without elevated rights (8a)
A five-minute collector reads important error log entries from the best
source the agent's rights allow: the error log itself (xp_readerrorlog,
only with securityadmin), the default trace's ErrorLog and Audit Login
Failed events (optional ALTER TRACE), or the exception and connectivity
ring buffers (VIEW SERVER STATE: numbers and severity, failed logins).
Repetitions are summed per error; the watermark is the newest entry
read, because the default trace is buffered. Stored in
insight.ErrorLogEvents (migration 0013, EventDays), resumed after restart.

Rules SQLI-LOG-001..006: corruption 823/824/825, I/O over 15 s (833),
severe errors (17+), login failure bursts (configurable), stack dumps and
AG errors; rules needing the log text are "not measurable" with the
right to grant. Page /instanser/{navn}/fejllog (menu Overvågning) and
GET /api/v1/instances/{name}/error-log with messages redacted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-02 10:30:41 +02:00

23 lines
676 B
C#

using SQLInsight.Rules.Engine;
namespace SQLInsight.Rules.Tests;
public class RuleCatalogTests
{
[Fact]
public void Every_rule_has_a_unique_well_formed_id()
{
var rules = BuiltInRules.Create();
Assert.Equal(rules.Count, rules.Select(r => r.Id).Distinct(StringComparer.OrdinalIgnoreCase).Count());
Assert.All(rules, r => Assert.Matches("^SQLI-[A-Z]+-[0-9]{3}$", r.Id));
Assert.All(rules, r => Assert.False(string.IsNullOrWhiteSpace(r.Title)));
}
/// <summary>Keeps the rule count in the README honest.</summary>
[Fact]
public void Rule_count()
{
Assert.Equal(72, BuiltInRules.Create().Count);
}
}