test(batch23): port and verify mapped route tests

This commit is contained in:
Joseph Doherty
2026-02-28 21:24:18 -05:00
parent 51c899b651
commit 3501320c6e
3 changed files with 79 additions and 5 deletions

View File

@@ -77,16 +77,30 @@ public sealed partial class NatsServer
internal Exception? SetRouteInfoHostPortAndIP()
{
var opts = GetOpts();
var host = opts.Cluster.Host;
if (string.IsNullOrWhiteSpace(host))
host = opts.Host;
string host;
int port;
if (!string.IsNullOrWhiteSpace(opts.Cluster.Advertise))
{
var (advHost, advPort, advErr) = Internal.ServerUtilities.ParseHostPort(opts.Cluster.Advertise, opts.Cluster.Port);
if (advErr != null)
return new InvalidOperationException($"Cluster.Advertise invalid: {opts.Cluster.Advertise}", advErr);
host = advHost;
port = advPort;
}
else
{
host = opts.Cluster.Host;
if (string.IsNullOrWhiteSpace(host))
host = opts.Host;
port = opts.Cluster.Port;
}
_mu.EnterWriteLock();
try
{
_routeInfo.Host = host;
_routeInfo.Port = opts.Cluster.Port;
_routeInfo.Ip = $"nats-route://{host}:{opts.Cluster.Port}/";
_routeInfo.Port = port;
_routeInfo.Ip = $"nats-route://{host}:{port}/";
return null;
}
finally