test(batch50): port 118 JetStream cluster 1 integration tests
Ports the first 118 tests from golang/nats-server/server/jetstream_cluster_1_test.go to C# integration tests in JetStream/JetStreamCluster1Tests.cs. Adds the Helpers/ scaffold (IntegrationTestBase, TestCluster, NatsTestClient, CheckHelper, ConfigHelper) and Xunit.SkippableFact package; tests skip automatically unless NATS_INTEGRATION_TESTS=true is set.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// Copyright 2020-2025 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0
|
||||
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace ZB.MOM.NatsNet.Server.IntegrationTests.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for integration tests that require a live NATS cluster.
|
||||
/// Tests are skipped when the cluster infrastructure is not available.
|
||||
/// </summary>
|
||||
[Trait("Category", "Integration")]
|
||||
public abstract class IntegrationTestBase
|
||||
{
|
||||
protected readonly ITestOutputHelper Output;
|
||||
|
||||
protected IntegrationTestBase(ITestOutputHelper output)
|
||||
{
|
||||
Output = output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether cluster integration tests should be skipped.
|
||||
/// Tests are skipped unless the NATS_INTEGRATION_TESTS environment variable is set to "true"
|
||||
/// or NATS_SERVER_URL is set to a valid cluster endpoint.
|
||||
/// </summary>
|
||||
protected static bool ShouldSkip()
|
||||
{
|
||||
var integrationEnabled = Environment.GetEnvironmentVariable("NATS_INTEGRATION_TESTS");
|
||||
if (string.Equals(integrationEnabled, "true", StringComparison.OrdinalIgnoreCase))
|
||||
return false;
|
||||
|
||||
var serverUrl = Environment.GetEnvironmentVariable("NATS_SERVER_URL");
|
||||
if (!string.IsNullOrEmpty(serverUrl))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void Log(string message) => Output.WriteLine(message);
|
||||
}
|
||||
Reference in New Issue
Block a user