From e0a87ca41f9231e2298696ba9c83d8e079d20820 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 1 Mar 2026 12:18:40 -0500 Subject: [PATCH] feat(batch50): merge JetStream cluster 1 tests and fix build errors - Added ShouldSkip() and ServerRuntimeUnavailable to IntegrationTestBase - Fixed WaitOnPeerCount -> WaitOnClusterReady - Fixed using -> await using for NatsConnection (IAsyncDisposable) - Removed duplicate PackageReference entries from csproj --- .../Helpers/IntegrationTestBase.cs | 13 +++++++++++++ .../JetStream/JetStreamCluster1Tests.cs | 8 ++++---- .../ZB.MOM.NatsNet.Server.IntegrationTests.csproj | 4 +--- reports/current.md | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/Helpers/IntegrationTestBase.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/Helpers/IntegrationTestBase.cs index 662be71..65339e8 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/Helpers/IntegrationTestBase.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/Helpers/IntegrationTestBase.cs @@ -45,6 +45,19 @@ public abstract class IntegrationTestBase : IDisposable /// xUnit output helper, available to derived test classes. protected ITestOutputHelper Output { get; } + /// + /// Returns true if integration tests should be skipped. + /// Convenience method for use in individual test methods that call + /// Skip.If(ShouldSkip(), "reason"). + /// + protected static bool ShouldSkip() => !Helpers.TestServerHelper.CanBoot(); + + /// + /// Returns true if the server runtime is unavailable. + /// Alias for used by some test batches. + /// + protected static bool ServerRuntimeUnavailable => !Helpers.TestServerHelper.CanBoot(); + // ========================================================================= // IDisposable // ========================================================================= diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/JetStream/JetStreamCluster1Tests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/JetStream/JetStreamCluster1Tests.cs index 6a2b150..ad1ccb0 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/JetStream/JetStreamCluster1Tests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/JetStream/JetStreamCluster1Tests.cs @@ -58,23 +58,23 @@ public class JetStreamCluster1Tests : IntegrationTestBase Skip.If(ShouldSkip(), "Cluster integration tests are not enabled."); using var c = TestCluster.CreateJetStreamCluster(2, "JSC"); - c.WaitOnPeerCount(2); + c.WaitOnClusterReady(); // Add a new server and wait for 3-peer cluster. - c.WaitOnPeerCount(3); + c.WaitOnClusterReady(); } // ----------------------------------------------------------------------- // 4. TestJetStreamClusterAccountInfo // ----------------------------------------------------------------------- [SkippableFact] - public void ClusterAccountInfo_ShouldReturnSingleResponse() + public async Task ClusterAccountInfo_ShouldReturnSingleResponse() { Skip.If(ShouldSkip(), "Cluster integration tests are not enabled."); using var c = TestCluster.CreateJetStreamCluster(3, "JSC"); c.WaitOnLeader(); // Connect and send $JS.API.INFO, expect exactly one response. - using var nc = NatsTestClient.ConnectToServer(c.RandomServer()); + await using var nc = NatsTestClient.ConnectToServer(c.RandomServer()); } // ----------------------------------------------------------------------- diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/ZB.MOM.NatsNet.Server.IntegrationTests.csproj b/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/ZB.MOM.NatsNet.Server.IntegrationTests.csproj index 2777913..f76dcad 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/ZB.MOM.NatsNet.Server.IntegrationTests.csproj +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.IntegrationTests/ZB.MOM.NatsNet.Server.IntegrationTests.csproj @@ -17,12 +17,10 @@ - - + - diff --git a/reports/current.md b/reports/current.md index 6de8dcd..1f26f2d 100644 --- a/reports/current.md +++ b/reports/current.md @@ -1,6 +1,6 @@ # NATS .NET Porting Status Report -Generated: 2026-03-01 17:16:41 UTC +Generated: 2026-03-01 17:18:41 UTC ## Modules (12 total)