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 <noreply@anthropic.com>
This commit is contained in:
Oliver Kieselbach
2026-10-12 17:43:52 +02:00
parent bfb6c12384
commit caafaeafd4
@@ -440,8 +440,13 @@ public class PushPairingServiceTests
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Requests.Add(request);
Bodies.Add(request.Content == null ? Array.Empty<byte>() : await request.Content.ReadAsByteArrayAsync(cancellationToken));
var body = request.Content == null ? Array.Empty<byte>() : 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) };
}
}