From f5ec6d4e769e06c75bd2233a06818baf0c7d8ba7 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Sat, 24 Oct 2026 03:41:39 -0400 Subject: [PATCH 1/2] Darling alert text: the word agrees with the source count (#6700) --- .../CollectionHistoryAuditTests.cs | 16 ++++++++++++++ .../ExternalAlertDeliverySelfAlertTests.cs | 21 ++++++++++++++++++- .../CollectionHistoryAudit.cs | 2 +- .../DarlingSelfAlertEvaluator.cs | 6 ++++-- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Darling/Darling.Tests/CollectionHistoryAuditTests.cs b/Darling/Darling.Tests/CollectionHistoryAuditTests.cs index 077e0b5754..5147d1951d 100644 --- a/Darling/Darling.Tests/CollectionHistoryAuditTests.cs +++ b/Darling/Darling.Tests/CollectionHistoryAuditTests.cs @@ -399,6 +399,22 @@ public void TheAuditedSources_AreTheLiveHourlyAggregatesForServers_AndThePerfmon Assert.Contains("collection_time", TimescaleSupport.CreatePerfmonIntervalBaselineSql, StringComparison.Ordinal); } + [Fact] + public void TheSourceCount_AgreesWithTheWord_ForOneSourceAndForMore() + { + /* #6700: "in 1 source," not "in 1 source(s),". */ + var shared = new[] { new CollectionHistoryAudit.FlaggedRange(18, 21, 0, 40, 0, 0) }; + var a = new Rollup("collect.query_store_stats_hourly", false); + var b = new Rollup("collect.query_store_stats_corrected_hourly", false); + + var one = CollectionHistoryAudit.Render(AuditDay, new (Rollup, IReadOnlyList)[] { (a, shared) }); + Assert.Contains("for that hour in 1 source, where usual", one, StringComparison.Ordinal); + + var two = CollectionHistoryAudit.Render(AuditDay, new (Rollup, IReadOnlyList)[] { (a, shared), (b, shared) }); + Assert.Contains("for that hour in 2 sources, where usual", two, StringComparison.Ordinal); + Assert.DoesNotContain("(s)", two, StringComparison.Ordinal); + } + [Fact] public void SourcesWithIdenticalFlaggedRanges_ShareOneLine_AndUnreadSourcesAreNamed() { diff --git a/Darling/Darling.Tests/ExternalAlertDeliverySelfAlertTests.cs b/Darling/Darling.Tests/ExternalAlertDeliverySelfAlertTests.cs index ee92881362..6eecf024f0 100644 --- a/Darling/Darling.Tests/ExternalAlertDeliverySelfAlertTests.cs +++ b/Darling/Darling.Tests/ExternalAlertDeliverySelfAlertTests.cs @@ -55,6 +55,7 @@ public async Task Undelivered_FiresOnceWithTheCountsPerSource_AndNeverRepeatsASu Assert.Equal("externalalerts", fired.ServerKey); Assert.Equal(DarlingSelfAlertEvaluator.StoreServerLabel, fired.ServerName); Assert.Equal("7", fired.CurrentValue); + Assert.Contains("7 external alerts were not delivered in the last hour", fired.ShortMessage); Assert.Contains("2 expired, 4 interrupted, 1 failed", fired.ShortMessage); Assert.Contains("- Source backup_svc: 2 expired, 1 failed", fired.DetailText); Assert.Contains("- Source etl: 4 interrupted", fired.DetailText); @@ -118,7 +119,25 @@ public async Task Undelivered_ListsAtMostTwentySources_AndTheCountReflectsAll() Assert.Equal("25", fired.CurrentValue); Assert.Contains("- Source src19:", fired.DetailText); Assert.DoesNotContain("- Source src20:", fired.DetailText); - Assert.Contains("+ 5 more source(s).", fired.DetailText); + Assert.Contains("+ 5 more sources.", fired.DetailText); + } + + [Fact] + public async Task Undelivered_TheWordsAgreeWithTheCounts_ForOneAlertAndForOneUnlistedSource() + { + /* #6700: "1 external alert was not delivered", not "1 external alert(s) were"; the 21st source is "1 more source.". */ + var one = new DarlingSelfAlertTests.Harness(); + await one.Build().ApplyExternalAlertsAsync(Report(("etl", "failed", 1)), Ct); + var single = Assert.Single(one.Deliverer.Outcomes); + Assert.StartsWith("1 external alert was not delivered in the last hour", single.ShortMessage); + Assert.DoesNotContain("(s)", single.DetailText); + + var h = new DarlingSelfAlertTests.Harness(); + var rows = Enumerable.Range(0, 21).Select(i => ("src" + i.ToString("D2", CultureInfo.InvariantCulture), "expired", 1)).ToArray(); + await h.Build().ApplyExternalAlertsAsync(Report(rows), Ct); + var fired = Assert.Single(h.Deliverer.Outcomes); + Assert.Contains("+ 1 more source.", fired.DetailText); + Assert.DoesNotContain("(s)", fired.DetailText); } [Fact] diff --git a/Darling/PerformanceMonitor.Darling.Service/CollectionHistoryAudit.cs b/Darling/PerformanceMonitor.Darling.Service/CollectionHistoryAudit.cs index 44c81c4d59..101533599f 100644 --- a/Darling/PerformanceMonitor.Darling.Service/CollectionHistoryAudit.cs +++ b/Darling/PerformanceMonitor.Darling.Service/CollectionHistoryAudit.cs @@ -423,7 +423,7 @@ internal static string Render( { var text = new StringBuilder(); text.Append(CultureInfo.InvariantCulture, - $"Retained history for {auditDayUtc:yyyy-MM-dd} (UTC) fell below half of the usual pace for that hour in {findings.Count} source(s), ") + $"Retained history for {auditDayUtc:yyyy-MM-dd} (UTC) fell below half of the usual pace for that hour in {findings.Count} {(findings.Count == 1 ? "source" : "sources")}, ") .Append("where usual is the median of the 7 days before and only servers enabled now are counted. "); var groups = new List<(bool JudgesPasses, bool Incomplete, List Sources, IReadOnlyList Ranges)>(); diff --git a/Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs b/Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs index ddb13c3661..07f5ef1917 100644 --- a/Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs +++ b/Darling/PerformanceMonitor.Darling.Service/DarlingSelfAlertEvaluator.cs @@ -5343,7 +5343,7 @@ await RecordResolutionAsync(new AlertResolution( private static (string ShortMessage, string Detail) RenderExternalAlerts(ExternalAlertsReport report) { var shortMessage = string.Create(CultureInfo.InvariantCulture, - $"{report.Total} external alert(s) were not delivered in the last hour: {report.Of("expired")} expired, {report.Of("interrupted")} interrupted, {report.Of("failed")} failed to send"); + $"{report.Total} external {(report.Total == 1 ? "alert was" : "alerts were")} not delivered in the last hour: {report.Of("expired")} expired, {report.Of("interrupted")} interrupted, {report.Of("failed")} failed to send"); var sb = new StringBuilder(); sb.Append(shortMessage).Append('.'); @@ -5359,7 +5359,9 @@ private static (string ShortMessage, string Detail) RenderExternalAlerts(Externa if (perSource.Count > MaxListedExternalSources) { - sb.Append("\n+ ").Append((perSource.Count - MaxListedExternalSources).ToString(CultureInfo.InvariantCulture)).Append(" more source(s)."); + /* #6700: "1 more source." / "N more sources." */ + var unlisted = perSource.Count - MaxListedExternalSources; + sb.Append("\n+ ").Append(unlisted.ToString(CultureInfo.InvariantCulture)).Append(unlisted == 1 ? " more source." : " more sources."); } sb.Append("\nExpired: still queued when its deadline passed. Interrupted: a stopped service had claimed it and it is not sent again. Failed: every channel refused it and the retries ran out."); From d0590f79165888a997960d180d5c5cd3996b5a66 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Sat, 24 Oct 2026 04:25:23 -0400 Subject: [PATCH 2/2] Web audit-alert test reads an alert row stored before the source-count fix (#6700) --- Darling/Darling.Tests/WebPartialWindowBehaviourTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Darling/Darling.Tests/WebPartialWindowBehaviourTests.cs b/Darling/Darling.Tests/WebPartialWindowBehaviourTests.cs index 558af0ff83..ccd13d1604 100644 --- a/Darling/Darling.Tests/WebPartialWindowBehaviourTests.cs +++ b/Darling/Darling.Tests/WebPartialWindowBehaviourTests.cs @@ -193,7 +193,10 @@ public void TheCollectionHistoryAuditAlert_AgreesItsSourceCount_AndKeepsEveryOth { (sources[0], new[] { new CollectionHistoryAudit.FlaggedRange(18, 21, 0, 40, 0, 0) }), }, - sources.Skip(1).ToList()); + sources.Skip(1).ToList()) + // #6700: Render now says "in 1 source". An alert row stored before that fix still holds "in 1 source(s)", and + // that row is what the web rewrite is for, so the body here is the old row's text. + .Replace("in 1 source, where usual", "in 1 source(s), where usual", StringComparison.Ordinal); Assert.DoesNotContain('\n', rendered); Assert.Contains("in 1 source(s), where usual", rendered);