Ports 36 JetStream super-cluster tests from jetstream_super_cluster_test.go, 3 JetStream leaf-node tests from jetstream_leafnode_test.go, and 14 leaf-node tests from leafnode_test.go into the integration test project. Creates the required harness infrastructure (TestSuperCluster, TestCluster, IntegrationTestBase, CheckHelper, ConfigHelper, NatsTestClient, TestServerHelper). All 53 tests are marked [Fact(Skip = "...")] pending full multi-server cluster runtime.
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
// Copyright 2020-2025 The NATS Authors
|
|
// Licensed under the Apache License, Version 2.0
|
|
|
|
namespace ZB.MOM.NatsNet.Server.IntegrationTests.Helpers;
|
|
|
|
/// <summary>
|
|
/// Helpers for generating and writing NATS server configuration files used by
|
|
/// integration tests.
|
|
/// </summary>
|
|
public static class ConfigHelper
|
|
{
|
|
/// <summary>
|
|
/// Template for a basic JetStream super-cluster node.
|
|
/// Placeholders: {ServerName}, {ClusterName}, {StoreDir}, {ClusterPort}, {Routes}
|
|
/// </summary>
|
|
public const string JsSuperClusterTemplate = """
|
|
listen: 127.0.0.1:-1
|
|
server_name: {ServerName}
|
|
jetstream: {max_mem_store: 256MB, max_file_store: 2GB, store_dir: '{StoreDir}'}
|
|
cluster {
|
|
name: {ClusterName}
|
|
listen: 127.0.0.1:{ClusterPort}
|
|
routes = [{Routes}]
|
|
}
|
|
accounts { $SYS { users = [ { user: "admin", pass: "s3cr3t!" } ] } }
|
|
""";
|
|
|
|
/// <summary>
|
|
/// Writes <paramref name="content"/> to a temporary file and returns its path.
|
|
/// The file is deleted when the process exits (via <see cref="Path.GetTempFileName"/>).
|
|
/// </summary>
|
|
public static string CreateConfigFile(string content)
|
|
{
|
|
var path = Path.Combine(Path.GetTempPath(), $"natsnet_{Guid.NewGuid():N}.conf");
|
|
File.WriteAllText(path, content);
|
|
return path;
|
|
}
|
|
}
|