Fix E2E test gaps and add comprehensive E2E + parity test suites
- Fix pull consumer fetch: send original stream subject in HMSG (not inbox) so NATS client distinguishes data messages from control messages - Fix MaxAge expiry: add background timer in StreamManager for periodic pruning - Fix JetStream wire format: Go-compatible anonymous objects with string enums, proper offset-based pagination for stream/consumer list APIs - Add 42 E2E black-box tests (core messaging, auth, TLS, accounts, JetStream) - Add ~1000 parity tests across all subsystems (gaps closure) - Update gap inventory docs to reflect implementation status
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Buffers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace NATS.Server.Protocol;
|
||||
@@ -80,7 +81,14 @@ public sealed class NatsParser
|
||||
|
||||
// Control line size check
|
||||
if (line.Length > NatsProtocol.MaxControlLineSize)
|
||||
throw new ProtocolViolationException("Maximum control line exceeded");
|
||||
{
|
||||
var snippetLength = (int)Math.Min(line.Length, NatsProtocol.MaxControlLineSnippetSize);
|
||||
var snippetBytes = new byte[snippetLength];
|
||||
line.Slice(0, snippetLength).CopyTo(snippetBytes);
|
||||
var snippet = ProtoSnippet(0, NatsProtocol.MaxControlLineSnippetSize, snippetBytes);
|
||||
throw new ProtocolViolationException(
|
||||
$"Maximum control line exceeded (max={NatsProtocol.MaxControlLineSize}, len={line.Length}, snip={snippet}...)");
|
||||
}
|
||||
|
||||
// Get line as contiguous span
|
||||
Span<byte> lineSpan = stackalloc byte[(int)line.Length];
|
||||
@@ -95,7 +103,7 @@ public sealed class NatsParser
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new ProtocolViolationException("Unknown protocol operation");
|
||||
throw new ProtocolViolationException($"Unknown protocol operation: {ProtoSnippet(lineSpan)}");
|
||||
}
|
||||
|
||||
byte b0 = (byte)(lineSpan[0] | 0x20); // lowercase
|
||||
@@ -192,9 +200,29 @@ public sealed class NatsParser
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new ProtocolViolationException("Unknown protocol operation");
|
||||
throw new ProtocolViolationException($"Unknown protocol operation: {ProtoSnippet(lineSpan)}");
|
||||
}
|
||||
|
||||
// Go reference: parser.go protoSnippet(start, max, buf).
|
||||
internal static string ProtoSnippet(int start, int max, ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
if (start >= buffer.Length)
|
||||
return "\"\"";
|
||||
|
||||
var stop = start + max;
|
||||
if (stop > buffer.Length)
|
||||
stop = buffer.Length - 1;
|
||||
|
||||
if (stop <= start)
|
||||
return "\"\"";
|
||||
|
||||
var slice = buffer[start..stop];
|
||||
return JsonSerializer.Serialize(Encoding.ASCII.GetString(slice));
|
||||
}
|
||||
|
||||
internal static string ProtoSnippet(ReadOnlySpan<byte> buffer) =>
|
||||
ProtoSnippet(0, NatsProtocol.ProtoSnippetSize, buffer);
|
||||
|
||||
private bool ParsePub(
|
||||
Span<byte> line,
|
||||
ref ReadOnlySequence<byte> buffer,
|
||||
|
||||
Reference in New Issue
Block a user