test(batch55): port 75 NoRace integration tests
Ports 51 tests from norace_1_test.go and 24 tests from norace_2_test.go
as [SkippableFact] integration tests. Creates test harness infrastructure
(IntegrationTestBase, CheckHelper, NatsTestClient, TestServerHelper,
TestCluster) and tags all tests with [Trait("Category", "NoRace")].
Tests skip unless NATS_INTEGRATION_ENABLED=true is set.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// Copyright 2012-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 running NATS server or cluster.
|
||||
/// Tests derived from this class are skipped when the infrastructure is not available.
|
||||
/// These tests correspond to Go's !race build tag tests (TestNoRace* functions).
|
||||
/// </summary>
|
||||
[Trait("Category", "Integration")]
|
||||
public abstract class IntegrationTestBase
|
||||
{
|
||||
protected readonly ITestOutputHelper Output;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true when the NATS_INTEGRATION_ENABLED environment variable is set to "true".
|
||||
/// When false, all [SkippableFact] tests will be skipped with an appropriate message.
|
||||
/// </summary>
|
||||
public static readonly bool IntegrationEnabled =
|
||||
string.Equals(
|
||||
Environment.GetEnvironmentVariable("NATS_INTEGRATION_ENABLED"),
|
||||
"true",
|
||||
StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
protected IntegrationTestBase(ITestOutputHelper output)
|
||||
{
|
||||
Output = output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a skip message when integration tests are not enabled.
|
||||
/// Use with [SkippableFact]: throw new SkipException(SkipMessage) if !IntegrationEnabled.
|
||||
/// </summary>
|
||||
public static string SkipMessage =>
|
||||
"Integration tests require NATS_INTEGRATION_ENABLED=true and a running NATS server/cluster";
|
||||
}
|
||||
Reference in New Issue
Block a user