From caafaeafd4843c4cda626b700564d8951eb30927 Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Mon, 12 Oct 2026 17:43:52 +0200 Subject: [PATCH] Tests: the push recording handler survives the parallel fan-out PushDeliveryService sends with Parallel.ForEachAsync, and RecordingHandler appended to plain lists without a lock: two concurrent sends could lose a request (Delivered 2, recorded 1), so Tenant_alert_also_reaches_platform_devices_whose_owners_home_tenant_it_is failed now and then (once in six full runs while it was traced). A request and its body are now recorded together under the lock. Co-Authored-By: Claude Opus 5.5 --- .../Push/PushPairingServiceTests.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Backend/AutopilotMonitor.Functions.Tests/Push/PushPairingServiceTests.cs b/src/Backend/AutopilotMonitor.Functions.Tests/Push/PushPairingServiceTests.cs index a9b9ed95..7988b46e 100644 --- a/src/Backend/AutopilotMonitor.Functions.Tests/Push/PushPairingServiceTests.cs +++ b/src/Backend/AutopilotMonitor.Functions.Tests/Push/PushPairingServiceTests.cs @@ -440,8 +440,13 @@ public class PushPairingServiceTests protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - Requests.Add(request); - Bodies.Add(request.Content == null ? Array.Empty() : await request.Content.ReadAsByteArrayAsync(cancellationToken)); + var body = request.Content == null ? Array.Empty() : await request.Content.ReadAsByteArrayAsync(cancellationToken); + // PushDeliveryService fans out in parallel: an unguarded List.Add loses entries. + lock (Requests) + { + Requests.Add(request); + Bodies.Add(body); + } return new HttpResponseMessage(Respond(request)) { Content = new StringContent(string.Empty) }; } }