[CI] [SKIP TESTS] Add detailed Probe-Agent connection diagnostics
This commit is contained in:
1 parent
0fd38b2367
commit
a7ebf61551
16 files changed
+376
-51
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@@ -31,11 +32,23 @@ public sealed class MsQuicConnectionTests
|
||||
[Fact]
|
||||
public async Task DatagramConnection_CanSendCloseAndReconnect_WithoutBlockingNativeWorkers()
|
||||
{
|
||||
var log = new CaptureLog();
|
||||
var counters = new DataPlaneCounters();
|
||||
var router = new MeasurementDatagramRouter(new SingleSession(new DataSession(1, new byte[32])), null,
|
||||
new MonoClock(TimeProvider.System), counters, log);
|
||||
using ECDsa key = ECDsa.Create(ECCurve.NamedCurves.nistP256);
|
||||
var request = new CertificateRequest("CN=localhost", key, HashAlgorithmName.SHA256);
|
||||
using X509Certificate2 certificate = request.CreateSelfSigned(DateTimeOffset.UnixEpoch, DateTimeOffset.UnixEpoch.AddYears(100));
|
||||
await using var listener = new MsQuicListener(IPAddress.Loopback, [0], certificate,
|
||||
(connection, data) => connection.Send(data), NullNodeLog.Instance, null);
|
||||
(connection, data) =>
|
||||
{
|
||||
// Bad measurement payloads must be counted without flooding logs.
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
router.Dispatch(connection, data);
|
||||
}
|
||||
connection.Send(data);
|
||||
}, log, null);
|
||||
listener.Start();
|
||||
|
||||
for (int attempt = 0; attempt < 3; attempt++)
|
||||
@@ -43,7 +56,7 @@ public sealed class MsQuicConnectionTests
|
||||
var reply = new TaskCompletionSource<byte[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||
MsQuicConnection client = await MsQuicConnection.ConnectAsync(IPAddress.Loopback, listener.BoundPorts[0], 0,
|
||||
key.ExportSubjectPublicKeyInfo(), (_, data) => reply.TrySetResult(data.ToArray()), NullNodeLog.Instance, timeout.Token);
|
||||
key.ExportSubjectPublicKeyInfo(), (_, data) => reply.TrySetResult(data.ToArray()), log, timeout.Token);
|
||||
try
|
||||
{
|
||||
while (!client.IsReady)
|
||||
@@ -72,6 +85,22 @@ public sealed class MsQuicConnectionTests
|
||||
await client.WaitForShutdownAsync().WaitAsync(TimeSpan.FromSeconds(3));
|
||||
}
|
||||
}
|
||||
Assert.True(counters.DroppedInvalid >= 300);
|
||||
var dropped = Assert.Single(log.Items, x => x.Message == "measurement datagram dropped");
|
||||
Assert.Equal("invalid_header", dropped.Fields["reason"]);
|
||||
Assert.NotNull(dropped.Fields["remote"]);
|
||||
Assert.NotNull(dropped.Fields["quic_id"]);
|
||||
var connected = log.Items.Where(x => x.Message == "MsQuic QUIC handshake completed").ToArray();
|
||||
Assert.Equal(6, connected.Select(x => x.Fields["quic_id"]).Distinct().Count());
|
||||
Assert.All(connected, entry => Assert.NotNull(entry.Fields["remote"]));
|
||||
Assert.DoesNotContain(log.Items.SelectMany(x => x.Fields.Keys), key => key is "key" or "session_id" or "mac" or "signature");
|
||||
}
|
||||
|
||||
private sealed class CaptureLog : INodeLog
|
||||
{
|
||||
public ConcurrentQueue<(string Message, Dictionary<string, object?> Fields)> Items { get; } = new();
|
||||
|
||||
public void Write(NodeLogLevel level, string message, params (string Key, object? Value)[] fields) =>
|
||||
Items.Enqueue((message, fields.ToDictionary(x => x.Key, x => x.Value)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user