Files
natsdotnet/tests/NATS.E2E.Tests/Infrastructure/JetStreamServerFixture.cs
Joseph Doherty c30e67a69d 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
2026-03-12 14:09:23 -04:00

46 lines
1.2 KiB
C#

using NATS.Client.Core;
namespace NATS.E2E.Tests.Infrastructure;
public sealed class JetStreamServerFixture : IAsyncLifetime
{
private NatsServerProcess _server = null!;
private string _storeDir = null!;
public int Port => _server.Port;
public async Task InitializeAsync()
{
_storeDir = Path.Combine(Path.GetTempPath(), "nats-e2e-js-" + Guid.NewGuid().ToString("N")[..8]);
Directory.CreateDirectory(_storeDir);
var config = $$"""
jetstream {
store_dir: "{{_storeDir}}"
max_mem_store: 64mb
max_file_store: 256mb
}
""";
_server = NatsServerProcess.WithConfig(config);
await _server.StartAsync();
}
public async Task DisposeAsync()
{
await _server.DisposeAsync();
if (_storeDir is not null && Directory.Exists(_storeDir))
{
try { Directory.Delete(_storeDir, recursive: true); }
catch { /* best-effort cleanup */ }
}
}
public NatsConnection CreateClient()
=> new(new NatsOpts { Url = $"nats://127.0.0.1:{Port}" });
}
[CollectionDefinition("E2E-JetStream")]
public class JetStreamCollection : ICollectionFixture<JetStreamServerFixture>;