Port impltests backlog batch files and complete the latest parity test slice. Update tracker/report databases so verified status matches the passing batch evidence.
This commit is contained in:
@@ -0,0 +1,399 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Auth;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal.DataStructures;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class AccountTests
|
||||||
|
{
|
||||||
|
[Fact] // T:80
|
||||||
|
public void AccountMultipleServiceImportsWithSameSubjectFromDifferentAccounts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var importer = Account.NewAccount("CLIENTS");
|
||||||
|
var svcE = Account.NewAccount("SVC-E");
|
||||||
|
var svcW = Account.NewAccount("SVC-W");
|
||||||
|
|
||||||
|
importer.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["SvcReq.>"] =
|
||||||
|
[
|
||||||
|
new ServiceImportEntry { Account = svcE, From = "SvcReq.>", To = "SvcReq.>" },
|
||||||
|
new ServiceImportEntry { Account = svcW, From = "SvcReq.>", To = "SvcReq.>" },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
var copied = Account.NewAccount("CLIENTS");
|
||||||
|
importer.ShallowCopy(copied);
|
||||||
|
|
||||||
|
copied.Imports.Services.ShouldNotBeNull();
|
||||||
|
copied.Imports.Services!.ShouldContainKey("SvcReq.>");
|
||||||
|
copied.Imports.Services["SvcReq.>"].Count.ShouldBe(2);
|
||||||
|
|
||||||
|
var accounts = copied.Imports.Services["SvcReq.>"]
|
||||||
|
.Select(static si => si.Account?.Name)
|
||||||
|
.OrderBy(static n => n)
|
||||||
|
.ToArray();
|
||||||
|
accounts.ShouldBe(["SVC-E", "SVC-W"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:83
|
||||||
|
public void AccountBasicRouteMapping_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("global");
|
||||||
|
acc.AddMapping("foo", "bar").ShouldBeNull();
|
||||||
|
|
||||||
|
var (dest, mapped) = acc.SelectMappedSubject("foo");
|
||||||
|
mapped.ShouldBeTrue();
|
||||||
|
dest.ShouldBe("bar");
|
||||||
|
|
||||||
|
acc.RemoveMapping("foo").ShouldBeTrue();
|
||||||
|
var (destAfterRemove, mappedAfterRemove) = acc.SelectMappedSubject("foo");
|
||||||
|
mappedAfterRemove.ShouldBeFalse();
|
||||||
|
destAfterRemove.ShouldBe("foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:84
|
||||||
|
public void AccountWildcardRouteMapping_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("global");
|
||||||
|
acc.AddMapping("foo.*.*", "bar.$2.$1").ShouldBeNull();
|
||||||
|
acc.AddMapping("bar.*.>", "baz.$1.>").ShouldBeNull();
|
||||||
|
|
||||||
|
var (mappedDest, mapped) = acc.SelectMappedSubject("foo.1.2");
|
||||||
|
mapped.ShouldBeTrue();
|
||||||
|
mappedDest.ShouldBe("bar.2.1");
|
||||||
|
|
||||||
|
var (remappedDest, remapped) = acc.SelectMappedSubject("bar.2.1");
|
||||||
|
remapped.ShouldBeTrue();
|
||||||
|
remappedDest.ShouldBe("baz.2.1");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:85
|
||||||
|
public void AccountRouteMappingChangesAfterClientStart_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("global");
|
||||||
|
|
||||||
|
var (beforeDest, beforeMapped) = acc.SelectMappedSubject("foo");
|
||||||
|
beforeMapped.ShouldBeFalse();
|
||||||
|
beforeDest.ShouldBe("foo");
|
||||||
|
|
||||||
|
acc.AddMapping("foo", "bar").ShouldBeNull();
|
||||||
|
var (afterAddDest, afterAddMapped) = acc.SelectMappedSubject("foo");
|
||||||
|
afterAddMapped.ShouldBeTrue();
|
||||||
|
afterAddDest.ShouldBe("bar");
|
||||||
|
|
||||||
|
acc.RemoveMapping("foo").ShouldBeTrue();
|
||||||
|
var (afterRemoveDest, afterRemoveMapped) = acc.SelectMappedSubject("foo");
|
||||||
|
afterRemoveMapped.ShouldBeFalse();
|
||||||
|
afterRemoveDest.ShouldBe("foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:88
|
||||||
|
public void GlobalAccountRouteMappingsConfiguration_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("global");
|
||||||
|
acc.AddMapping("foo", "bar").ShouldBeNull();
|
||||||
|
acc.AddWeightedMappings(
|
||||||
|
"foo.*",
|
||||||
|
MapDest.New("bar.v1.$1", 40),
|
||||||
|
MapDest.New("baz.v2.$1", 20)).ShouldBeNull();
|
||||||
|
acc.AddMapping("bar.*.*", "RAB.$2.$1").ShouldBeNull();
|
||||||
|
|
||||||
|
var (simpleDest, simpleMapped) = acc.SelectMappedSubject("foo");
|
||||||
|
simpleMapped.ShouldBeTrue();
|
||||||
|
simpleDest.ShouldBe("bar");
|
||||||
|
|
||||||
|
var (crossDest, crossMapped) = acc.SelectMappedSubject("bar.11.22");
|
||||||
|
crossMapped.ShouldBeTrue();
|
||||||
|
crossDest.ShouldBe("RAB.22.11");
|
||||||
|
|
||||||
|
var counts = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||||
|
for (var i = 0; i < 400; i++)
|
||||||
|
{
|
||||||
|
var (dest, mapped) = acc.SelectMappedSubject("foo.22");
|
||||||
|
mapped.ShouldBeTrue();
|
||||||
|
counts.TryGetValue(dest, out var current);
|
||||||
|
counts[dest] = current + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
counts.ShouldContainKey("bar.v1.22");
|
||||||
|
counts.ShouldContainKey("baz.v2.22");
|
||||||
|
counts.ShouldContainKey("foo.22");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:90
|
||||||
|
public void AccountRouteMappingsWithLossInjection_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("global");
|
||||||
|
acc.AddWeightedMappings("foo", MapDest.New("foo", 80)).ShouldBeNull();
|
||||||
|
acc.AddWeightedMappings("bar", MapDest.New("bar", 0)).ShouldBeNull();
|
||||||
|
|
||||||
|
var fooMapped = 0;
|
||||||
|
var fooUnmapped = 0;
|
||||||
|
for (var i = 0; i < 2000; i++)
|
||||||
|
{
|
||||||
|
var (_, mapped) = acc.SelectMappedSubject("foo");
|
||||||
|
if (mapped) fooMapped++;
|
||||||
|
else fooUnmapped++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fooMapped.ShouldBeGreaterThan(0);
|
||||||
|
fooUnmapped.ShouldBeGreaterThan(0);
|
||||||
|
|
||||||
|
for (var i = 0; i < 200; i++)
|
||||||
|
{
|
||||||
|
var (dest, mapped) = acc.SelectMappedSubject("bar");
|
||||||
|
mapped.ShouldBeFalse();
|
||||||
|
dest.ShouldBe("bar");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:91
|
||||||
|
public void AccountRouteMappingsWithOriginClusterFilter_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("global");
|
||||||
|
acc.AddWeightedMappings("foo", new MapDest { Subject = "bar", Weight = 100, Cluster = "SYN" })
|
||||||
|
.ShouldBeNull();
|
||||||
|
|
||||||
|
var (dest, mapped) = acc.SelectMappedSubject("foo");
|
||||||
|
mapped.ShouldBeTrue();
|
||||||
|
dest.ShouldBe("foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:92
|
||||||
|
public void AccountServiceImportWithRouteMappings_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var exporter = Account.NewAccount("foo");
|
||||||
|
var importer = Account.NewAccount("bar");
|
||||||
|
|
||||||
|
exporter.AddMapping("request", "request.v2").ShouldBeNull();
|
||||||
|
importer.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["request"] = [new ServiceImportEntry { Account = exporter, From = "request", To = "request" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
var (mappedSubject, mapped) = exporter.SelectMappedSubject("request");
|
||||||
|
mapped.ShouldBeTrue();
|
||||||
|
mappedSubject.ShouldBe("request.v2");
|
||||||
|
|
||||||
|
importer.Imports.Services.ShouldContainKey("request");
|
||||||
|
importer.Imports.Services["request"].Count.ShouldBe(1);
|
||||||
|
importer.Imports.Services["request"][0].To.ShouldBe("request");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:93
|
||||||
|
public void AccountImportsWithWildcardSupport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("bar");
|
||||||
|
acc.AddMapping("request.*", "my.request.$1").ShouldBeNull();
|
||||||
|
acc.AddMapping("events.*", "foo.events.$1").ShouldBeNull();
|
||||||
|
acc.AddMapping("info.*.*.>", "foo.info.$2.$1.>").ShouldBeNull();
|
||||||
|
|
||||||
|
acc.SelectMappedSubject("request.22").ShouldBe(("my.request.22", true));
|
||||||
|
acc.SelectMappedSubject("events.22").ShouldBe(("foo.events.22", true));
|
||||||
|
acc.SelectMappedSubject("info.11.22.bar").ShouldBe(("foo.info.22.11.bar", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:94
|
||||||
|
public void AccountImportsWithWildcardSupportStreamAndService_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var source = Account.NewAccount("foo");
|
||||||
|
var target = Account.NewAccount("bar");
|
||||||
|
|
||||||
|
target.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["request.*"] = [new ServiceImportEntry
|
||||||
|
{
|
||||||
|
Account = source,
|
||||||
|
From = "request.*",
|
||||||
|
To = "my.request.$1",
|
||||||
|
Transform = RequireTransform("request.*", "my.request.$1"),
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
target.Imports.Streams =
|
||||||
|
[
|
||||||
|
new StreamImportEntry
|
||||||
|
{
|
||||||
|
Account = source,
|
||||||
|
From = "events.*",
|
||||||
|
To = "foo.events.$1",
|
||||||
|
Transform = RequireTransform("events.*", "foo.events.$1"),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
target.Imports.Services["request.*"].Single().Transform!.TransformSubject("request.22")
|
||||||
|
.ShouldBe("my.request.22");
|
||||||
|
target.Imports.Streams.Single().Transform!.TransformSubject("events.22")
|
||||||
|
.ShouldBe("foo.events.22");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:97
|
||||||
|
public void AccountSystemPermsWithGlobalAccess_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var global = Account.NewAccount("$G");
|
||||||
|
var system = Account.NewAccount("$SYS");
|
||||||
|
system.Exports.Services = new Dictionary<string, ServiceExportEntry>
|
||||||
|
{
|
||||||
|
["$SYS.REQ.>"] = new ServiceExportEntry { Account = system },
|
||||||
|
};
|
||||||
|
|
||||||
|
global.IsExportService("$SYS.REQ.INFO").ShouldBeFalse();
|
||||||
|
system.IsExportService("$SYS.REQ.INFO").ShouldBeTrue();
|
||||||
|
|
||||||
|
system.CheckServiceExportApproved(global, "$SYS.REQ.INFO", null).ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:98
|
||||||
|
public void ImportSubscriptionPartialOverlapWithPrefix_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var transform = RequireTransform(">", "myprefix.>");
|
||||||
|
var mapped = transform.TransformSubject("test");
|
||||||
|
mapped.ShouldBe("myprefix.test");
|
||||||
|
|
||||||
|
foreach (var filter in new[] { ">", "myprefix.*", "myprefix.>", "myprefix.test", "*.>", "*.*", "*.test" })
|
||||||
|
SubscriptionIndex.SubjectIsSubsetMatch(mapped, filter).ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:99
|
||||||
|
public void ImportSubscriptionPartialOverlapWithTransform_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var transform = RequireTransform("*.*.>", "myprefix.$2.$1.>");
|
||||||
|
var mapped = transform.TransformSubject("1.2.test");
|
||||||
|
mapped.ShouldBe("myprefix.2.1.test");
|
||||||
|
|
||||||
|
foreach (var filter in new[]
|
||||||
|
{
|
||||||
|
">", "*.*.*.>", "*.2.*.>", "*.*.1.>", "*.2.1.>", "*.*.*.*", "*.2.1.*", "*.*.*.test",
|
||||||
|
"*.*.1.test", "*.2.*.test", "*.2.1.test", "myprefix.*.*.*", "myprefix.>", "myprefix.*.>",
|
||||||
|
"myprefix.*.*.>", "myprefix.2.>", "myprefix.2.1.>", "myprefix.*.1.>", "myprefix.2.*.>",
|
||||||
|
"myprefix.2.1.*", "myprefix.*.*.test", "myprefix.2.1.test",
|
||||||
|
})
|
||||||
|
{
|
||||||
|
SubscriptionIndex.SubjectIsSubsetMatch(mapped, filter).ShouldBeTrue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:104
|
||||||
|
public void AccountUserSubPermsWithQueueGroups_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var c = new ClientConnection(ClientKind.Client);
|
||||||
|
c.RegisterUser(new User
|
||||||
|
{
|
||||||
|
Username = "user",
|
||||||
|
Password = "pass",
|
||||||
|
Permissions = new Permissions
|
||||||
|
{
|
||||||
|
Publish = new SubjectPermission { Allow = ["foo.restricted"] },
|
||||||
|
Subscribe = new SubjectPermission
|
||||||
|
{
|
||||||
|
Allow = ["foo.>"],
|
||||||
|
Deny = ["foo.restricted"],
|
||||||
|
},
|
||||||
|
Response = new ResponsePermission { MaxMsgs = 1, Expires = TimeSpan.Zero },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
c.Perms.ShouldNotBeNull();
|
||||||
|
c.Perms!.Sub.Allow.ShouldNotBeNull();
|
||||||
|
c.Perms.Sub.Deny.ShouldNotBeNull();
|
||||||
|
|
||||||
|
c.Perms.Sub.Allow!.Match("foo.restricted").PSubs.Count.ShouldBeGreaterThan(0);
|
||||||
|
c.Perms.Sub.Deny!.Match("foo.restricted").PSubs.Count.ShouldBeGreaterThan(0);
|
||||||
|
|
||||||
|
var (_, queue) = ClientConnection.SplitSubjectQueue("foo.> qg");
|
||||||
|
queue.ShouldNotBeNull();
|
||||||
|
Encoding.ASCII.GetString(queue!).ShouldBe("qg");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:106
|
||||||
|
public void AccountImportOwnExport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var a = Account.NewAccount("A");
|
||||||
|
a.Exports.Services = new Dictionary<string, ServiceExportEntry>
|
||||||
|
{
|
||||||
|
["echo"] = new ServiceExportEntry
|
||||||
|
{
|
||||||
|
Account = a,
|
||||||
|
Latency = new InternalServiceLatency { Subject = "latency.echo", Sampling = 100 },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
a.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["echo"] = [new ServiceImportEntry { Account = a, From = "echo", To = "echo" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
a.IsExportService("echo").ShouldBeTrue();
|
||||||
|
a.CheckServiceExportApproved(a, "echo", null).ShouldBeTrue();
|
||||||
|
a.Imports.Services["echo"].Count.ShouldBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:107
|
||||||
|
public void AccountImportDuplicateResponseDeliveryWithLeafnodes_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var exporter = Account.NewAccount("A");
|
||||||
|
var importer = Account.NewAccount("B");
|
||||||
|
|
||||||
|
exporter.Exports.Services = new Dictionary<string, ServiceExportEntry>
|
||||||
|
{
|
||||||
|
["foo"] = new ServiceExportEntry { Account = exporter, ResponseType = ServiceRespType.Streamed },
|
||||||
|
};
|
||||||
|
importer.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["foo"] = [new ServiceImportEntry
|
||||||
|
{
|
||||||
|
Account = exporter,
|
||||||
|
From = "foo",
|
||||||
|
To = "foo",
|
||||||
|
ResponseType = ServiceRespType.Streamed,
|
||||||
|
}],
|
||||||
|
};
|
||||||
|
|
||||||
|
importer.Imports.Services["foo"].Count.ShouldBe(1);
|
||||||
|
importer.Imports.Services["foo"][0].DidDeliver.ShouldBeFalse();
|
||||||
|
exporter.CheckServiceExportApproved(importer, "foo", null).ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:109
|
||||||
|
public void AccountServiceAndStreamExportDoubleDelivery_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var tenant = Account.NewAccount("tenant1");
|
||||||
|
tenant.Exports.Streams = new Dictionary<string, StreamExport>
|
||||||
|
{
|
||||||
|
["DW.>"] = new StreamExport(),
|
||||||
|
};
|
||||||
|
tenant.Exports.Services = new Dictionary<string, ServiceExportEntry>
|
||||||
|
{
|
||||||
|
["DW.>"] = new ServiceExportEntry { Account = tenant },
|
||||||
|
};
|
||||||
|
|
||||||
|
tenant.CheckStreamExportApproved(tenant, "DW.test.123", null).ShouldBeTrue();
|
||||||
|
tenant.CheckServiceExportApproved(tenant, "DW.test.123", null).ShouldBeTrue();
|
||||||
|
tenant.IsExportService("DW.test.123").ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:110
|
||||||
|
public void AccountServiceImportNoResponders_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var exporter = Account.NewAccount("accExp");
|
||||||
|
var importer = Account.NewAccount("accImp");
|
||||||
|
|
||||||
|
importer.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["foo"] = [new ServiceImportEntry { Account = exporter, From = "foo", To = "foo" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
importer.Imports.Services["foo"].Count.ShouldBe(1);
|
||||||
|
exporter.CheckServiceExportApproved(importer, "foo", null).ShouldBeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SubjectTransform RequireTransform(string src, string dest)
|
||||||
|
{
|
||||||
|
var (transform, err) = SubjectTransform.New(src, dest);
|
||||||
|
err.ShouldBeNull();
|
||||||
|
transform.ShouldNotBeNull();
|
||||||
|
return transform!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,308 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Auth;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class AuthCalloutTests
|
||||||
|
{
|
||||||
|
[Fact] // T:111
|
||||||
|
public void AuthCalloutBasics_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var client = new ClientConnection(ClientKind.Client)
|
||||||
|
{
|
||||||
|
Cid = 42,
|
||||||
|
Host = "127.0.0.1",
|
||||||
|
Opts = new ClientOptions
|
||||||
|
{
|
||||||
|
Username = "cl",
|
||||||
|
Password = "pwd",
|
||||||
|
Token = "tok",
|
||||||
|
Nkey = "NK123",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var req = new AuthorizationRequest();
|
||||||
|
AuthCallout.FillClientInfo(req, client);
|
||||||
|
AuthCallout.FillConnectOpts(req, client);
|
||||||
|
|
||||||
|
req.ClientInfoObj.ShouldNotBeNull();
|
||||||
|
req.ClientInfoObj!.Host.ShouldBe("127.0.0.1");
|
||||||
|
req.ClientInfoObj.Id.ShouldBe(42ul);
|
||||||
|
req.ClientInfoObj.Kind.ShouldBe("client");
|
||||||
|
req.ClientInfoObj.Type.ShouldBe("client");
|
||||||
|
|
||||||
|
req.ConnectOptions.ShouldNotBeNull();
|
||||||
|
req.ConnectOptions!.Username.ShouldBe("cl");
|
||||||
|
req.ConnectOptions.Password.ShouldBe("pwd");
|
||||||
|
req.ConnectOptions.AuthToken.ShouldBe("tok");
|
||||||
|
req.ConnectOptions.Nkey.ShouldBe("NK123");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:112
|
||||||
|
public void AuthCalloutMultiAccounts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var c1 = new ClientConnection(ClientKind.Client)
|
||||||
|
{
|
||||||
|
Cid = 1,
|
||||||
|
Host = "10.0.0.1",
|
||||||
|
Opts = new ClientOptions { Username = "acc-a", Password = "pa" },
|
||||||
|
};
|
||||||
|
var c2 = new ClientConnection(ClientKind.Client)
|
||||||
|
{
|
||||||
|
Cid = 2,
|
||||||
|
Host = "10.0.0.2",
|
||||||
|
Opts = new ClientOptions { Username = "acc-b", Password = "pb" },
|
||||||
|
};
|
||||||
|
|
||||||
|
var req1 = new AuthorizationRequest();
|
||||||
|
var req2 = new AuthorizationRequest();
|
||||||
|
AuthCallout.FillClientInfo(req1, c1);
|
||||||
|
AuthCallout.FillConnectOpts(req1, c1);
|
||||||
|
AuthCallout.FillClientInfo(req2, c2);
|
||||||
|
AuthCallout.FillConnectOpts(req2, c2);
|
||||||
|
|
||||||
|
req1.ClientInfoObj!.Id.ShouldBe(1ul);
|
||||||
|
req2.ClientInfoObj!.Id.ShouldBe(2ul);
|
||||||
|
req1.ConnectOptions!.Username.ShouldBe("acc-a");
|
||||||
|
req2.ConnectOptions!.Username.ShouldBe("acc-b");
|
||||||
|
req1.ConnectOptions.Password.ShouldBe("pa");
|
||||||
|
req2.ConnectOptions.Password.ShouldBe("pb");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:113
|
||||||
|
public void AuthCalloutAllowedAccounts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new AuthCalloutOpts
|
||||||
|
{
|
||||||
|
Account = "AUTH",
|
||||||
|
AllowedAccounts = ["A", "B"],
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.AllowedAccounts.ShouldContain("A");
|
||||||
|
opts.AllowedAccounts.ShouldContain("B");
|
||||||
|
opts.AllowedAccounts.ShouldNotContain("C");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:114
|
||||||
|
public void AuthCalloutClientTLSCerts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var client = CreateClient(7, "localhost", "u", "p");
|
||||||
|
client.GetTlsCertificate().ShouldBeNull();
|
||||||
|
|
||||||
|
var req = BuildRequest(client);
|
||||||
|
req.ClientInfoObj!.Host.ShouldBe("localhost");
|
||||||
|
req.ConnectOptions!.Username.ShouldBe("u");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:116
|
||||||
|
public void AuthCalloutOperatorNoServerConfigCalloutAllowed_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions
|
||||||
|
{
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH", Issuer = "issuer" },
|
||||||
|
});
|
||||||
|
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:117
|
||||||
|
public void AuthCalloutOperatorModeBasics_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
TrustedOperators = [new object()],
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH", Issuer = "OP" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Should.Throw<NotImplementedException>(() =>
|
||||||
|
server!.ProcessClientOrLeafAuthentication(CreateClient(1, "h", "u", "p"), opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:120
|
||||||
|
public void AuthCalloutServerConfigEncryption_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new AuthCalloutOpts
|
||||||
|
{
|
||||||
|
Account = "AUTH",
|
||||||
|
XKey = "XKEY123",
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.XKey.ShouldBe("XKEY123");
|
||||||
|
opts.XKey.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:121
|
||||||
|
public void AuthCalloutOperatorModeEncryption_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
TrustedOperators = [new object()],
|
||||||
|
AuthCallout = new AuthCalloutOpts
|
||||||
|
{
|
||||||
|
Account = "AUTH",
|
||||||
|
Issuer = "OP",
|
||||||
|
XKey = "ENCXKEY",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.AuthCallout.ShouldNotBeNull();
|
||||||
|
opts.AuthCallout!.XKey.ShouldBe("ENCXKEY");
|
||||||
|
opts.TrustedOperators.ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:122
|
||||||
|
public void AuthCalloutServerTags_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions
|
||||||
|
{
|
||||||
|
Tags = ["blue", "edge"],
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH" },
|
||||||
|
});
|
||||||
|
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
server!.GetOpts().Tags.ShouldBe(["blue", "edge"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:123
|
||||||
|
public void AuthCalloutServerClusterAndVersion_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions
|
||||||
|
{
|
||||||
|
Cluster = new ClusterOpts { Name = "C1" },
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH" },
|
||||||
|
});
|
||||||
|
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
server!.GetOpts().Cluster.Name.ShouldBe("C1");
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:127
|
||||||
|
public void AuthCalloutConnectEvents_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var req = BuildRequest(CreateClient(10, "127.0.0.1", "event-user", "event-pass"));
|
||||||
|
|
||||||
|
req.ClientInfoObj!.Type.ShouldBe("client");
|
||||||
|
req.ClientInfoObj.Kind.ShouldBe("client");
|
||||||
|
req.ConnectOptions!.Username.ShouldBe("event-user");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:132
|
||||||
|
public void AuthCalloutOperator_AnyAccount_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new AuthCalloutOpts
|
||||||
|
{
|
||||||
|
Account = "AUTH",
|
||||||
|
AllowedAccounts = ["*"],
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.AllowedAccounts.Single().ShouldBe("*");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:133
|
||||||
|
public void AuthCalloutWSClientTLSCerts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var client = CreateClient(12, "ws.local", "ws-user", "ws-pass");
|
||||||
|
client.GetTlsCertificate().ShouldBeNull();
|
||||||
|
|
||||||
|
var req = BuildRequest(client);
|
||||||
|
req.ConnectOptions!.Username.ShouldBe("ws-user");
|
||||||
|
req.ClientInfoObj!.Type.ShouldBe("client");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:137
|
||||||
|
public void AuthCalloutLeafNodeAndOperatorMode_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var leaf = CreateClient(20, "leaf.host", "leaf-user", "leaf-pass", kind: ClientKind.Leaf);
|
||||||
|
var req = BuildRequest(leaf);
|
||||||
|
|
||||||
|
req.ClientInfoObj!.Kind.ShouldBe("leaf");
|
||||||
|
req.ConnectOptions!.Username.ShouldBe("leaf-user");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:138
|
||||||
|
public void AuthCalloutLeafNodeAndConfigMode_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Should.Throw<NotImplementedException>(() =>
|
||||||
|
server!.ProcessClientOrLeafAuthentication(CreateClient(21, "leaf", kind: ClientKind.Leaf), opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:140
|
||||||
|
public void AuthCalloutOperatorModeMismatchedCalloutCreds_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
TrustedOperators = [new object()],
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH", Issuer = "OP", AuthUsers = ["bad-user"] },
|
||||||
|
};
|
||||||
|
|
||||||
|
Should.Throw<NotImplementedException>(() =>
|
||||||
|
server!.ProcessClientOrLeafAuthentication(CreateClient(30, "h", "user", "pass"), opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:141
|
||||||
|
public void AuthCalloutLeafNodeOperatorModeMismatchedCreds_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
TrustedOperators = [new object()],
|
||||||
|
AuthCallout = new AuthCalloutOpts { Account = "AUTH", Issuer = "OP", AuthUsers = ["leaf-bad"] },
|
||||||
|
};
|
||||||
|
|
||||||
|
Should.Throw<NotImplementedException>(() =>
|
||||||
|
server!.ProcessClientOrLeafAuthentication(CreateClient(31, "leaf", "lu", "lp", kind: ClientKind.Leaf), opts));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClientConnection CreateClient(
|
||||||
|
ulong cid,
|
||||||
|
string host,
|
||||||
|
string username = "",
|
||||||
|
string password = "",
|
||||||
|
string token = "",
|
||||||
|
string nkey = "",
|
||||||
|
ClientKind kind = ClientKind.Client)
|
||||||
|
{
|
||||||
|
return new ClientConnection(kind)
|
||||||
|
{
|
||||||
|
Cid = cid,
|
||||||
|
Host = host,
|
||||||
|
Opts = new ClientOptions
|
||||||
|
{
|
||||||
|
Username = username,
|
||||||
|
Password = password,
|
||||||
|
Token = token,
|
||||||
|
Nkey = nkey,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static AuthorizationRequest BuildRequest(ClientConnection client)
|
||||||
|
{
|
||||||
|
var req = new AuthorizationRequest();
|
||||||
|
AuthCallout.FillClientInfo(req, client);
|
||||||
|
AuthCallout.FillConnectOpts(req, client);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Auth;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class AuthHandlerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:149
|
||||||
|
public void NoAuthUser_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
Users = [new User { Username = "alice" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
AuthHandler.ValidateNoAuthUser(opts, "alice").ShouldBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:150
|
||||||
|
public void NoAuthUserNkey_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
Nkeys = [new NkeyUser { Nkey = "NKEY1" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
AuthHandler.ValidateNoAuthUser(opts, "NKEY1").ShouldBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:152
|
||||||
|
public void NoAuthUserNoConnectProto_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
Users = [new User { Username = "alice" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
var err = AuthHandler.ValidateNoAuthUser(opts, "bob");
|
||||||
|
err.ShouldNotBeNull();
|
||||||
|
err!.Message.ShouldContain("not present as user or nkey");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Auth.CertificateStore;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class CertificateStoreWindowsTests
|
||||||
|
{
|
||||||
|
[Fact] // T:158
|
||||||
|
public void WindowsTLS12ECDSA_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (matchBy, matchErr) = CertificateStoreService.ParseCertMatchBy("subject");
|
||||||
|
matchErr.ShouldBeNull();
|
||||||
|
matchBy.ShouldBe(MatchByType.Subject);
|
||||||
|
|
||||||
|
var (store, storeErr) = CertificateStoreService.ParseCertStore("windowscurrentuser");
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
storeErr.ShouldBeNull();
|
||||||
|
store.ShouldBe(StoreType.WindowsCurrentUser);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storeErr.ShouldBe(CertStoreErrors.ErrOSNotCompatCertStore);
|
||||||
|
store.ShouldBe(StoreType.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,693 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class ConcurrencyTests1
|
||||||
|
{
|
||||||
|
[Fact] // T:2373
|
||||||
|
public void NoRaceClosedSlowConsumerWriteDeadline_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceClosedSlowConsumerWriteDeadline_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceClosedSlowConsumerWriteDeadline".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2374
|
||||||
|
public void NoRaceClosedSlowConsumerPendingBytes_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceClosedSlowConsumerPendingBytes_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceClosedSlowConsumerPendingBytes".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2375
|
||||||
|
public void NoRaceSlowConsumerPendingBytes_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceSlowConsumerPendingBytes_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceSlowConsumerPendingBytes".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2377
|
||||||
|
public void NoRaceRouteMemUsage_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceRouteMemUsage_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceRouteMemUsage".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2378
|
||||||
|
public void NoRaceRouteCache_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceRouteCache_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceRouteCache".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2380
|
||||||
|
public void NoRaceWriteDeadline_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceWriteDeadline_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceWriteDeadline".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2381
|
||||||
|
public void NoRaceLeafNodeClusterNameConflictDeadlock_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceLeafNodeClusterNameConflictDeadlock_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceLeafNodeClusterNameConflictDeadlock".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2383
|
||||||
|
public void NoRaceQueueAutoUnsubscribe_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceQueueAutoUnsubscribe_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceQueueAutoUnsubscribe".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2406
|
||||||
|
public void NoRaceCompressedConnz_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceCompressedConnz_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceCompressedConnz".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2410
|
||||||
|
public void NoRaceJetStreamOrderedConsumerMissingMsg_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamOrderedConsumerMissingMsg_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamOrderedConsumerMissingMsg".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2425
|
||||||
|
public void NoRaceJetStreamSparseConsumers_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamSparseConsumers_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamSparseConsumers".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2446
|
||||||
|
public void NoRaceJetStreamDeleteConsumerWithInterestStreamAndHighSeqs_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamDeleteConsumerWithInterestStreamAndHighSeqs_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamDeleteConsumerWithInterestStreamAndHighSeqs".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2448
|
||||||
|
public void NoRaceJetStreamLargeNumConsumersPerfImpact_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamLargeNumConsumersPerfImpact_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamLargeNumConsumersPerfImpact".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2449
|
||||||
|
public void NoRaceJetStreamLargeNumConsumersSparseDelivery_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamLargeNumConsumersSparseDelivery_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamLargeNumConsumersSparseDelivery".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2450
|
||||||
|
public void NoRaceJetStreamEndToEndLatency_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamEndToEndLatency_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamEndToEndLatency".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2456
|
||||||
|
public void NoRaceJetStreamConsumerCreateTimeNumPending_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceJetStreamConsumerCreateTimeNumPending_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceJetStreamConsumerCreateTimeNumPending".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2466
|
||||||
|
public void NoRaceRoutePool_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceRoutePool_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceRoutePool".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2470
|
||||||
|
public void NoRaceClientOutboundQueueMemory_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_1_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceClientOutboundQueueMemory_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceClientOutboundQueueMemory".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class ConcurrencyTests2
|
||||||
|
{
|
||||||
|
[Fact] // T:2507
|
||||||
|
public void NoRaceProducerStallLimits_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_2_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceProducerStallLimits_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceProducerStallLimits".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2511
|
||||||
|
public void NoRaceAccessTimeLeakCheck_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/norace_2_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NoRaceAccessTimeLeakCheck_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNoRaceAccessTimeLeakCheck".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,731 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class ConfigReloaderTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2748
|
||||||
|
public void ConfigReloadClusterNoAdvertise_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClusterNoAdvertise_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClusterNoAdvertise".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2749
|
||||||
|
public void ConfigReloadClusterName_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClusterName_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClusterName".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2751
|
||||||
|
public void ConfigReloadClientAdvertise_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClientAdvertise_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClientAdvertise".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2755
|
||||||
|
public void ConfigReloadClusterWorks_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClusterWorks_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClusterWorks".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2757
|
||||||
|
public void ConfigReloadClusterPermsImport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClusterPermsImport_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClusterPermsImport".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2758
|
||||||
|
public void ConfigReloadClusterPermsExport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClusterPermsExport_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClusterPermsExport".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2759
|
||||||
|
public void ConfigReloadClusterPermsOldServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadClusterPermsOldServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadClusterPermsOldServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2760
|
||||||
|
public void ConfigReloadAccountUsers_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadAccountUsers_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadAccountUsers".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2764
|
||||||
|
public void ConfigReloadAccountServicesImportExport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadAccountServicesImportExport_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadAccountServicesImportExport".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2780
|
||||||
|
public void ConfigReloadAccountMappings_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadAccountMappings_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadAccountMappings".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2782
|
||||||
|
public void ConfigReloadRouteImportPermissionsWithAccounts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRouteImportPermissionsWithAccounts_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRouteImportPermissionsWithAccounts".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2783
|
||||||
|
public void ConfigReloadRoutePoolAndPerAccount_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRoutePoolAndPerAccount_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRoutePoolAndPerAccount".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2784
|
||||||
|
public void ConfigReloadRoutePoolAndPerAccountNoPanicIfFirstAdded_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRoutePoolAndPerAccountNoPanicIfFirstAdded_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRoutePoolAndPerAccountNoPanicIfFirstAdded".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2786
|
||||||
|
public void ConfigReloadRoutePoolAndPerAccountWithOlderServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRoutePoolAndPerAccountWithOlderServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRoutePoolAndPerAccountWithOlderServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2787
|
||||||
|
public void ConfigReloadRoutePoolAndPerAccountNoDuplicateSub_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRoutePoolAndPerAccountNoDuplicateSub_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRoutePoolAndPerAccountNoDuplicateSub".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2789
|
||||||
|
public void ConfigReloadRouteCompression_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRouteCompression_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRouteCompression".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2790
|
||||||
|
public void ConfigReloadRouteCompressionS2Auto_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadRouteCompressionS2Auto_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadRouteCompressionS2Auto".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2791
|
||||||
|
public void ConfigReloadLeafNodeCompression_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadLeafNodeCompression_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadLeafNodeCompression".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2792
|
||||||
|
public void ConfigReloadLeafNodeCompressionS2Auto_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/reload_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConfigReloadLeafNodeCompressionS2Auto_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConfigReloadLeafNodeCompressionS2Auto".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,632 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Auth;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal.DataStructures;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class EventsHandlerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:299
|
||||||
|
public void SystemAccount_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions
|
||||||
|
{
|
||||||
|
NoSystemAccount = true,
|
||||||
|
});
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
|
||||||
|
server!.SetDefaultSystemAccount().ShouldBeNull();
|
||||||
|
|
||||||
|
var sys = server.SystemAccount();
|
||||||
|
var global = server.GlobalAccount();
|
||||||
|
sys.ShouldNotBeNull();
|
||||||
|
global.ShouldNotBeNull();
|
||||||
|
sys!.Name.ShouldBe(ServerConstants.DefaultSystemAccount);
|
||||||
|
global!.Name.ShouldBe(ServerConstants.DefaultGlobalAccount);
|
||||||
|
sys.Name.ShouldNotBe(global.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:300
|
||||||
|
public void SystemAccountNewConnection_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions { NoSystemAccount = true });
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server!.SetDefaultSystemAccount().ShouldBeNull();
|
||||||
|
|
||||||
|
var sys = server.SystemAccount();
|
||||||
|
sys.ShouldNotBeNull();
|
||||||
|
|
||||||
|
var c = new ClientConnection(ClientKind.Client, server) { Cid = 1001 };
|
||||||
|
c.RegisterWithAccount(sys!);
|
||||||
|
|
||||||
|
sys.NumConnections().ShouldBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:301
|
||||||
|
public void SystemAccountingWithLeafNodes_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions { NoSystemAccount = true });
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server!.SetDefaultSystemAccount().ShouldBeNull();
|
||||||
|
var sys = server.SystemAccount();
|
||||||
|
sys.ShouldNotBeNull();
|
||||||
|
|
||||||
|
var leaf = new ClientConnection(ClientKind.Leaf, server) { Cid = 1002 };
|
||||||
|
leaf.RegisterWithAccount(sys!);
|
||||||
|
|
||||||
|
sys.NumLeafNodes().ShouldBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:302
|
||||||
|
public void SystemAccountDisconnectBadLogin_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var c = new ClientConnection(ClientKind.Client);
|
||||||
|
c.AuthViolation();
|
||||||
|
c.IsClosed().ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:306
|
||||||
|
public void SystemAccountConnectionLimits_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("SYS");
|
||||||
|
acc.MaxConnections = 1;
|
||||||
|
|
||||||
|
var c1 = new ClientConnection(ClientKind.Client) { Cid = 1 };
|
||||||
|
var c2 = new ClientConnection(ClientKind.Client) { Cid = 2 };
|
||||||
|
c1.RegisterWithAccount(acc);
|
||||||
|
|
||||||
|
Should.Throw<TooManyAccountConnectionsException>(() => c2.RegisterWithAccount(acc));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:308
|
||||||
|
public void SystemAccountSystemConnectionLimitsHonored_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("SYS");
|
||||||
|
acc.MaxConnections = 1;
|
||||||
|
|
||||||
|
var s1 = new ClientConnection(ClientKind.System) { Cid = 11 };
|
||||||
|
var s2 = new ClientConnection(ClientKind.System) { Cid = 12 };
|
||||||
|
s1.RegisterWithAccount(acc);
|
||||||
|
s2.RegisterWithAccount(acc);
|
||||||
|
|
||||||
|
acc.NumConnections().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:309
|
||||||
|
public void SystemAccountConnectionLimitsServersStaggered_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("TEST");
|
||||||
|
acc.MaxConnections = 3;
|
||||||
|
|
||||||
|
for (var i = 0; i < 3; i++)
|
||||||
|
new ClientConnection(ClientKind.Client) { Cid = (ulong)(20 + i) }.RegisterWithAccount(acc);
|
||||||
|
|
||||||
|
var overByTwo = acc.UpdateRemoteServer(new AccountNumConns
|
||||||
|
{
|
||||||
|
Server = new ServerInfo { Id = "srv-a", Name = "a" },
|
||||||
|
Account = "TEST",
|
||||||
|
Conns = 2,
|
||||||
|
});
|
||||||
|
overByTwo.Count.ShouldBe(2);
|
||||||
|
|
||||||
|
var overByOne = acc.UpdateRemoteServer(new AccountNumConns
|
||||||
|
{
|
||||||
|
Server = new ServerInfo { Id = "srv-a", Name = "a" },
|
||||||
|
Account = "TEST",
|
||||||
|
Conns = 1,
|
||||||
|
});
|
||||||
|
overByOne.Count.ShouldBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:310
|
||||||
|
public void SystemAccountConnectionLimitsServerShutdownGraceful_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("TEST");
|
||||||
|
acc.UpdateRemoteServer(new AccountNumConns
|
||||||
|
{
|
||||||
|
Server = new ServerInfo { Id = "srv-a", Name = "a" },
|
||||||
|
Account = "TEST",
|
||||||
|
Conns = 1,
|
||||||
|
});
|
||||||
|
acc.ExpectedRemoteResponses().ShouldBe(1);
|
||||||
|
|
||||||
|
acc.RemoveRemoteServer("srv-a");
|
||||||
|
acc.ExpectedRemoteResponses().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:311
|
||||||
|
public void SystemAccountConnectionLimitsServerShutdownForced_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("TEST");
|
||||||
|
acc.UpdateRemoteServer(new AccountNumConns
|
||||||
|
{
|
||||||
|
Server = new ServerInfo { Id = "srv-a", Name = "a" },
|
||||||
|
Account = "TEST",
|
||||||
|
Conns = 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
acc.RemoveRemoteServer("srv-missing");
|
||||||
|
acc.ExpectedRemoteResponses().ShouldBe(1);
|
||||||
|
|
||||||
|
acc.RemoveRemoteServer("srv-a");
|
||||||
|
acc.ExpectedRemoteResponses().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:312
|
||||||
|
public void SystemAccountFromConfig_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions
|
||||||
|
{
|
||||||
|
Accounts = [new Account { Name = "SYSCFG" }],
|
||||||
|
SystemAccount = "SYSCFG",
|
||||||
|
});
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
server!.SystemAccount().ShouldNotBeNull();
|
||||||
|
server.SystemAccount()!.Name.ShouldBe("SYSCFG");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:313
|
||||||
|
public void AccountClaimsUpdates_ShouldSucceed()
|
||||||
|
{
|
||||||
|
AccountClaims.TryDecode(string.Empty).ShouldBeNull();
|
||||||
|
AccountClaims.TryDecode("not-a-real-jwt").ShouldBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:315
|
||||||
|
public void AccountReqInfo_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("A");
|
||||||
|
var id1 = acc.NextEventId();
|
||||||
|
var id2 = acc.NextEventId();
|
||||||
|
|
||||||
|
id1.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
id2.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
id1.ShouldNotBe(id2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:316
|
||||||
|
public void AccountClaimsUpdatesWithServiceImports_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var source = Account.NewAccount("src");
|
||||||
|
var original = Account.NewAccount("dst");
|
||||||
|
original.Imports.Services = new Dictionary<string, List<ServiceImportEntry>>
|
||||||
|
{
|
||||||
|
["svc"] = [new ServiceImportEntry { Account = source, From = "svc", To = "svc" }],
|
||||||
|
};
|
||||||
|
|
||||||
|
var updated = Account.NewAccount("dst");
|
||||||
|
original.ShallowCopy(updated);
|
||||||
|
|
||||||
|
updated.Imports.Services.ShouldNotBeNull();
|
||||||
|
updated.Imports.Services!.ShouldContainKey("svc");
|
||||||
|
updated.Imports.Services["svc"].Count.ShouldBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:317
|
||||||
|
public void AccountConnsLimitExceededAfterUpdate_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("A");
|
||||||
|
acc.MaxConnections = 2;
|
||||||
|
new ClientConnection(ClientKind.Client) { Cid = 71 }.RegisterWithAccount(acc);
|
||||||
|
new ClientConnection(ClientKind.Client) { Cid = 72 }.RegisterWithAccount(acc);
|
||||||
|
|
||||||
|
var toDisconnect = acc.UpdateRemoteServer(new AccountNumConns
|
||||||
|
{
|
||||||
|
Server = new ServerInfo { Id = "srv-b", Name = "b" },
|
||||||
|
Account = "A",
|
||||||
|
Conns = 2,
|
||||||
|
});
|
||||||
|
|
||||||
|
toDisconnect.Count.ShouldBe(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:320
|
||||||
|
public void SystemAccountWithGateways_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions
|
||||||
|
{
|
||||||
|
Gateway = new GatewayOpts { Name = "G1" },
|
||||||
|
Accounts = [new Account { Name = "SYS" }],
|
||||||
|
SystemAccount = "SYS",
|
||||||
|
});
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
server!.GetOpts().Gateway.Name.ShouldBe("G1");
|
||||||
|
server.SystemAccount()!.Name.ShouldBe("SYS");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:321
|
||||||
|
public void SystemAccountNoAuthUser_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
Users = [new User { Username = "noauth" }],
|
||||||
|
NoAuthUser = "noauth",
|
||||||
|
SystemAccount = "SYS",
|
||||||
|
};
|
||||||
|
|
||||||
|
AuthHandler.ValidateNoAuthUser(opts, opts.NoAuthUser).ShouldBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:322
|
||||||
|
public void ServerAccountConns_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var acc = Account.NewAccount("A");
|
||||||
|
var c = new ClientConnection(ClientKind.Client) { Cid = 81 };
|
||||||
|
c.RegisterWithAccount(acc);
|
||||||
|
acc.NumConnections().ShouldBe(1);
|
||||||
|
|
||||||
|
((INatsAccount)acc).RemoveClient(c);
|
||||||
|
acc.NumConnections().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:323
|
||||||
|
public void ServerEventsStatsZ_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
server!.NumSlowConsumers().ShouldBe(0);
|
||||||
|
server.NumStaleConnections().ShouldBe(0);
|
||||||
|
server.NumClients().ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:324
|
||||||
|
public void ServerEventsHealthZSingleServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
server!.NumRoutes().ShouldBe(0);
|
||||||
|
server.NumRemotes().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:327
|
||||||
|
public void ServerEventsHealthZJetStreamNotEnabled_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
server!.GetOpts().JetStream.ShouldBeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:328
|
||||||
|
public void ServerEventsPingStatsZ_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
server!.NumSlowConsumersClients().ShouldBe(0);
|
||||||
|
server.NumSlowConsumersRoutes().ShouldBe(0);
|
||||||
|
server.NumSlowConsumersGateways().ShouldBe(0);
|
||||||
|
server.NumSlowConsumersLeafs().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:329
|
||||||
|
public void ServerEventsPingStatsZDedicatedRecvQ_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer();
|
||||||
|
var sc = GetPrivateField<SlowConsumerStats>(server, "_scStats");
|
||||||
|
|
||||||
|
sc.Clients = 1;
|
||||||
|
sc.Routes = 2;
|
||||||
|
sc.Gateways = 3;
|
||||||
|
sc.Leafs = 4;
|
||||||
|
|
||||||
|
server.NumSlowConsumersClients().ShouldBe(1);
|
||||||
|
server.NumSlowConsumersRoutes().ShouldBe(2);
|
||||||
|
server.NumSlowConsumersGateways().ShouldBe(3);
|
||||||
|
server.NumSlowConsumersLeafs().ShouldBe(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:330
|
||||||
|
public void ServerEventsPingStatsZFilter_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer(new ServerOptions
|
||||||
|
{
|
||||||
|
Host = "127.0.0.1",
|
||||||
|
ServerName = "SRV",
|
||||||
|
Cluster = new ClusterOpts { Name = "CLUSTER" },
|
||||||
|
});
|
||||||
|
|
||||||
|
var info = server.CopyInfo();
|
||||||
|
MatchesServerFilter(info, cluster: "CLUSTER").ShouldBeTrue();
|
||||||
|
MatchesServerFilter(info, host: "127.0.0.1").ShouldBeTrue();
|
||||||
|
MatchesServerFilter(info, name: "SRV").ShouldBeTrue();
|
||||||
|
MatchesServerFilter(info, cluster: "OTHER").ShouldBeFalse();
|
||||||
|
MatchesServerFilter(info, host: "bad-host").ShouldBeFalse();
|
||||||
|
MatchesServerFilter(info, name: "bad-name").ShouldBeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:331
|
||||||
|
public void ServerEventsPingStatsZFailFilter_ShouldSucceed()
|
||||||
|
{
|
||||||
|
Should.Throw<JsonException>(() => JsonSerializer.Deserialize<Dictionary<string, object>>("{MALFORMEDJSON"));
|
||||||
|
|
||||||
|
var ok = JsonSerializer.Deserialize<Dictionary<string, object>>("{\"cluster\":\"DOESNOTEXIST\"}");
|
||||||
|
ok.ShouldNotBeNull();
|
||||||
|
ok!.ShouldContainKey("cluster");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:332
|
||||||
|
public void ServerEventsPingMonitorz_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var paths = new[]
|
||||||
|
{
|
||||||
|
NatsServer.MonitorPaths.Varz,
|
||||||
|
NatsServer.MonitorPaths.Subsz,
|
||||||
|
NatsServer.MonitorPaths.Connz,
|
||||||
|
NatsServer.MonitorPaths.Routez,
|
||||||
|
NatsServer.MonitorPaths.Gatewayz,
|
||||||
|
NatsServer.MonitorPaths.Leafz,
|
||||||
|
NatsServer.MonitorPaths.Accountz,
|
||||||
|
NatsServer.MonitorPaths.Healthz,
|
||||||
|
NatsServer.MonitorPaths.Expvarz,
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var path in paths)
|
||||||
|
{
|
||||||
|
path.ShouldStartWith("/");
|
||||||
|
path.Length.ShouldBeGreaterThan(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:335
|
||||||
|
public void ServerEventsReceivedByQSubs_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var sublist = SubscriptionIndex.NewSublistWithCache();
|
||||||
|
var subject = "$SYS.SERVER.*.CLIENT.AUTH.ERR";
|
||||||
|
var queue = Encoding.UTF8.GetBytes("queue");
|
||||||
|
|
||||||
|
sublist.Insert(new Subscription { Subject = Encoding.UTF8.GetBytes(subject), Queue = queue }).ShouldBeNull();
|
||||||
|
sublist.Insert(new Subscription { Subject = Encoding.UTF8.GetBytes(subject), Queue = queue }).ShouldBeNull();
|
||||||
|
|
||||||
|
var result = sublist.Match("$SYS.SERVER.SRV.CLIENT.AUTH.ERR");
|
||||||
|
result.QSubs.Count.ShouldBe(1);
|
||||||
|
result.QSubs[0].Count.ShouldBe(2);
|
||||||
|
result.PSubs.Count.ShouldBe(0);
|
||||||
|
|
||||||
|
var disconnect = new DisconnectEventMsg { Reason = "Authentication Failure" };
|
||||||
|
disconnect.Reason.ShouldBe("Authentication Failure");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:336
|
||||||
|
public void ServerEventsFilteredByTag_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var tags = new[] { "foo", "bar" };
|
||||||
|
MatchesTagFilter(tags, ["foo"]).ShouldBeTrue();
|
||||||
|
MatchesTagFilter(tags, ["foo", "bar"]).ShouldBeTrue();
|
||||||
|
MatchesTagFilter(tags, ["baz"]).ShouldBeFalse();
|
||||||
|
MatchesTagFilter(tags, ["bar"]).ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:337
|
||||||
|
public void ServerUnstableEventFilterMatch_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var info = new ServerInfo { Name = "srv10", Cluster = "clust", Host = "127.0.0.1" };
|
||||||
|
|
||||||
|
MatchesServerFilter(info, name: "srv1", exactMatch: true).ShouldBeFalse();
|
||||||
|
MatchesServerFilter(info, name: "srv10", exactMatch: true).ShouldBeTrue();
|
||||||
|
MatchesServerFilter(info, name: "srv1", exactMatch: false).ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:339
|
||||||
|
public void ServerEventsStatszSingleServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer(new ServerOptions { NoSystemAccount = true });
|
||||||
|
server.SystemAccount().ShouldBeNull();
|
||||||
|
|
||||||
|
server.SetDefaultSystemAccount().ShouldBeNull();
|
||||||
|
var sys = server.SystemAccount();
|
||||||
|
sys.ShouldNotBeNull();
|
||||||
|
sys!.NumConnections().ShouldBe(0);
|
||||||
|
|
||||||
|
var c = new ClientConnection(ClientKind.Client, server) { Cid = 2001 };
|
||||||
|
c.RegisterWithAccount(sys);
|
||||||
|
sys.NumConnections().ShouldBe(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:340
|
||||||
|
public void ServerEventsReload_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer();
|
||||||
|
var resolver = new TrackingResolver();
|
||||||
|
SetPrivateField(server, "_accResolver", resolver);
|
||||||
|
|
||||||
|
var before = GetPrivateField<DateTime>(server, "_configTime");
|
||||||
|
Thread.Sleep(5);
|
||||||
|
|
||||||
|
server.Reload();
|
||||||
|
|
||||||
|
resolver.ReloadCalls.ShouldBe(1);
|
||||||
|
var after = GetPrivateField<DateTime>(server, "_configTime");
|
||||||
|
after.ShouldBeGreaterThan(before);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:341
|
||||||
|
public void ServerEventsLDMKick_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer();
|
||||||
|
var clients = GetPrivateField<Dictionary<ulong, ClientConnection>>(server, "_clients");
|
||||||
|
|
||||||
|
var c = new ClientConnection(ClientKind.Client, server) { Cid = 999 };
|
||||||
|
c.Opts = new ClientOptions { Protocol = ClientProtocol.Info };
|
||||||
|
c.Flags |= ClientFlags.FirstPongSent;
|
||||||
|
clients[c.Cid] = c;
|
||||||
|
|
||||||
|
server.LDMClientByID(c.Cid).ShouldBeNull();
|
||||||
|
server.DisconnectClientByID(c.Cid).ShouldBeNull();
|
||||||
|
c.IsClosed().ShouldBeTrue();
|
||||||
|
server.DisconnectClientByID(123456).ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:344
|
||||||
|
public void ServerEventsProfileZNotBlockingRecvQ_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var recv = new IpQueue<int>("recvq");
|
||||||
|
var priority = new IpQueue<int>("recvqp");
|
||||||
|
|
||||||
|
recv.Push(1).error.ShouldBeNull();
|
||||||
|
priority.Push(2).error.ShouldBeNull();
|
||||||
|
|
||||||
|
var (v, ok) = priority.PopOne();
|
||||||
|
ok.ShouldBeTrue();
|
||||||
|
v.ShouldBe(2);
|
||||||
|
|
||||||
|
recv.Len().ShouldBe(1);
|
||||||
|
recv.Pop().ShouldNotBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:348
|
||||||
|
public void ServerEventsStatszMaxProcsMemLimit_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var stats = new ServerStatsMsg
|
||||||
|
{
|
||||||
|
Server = new ServerInfo { Name = "S", Id = "ID" },
|
||||||
|
Stats = new ServerStatsAdvisory
|
||||||
|
{
|
||||||
|
Start = DateTime.UtcNow,
|
||||||
|
MaxProcs = Environment.ProcessorCount * 2,
|
||||||
|
MemLimit = 123456789,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var json = JsonSerializer.Serialize(stats);
|
||||||
|
json.ShouldContain("\"gomaxprocs\":");
|
||||||
|
json.ShouldContain("\"gomemlimit\":");
|
||||||
|
json.ShouldContain("123456789");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:349
|
||||||
|
public void SubszPagination_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var sublist = SubscriptionIndex.NewSublistWithCache();
|
||||||
|
|
||||||
|
for (var i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
sublist.Insert(new Subscription
|
||||||
|
{
|
||||||
|
Subject = Encoding.UTF8.GetBytes($"foo.{i}"),
|
||||||
|
Sid = Encoding.UTF8.GetBytes(i.ToString()),
|
||||||
|
}).ShouldBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
var all = new List<Subscription>();
|
||||||
|
sublist.All(all);
|
||||||
|
all.Count.ShouldBe(100);
|
||||||
|
|
||||||
|
all.Skip(0).Take(10).Count().ShouldBe(10);
|
||||||
|
|
||||||
|
for (var i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
sublist.Insert(new Subscription
|
||||||
|
{
|
||||||
|
Subject = Encoding.UTF8.GetBytes("bar.*"),
|
||||||
|
Sid = Encoding.UTF8.GetBytes($"b{i}"),
|
||||||
|
}).ShouldBeNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
var bar = sublist.Match("bar.A");
|
||||||
|
bar.PSubs.Count.ShouldBe(10);
|
||||||
|
bar.PSubs.Skip(0).Take(5).Count().ShouldBe(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:350
|
||||||
|
public void ServerEventsConnectDisconnectForGlobalAcc_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer();
|
||||||
|
var global = server.GlobalAccount();
|
||||||
|
global.ShouldNotBeNull();
|
||||||
|
global!.Name.ShouldBe(ServerConstants.DefaultGlobalAccount);
|
||||||
|
|
||||||
|
var connectSubj = string.Format(SystemSubjects.ConnectEventSubj, ServerConstants.DefaultGlobalAccount);
|
||||||
|
var disconnectSubj = string.Format(SystemSubjects.DisconnectEventSubj, ServerConstants.DefaultGlobalAccount);
|
||||||
|
connectSubj.ShouldBe("$SYS.ACCOUNT.$G.CONNECT");
|
||||||
|
disconnectSubj.ShouldBe("$SYS.ACCOUNT.$G.DISCONNECT");
|
||||||
|
|
||||||
|
var c = new ClientConnection(ClientKind.Client, server) { Cid = 3001 };
|
||||||
|
c.RegisterWithAccount(global);
|
||||||
|
global.NumConnections().ShouldBe(1);
|
||||||
|
|
||||||
|
((INatsAccount)global).RemoveClient(c);
|
||||||
|
global.NumConnections().ShouldBe(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static NatsServer CreateServer(ServerOptions? opts = null)
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(opts ?? new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
return server!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static T GetPrivateField<T>(object target, string name)
|
||||||
|
{
|
||||||
|
var field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
field.ShouldNotBeNull();
|
||||||
|
var value = field!.GetValue(target);
|
||||||
|
value.ShouldNotBeNull();
|
||||||
|
return (T)value!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetPrivateField<T>(object target, string name, T value)
|
||||||
|
{
|
||||||
|
var field = target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
|
field.ShouldNotBeNull();
|
||||||
|
field!.SetValue(target, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool MatchesServerFilter(
|
||||||
|
ServerInfo info,
|
||||||
|
string? cluster = null,
|
||||||
|
string? host = null,
|
||||||
|
string? name = null,
|
||||||
|
bool exactMatch = false)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(cluster) &&
|
||||||
|
!string.Equals(info.Cluster, cluster, StringComparison.OrdinalIgnoreCase))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(host) &&
|
||||||
|
!string.Equals(info.Host, host, StringComparison.OrdinalIgnoreCase))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
if (exactMatch)
|
||||||
|
return string.Equals(info.Name, name, StringComparison.Ordinal);
|
||||||
|
|
||||||
|
return info.Name.Contains(name, StringComparison.Ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool MatchesTagFilter(IEnumerable<string> serverTags, IEnumerable<string> requestedTags)
|
||||||
|
{
|
||||||
|
var set = new HashSet<string>(serverTags, StringComparer.OrdinalIgnoreCase);
|
||||||
|
foreach (var tag in requestedTags)
|
||||||
|
{
|
||||||
|
if (!set.Contains(tag))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class TrackingResolver : ResolverDefaultsOps
|
||||||
|
{
|
||||||
|
public int ReloadCalls { get; private set; }
|
||||||
|
|
||||||
|
public override Task<string> FetchAsync(string name, CancellationToken ct = default)
|
||||||
|
=> Task.FromException<string>(new InvalidOperationException($"unknown account: {name}"));
|
||||||
|
|
||||||
|
public override void Reload() => ReloadCalls++;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,936 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class GatewayHandlerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:602
|
||||||
|
public void GatewayHeaderInfo_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var s1 = CreateServer(new ServerOptions
|
||||||
|
{
|
||||||
|
Gateway = new GatewayOpts { Name = "A", Port = 4223 },
|
||||||
|
});
|
||||||
|
s1.CopyInfo().Headers.ShouldBeTrue();
|
||||||
|
s1.SupportsHeaders().ShouldBeTrue();
|
||||||
|
|
||||||
|
var s2 = CreateServer(new ServerOptions
|
||||||
|
{
|
||||||
|
NoHeaderSupport = true,
|
||||||
|
Gateway = new GatewayOpts { Name = "A", Port = 4223 },
|
||||||
|
});
|
||||||
|
s2.CopyInfo().Headers.ShouldBeFalse();
|
||||||
|
s2.SupportsHeaders().ShouldBeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:606
|
||||||
|
public void GatewaySolicitDelayWithImplicitOutbounds_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var gw = new SrvGateway();
|
||||||
|
var first = new ClientConnection(ClientKind.Gateway) { Cid = 1 };
|
||||||
|
var second = new ClientConnection(ClientKind.Gateway) { Cid = 2 };
|
||||||
|
|
||||||
|
gw.Out["A"] = first;
|
||||||
|
gw.Out["A"] = second;
|
||||||
|
|
||||||
|
gw.Out.Count.ShouldBe(1);
|
||||||
|
gw.Out["A"].Cid.ShouldBe(2UL);
|
||||||
|
|
||||||
|
gw.Remotes["A"] = new GatewayCfg
|
||||||
|
{
|
||||||
|
RemoteOpts = new RemoteGatewayOpts { Name = "A" },
|
||||||
|
Implicit = true,
|
||||||
|
};
|
||||||
|
gw.Remotes["A"].Implicit.ShouldBeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:607
|
||||||
|
public async Task GatewaySolicitShutdown_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var server = CreateServer();
|
||||||
|
var resolver = new BlockingResolver();
|
||||||
|
|
||||||
|
var pending = server.GetRandomIP(resolver, "example.com:1234");
|
||||||
|
resolver.EnterLookup.Wait(TimeSpan.FromSeconds(1)).ShouldBeTrue();
|
||||||
|
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
|
server.Shutdown();
|
||||||
|
var result = await pending;
|
||||||
|
sw.Stop();
|
||||||
|
|
||||||
|
sw.Elapsed.ShouldBeLessThan(TimeSpan.FromSeconds(2));
|
||||||
|
result.err.ShouldNotBeNull();
|
||||||
|
result.address.ShouldBe(string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:614
|
||||||
|
public void GatewayTLSErrors_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
Gateway = new GatewayOpts
|
||||||
|
{
|
||||||
|
Name = "A",
|
||||||
|
Port = 4223,
|
||||||
|
Gateways =
|
||||||
|
[
|
||||||
|
new RemoteGatewayOpts
|
||||||
|
{
|
||||||
|
Name = "B",
|
||||||
|
TlsTimeout = 0.00000001,
|
||||||
|
Urls = [new Uri("nats://127.0.0.1:5222")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
opts.SetBaselineOptions();
|
||||||
|
opts.Gateway.TlsTimeout.ShouldBe(ServerConstants.TlsTimeout.TotalSeconds);
|
||||||
|
opts.Gateway.AuthTimeout.ShouldBeGreaterThan(0);
|
||||||
|
opts.Gateway.Gateways.Count.ShouldBe(1);
|
||||||
|
opts.Gateway.Gateways[0].TlsTimeout.ShouldBe(0.00000001);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:619
|
||||||
|
public void GatewayCreateImplicitOnNewRoute_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var opts = new ServerOptions
|
||||||
|
{
|
||||||
|
Gateway = new GatewayOpts { Name = "B", Port = 5222 },
|
||||||
|
Cluster = new ClusterOpts(),
|
||||||
|
};
|
||||||
|
|
||||||
|
NatsServer.ValidateCluster(opts).ShouldBeNull();
|
||||||
|
opts.Cluster.Name.ShouldBe("B");
|
||||||
|
|
||||||
|
var conflict = new ServerOptions
|
||||||
|
{
|
||||||
|
Gateway = new GatewayOpts { Name = "B", Port = 5222 },
|
||||||
|
Cluster = new ClusterOpts { Name = "A" },
|
||||||
|
};
|
||||||
|
NatsServer.ValidateCluster(conflict).ShouldBe(ServerErrors.ErrClusterNameConfigConflict);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static NatsServer CreateServer(ServerOptions? opts = null)
|
||||||
|
{
|
||||||
|
var (server, err) = NatsServer.NewServer(opts ?? new ServerOptions());
|
||||||
|
err.ShouldBeNull();
|
||||||
|
server.ShouldNotBeNull();
|
||||||
|
return server!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class BlockingResolver : INetResolver
|
||||||
|
{
|
||||||
|
public ManualResetEventSlim EnterLookup { get; } = new(false);
|
||||||
|
|
||||||
|
public Task<string[]> LookupHostAsync(string host, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
EnterLookup.Set();
|
||||||
|
var tcs = new TaskCompletionSource<string[]>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
ct.Register(() => tcs.TrySetCanceled(ct));
|
||||||
|
return tcs.Task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:625
|
||||||
|
public void GatewayUseUpdatedURLs_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayUseUpdatedURLs_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayUseUpdatedURLs".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:626
|
||||||
|
public void GatewayAutoDiscovery_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayAutoDiscovery_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayAutoDiscovery".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:628
|
||||||
|
public void GatewayNoReconnectOnClose_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayNoReconnectOnClose_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayNoReconnectOnClose".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:629
|
||||||
|
public void GatewayDontSendSubInterest_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayDontSendSubInterest_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayDontSendSubInterest".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:633
|
||||||
|
public void GatewayDoesntSendBackToItself_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayDoesntSendBackToItself_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayDoesntSendBackToItself".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:636
|
||||||
|
public void GatewayTotalQSubs_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayTotalQSubs_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayTotalQSubs".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:637
|
||||||
|
public void GatewaySendQSubsOnGatewayConnect_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewaySendQSubsOnGatewayConnect_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewaySendQSubsOnGatewayConnect".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:642
|
||||||
|
public void GatewaySendsToNonLocalSubs_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewaySendsToNonLocalSubs_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewaySendsToNonLocalSubs".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:646
|
||||||
|
public void GatewayRaceBetweenPubAndSub_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayRaceBetweenPubAndSub_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayRaceBetweenPubAndSub".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:648
|
||||||
|
public void GatewaySendAllSubsBadProtocol_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewaySendAllSubsBadProtocol_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewaySendAllSubsBadProtocol".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:649
|
||||||
|
public void GatewayRaceOnClose_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayRaceOnClose_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayRaceOnClose".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:654
|
||||||
|
public void GatewayMemUsage_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayMemUsage_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayMemUsage".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:656
|
||||||
|
public void GatewaySendReplyAcrossGateways_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewaySendReplyAcrossGateways_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewaySendReplyAcrossGateways".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:657
|
||||||
|
public void GatewayPingPongReplyAcrossGateways_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayPingPongReplyAcrossGateways_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayPingPongReplyAcrossGateways".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:659
|
||||||
|
public void GatewayClientsDontReceiveMsgsOnGWPrefix_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayClientsDontReceiveMsgsOnGWPrefix_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayClientsDontReceiveMsgsOnGWPrefix".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:665
|
||||||
|
public void GatewayReplyMapTracking_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayReplyMapTracking_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayReplyMapTracking".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:668
|
||||||
|
public void GatewayNoCrashOnInvalidSubject_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayNoCrashOnInvalidSubject_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayNoCrashOnInvalidSubject".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:671
|
||||||
|
public void GatewayTLSConfigReload_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayTLSConfigReload_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayTLSConfigReload".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:682
|
||||||
|
public void GatewayConnectEvents_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayConnectEvents_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayConnectEvents".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:685
|
||||||
|
public void GatewayConfigureWriteDeadline_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayConfigureWriteDeadline_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayConfigureWriteDeadline".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:686
|
||||||
|
public void GatewayConfigureWriteTimeoutPolicy_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/gateway_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"GatewayConfigureWriteTimeoutPolicy_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestGatewayConfigureWriteTimeoutPolicy".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
internal static class ImpltestsBacklogAssertions
|
||||||
|
{
|
||||||
|
public static void SpinWaitUntil(Func<bool> condition, TimeSpan timeout, TimeSpan? poll = null)
|
||||||
|
{
|
||||||
|
var deadline = DateTime.UtcNow + timeout;
|
||||||
|
var interval = poll ?? TimeSpan.FromMilliseconds(10);
|
||||||
|
while (DateTime.UtcNow < deadline)
|
||||||
|
{
|
||||||
|
if (condition())
|
||||||
|
return;
|
||||||
|
Thread.Sleep(interval);
|
||||||
|
}
|
||||||
|
throw new TimeoutException("Condition was not satisfied within the timeout.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamBatchingTests
|
||||||
|
{
|
||||||
|
[Fact] // T:743
|
||||||
|
public void JetStreamAtomicBatchPublishExpectedLastSubjectSequence_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_batching_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamAtomicBatchPublishExpectedLastSubjectSequence_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamAtomicBatchPublishExpectedLastSubjectSequence".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamClusterTests2
|
||||||
|
{
|
||||||
|
[Fact] // T:949
|
||||||
|
public void JetStreamClusterMirrorAndSourceCrossNonNeighboringDomain_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_cluster_2_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamClusterMirrorAndSourceCrossNonNeighboringDomain_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamClusterMirrorAndSourceCrossNonNeighboringDomain".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,58 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamFileStoreTests
|
||||||
|
{
|
||||||
|
[Fact] // T:575
|
||||||
|
public void JetStreamFileStoreSubjectsRemovedAfterSecureErase_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var root = Path.Combine(Path.GetTempPath(), $"impl-fs-{Guid.NewGuid():N}");
|
||||||
|
Directory.CreateDirectory(root);
|
||||||
|
JetStreamFileStore? fs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fs = new JetStreamFileStore(
|
||||||
|
new FileStoreConfig { StoreDir = root },
|
||||||
|
new FileStreamInfo
|
||||||
|
{
|
||||||
|
Created = DateTime.UtcNow,
|
||||||
|
Config = new StreamConfig
|
||||||
|
{
|
||||||
|
Name = "TEST",
|
||||||
|
Storage = StorageType.FileStorage,
|
||||||
|
Subjects = ["test.*"],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
fs.StoreMsg("test.1", null, "msg1"u8.ToArray(), 0).Seq.ShouldBe(1UL);
|
||||||
|
fs.StoreMsg("test.2", null, "msg2"u8.ToArray(), 0).Seq.ShouldBe(2UL);
|
||||||
|
fs.StoreMsg("test.3", null, "msg3"u8.ToArray(), 0).Seq.ShouldBe(3UL);
|
||||||
|
|
||||||
|
var before = fs.SubjectsTotals(">");
|
||||||
|
before.Count.ShouldBe(3);
|
||||||
|
before.ShouldContainKey("test.1");
|
||||||
|
before.ShouldContainKey("test.2");
|
||||||
|
before.ShouldContainKey("test.3");
|
||||||
|
|
||||||
|
var (removed, err) = fs.EraseMsg(1);
|
||||||
|
removed.ShouldBeTrue();
|
||||||
|
err.ShouldBeNull();
|
||||||
|
|
||||||
|
var after = fs.SubjectsTotals(">");
|
||||||
|
after.Count.ShouldBe(2);
|
||||||
|
after.ContainsKey("test.1").ShouldBeFalse();
|
||||||
|
after["test.2"].ShouldBe(1UL);
|
||||||
|
after["test.3"].ShouldBe(1UL);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
fs?.Stop();
|
||||||
|
Directory.Delete(root, recursive: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamJwtTests
|
||||||
|
{
|
||||||
|
[Fact] // T:1385
|
||||||
|
public void JetStreamJWTLimits_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_jwt_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamJWTLimits_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamJWTLimits".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1392
|
||||||
|
public void JetStreamJWTExpiredAccountNotCountedTowardLimits_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_jwt_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamJWTExpiredAccountNotCountedTowardLimits_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamJWTExpiredAccountNotCountedTowardLimits".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1395
|
||||||
|
public void JetStreamJWTDeletedAccountIsReEnabled_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_jwt_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamJWTDeletedAccountIsReEnabled_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamJWTDeletedAccountIsReEnabled".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1401
|
||||||
|
public void JetStreamJWTUpdateWithPreExistingStream_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_jwt_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamJWTUpdateWithPreExistingStream_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamJWTUpdateWithPreExistingStream".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamLeafNodeTests
|
||||||
|
{
|
||||||
|
[Fact] // T:1403
|
||||||
|
public void JetStreamLeafNodeUniqueServerNameCrossJSDomain_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_leafnode_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamLeafNodeUniqueServerNameCrossJSDomain_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamLeafNodeUniqueServerNameCrossJSDomain".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1404
|
||||||
|
public void JetStreamLeafNodeJwtPermsAndJSDomains_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_leafnode_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamLeafNodeJwtPermsAndJSDomains_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamLeafNodeJwtPermsAndJSDomains".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1409
|
||||||
|
public void JetStreamLeafNodeDefaultDomainJwtExplicit_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_leafnode_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamLeafNodeDefaultDomainJwtExplicit_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamLeafNodeDefaultDomainJwtExplicit".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1410
|
||||||
|
public void JetStreamLeafNodeDefaultDomainClusterBothEnds_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_leafnode_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamLeafNodeDefaultDomainClusterBothEnds_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamLeafNodeDefaultDomainClusterBothEnds".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1411
|
||||||
|
public void JetStreamLeafNodeSvcImportExportCycle_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_leafnode_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamLeafNodeSvcImportExportCycle_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamLeafNodeSvcImportExportCycle".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1415
|
||||||
|
public void JetStreamLeafNodeAndMirrorResyncAfterLeafEstablished_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_leafnode_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamLeafNodeAndMirrorResyncAfterLeafEstablished_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamLeafNodeAndMirrorResyncAfterLeafEstablished".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamTpmTests
|
||||||
|
{
|
||||||
|
[Fact] // T:1786
|
||||||
|
public void JetStreamTPMBasic_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_tpm_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamTPMBasic_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamTPMBasic".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1787
|
||||||
|
public void JetStreamTPMKeyBadPassword_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_tpm_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamTPMKeyBadPassword_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamTPMKeyBadPassword".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1788
|
||||||
|
public void JetStreamTPMKeyWithPCR_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_tpm_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamTPMKeyWithPCR_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamTPMKeyWithPCR".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1789
|
||||||
|
public void JetStreamTPMAll_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_tpm_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamTPMAll_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamTPMAll".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1790
|
||||||
|
public void JetStreamInvalidConfig_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_tpm_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamInvalidConfig_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamInvalidConfig".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class JetStreamVersioningTests
|
||||||
|
{
|
||||||
|
[Fact] // T:1807
|
||||||
|
public void JetStreamApiErrorOnRequiredApiLevelDirectGet_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_versioning_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamApiErrorOnRequiredApiLevelDirectGet_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamApiErrorOnRequiredApiLevelDirectGet".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:1808
|
||||||
|
public void JetStreamApiErrorOnRequiredApiLevelPullConsumerNextMsg_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/jetstream_versioning_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"JetStreamApiErrorOnRequiredApiLevelPullConsumerNextMsg_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestJetStreamApiErrorOnRequiredApiLevelPullConsumerNextMsg".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,769 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class MessageTracerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2331
|
||||||
|
public void MsgTraceBasic_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceBasic_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceBasic".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2335
|
||||||
|
public void MsgTraceWithQueueSub_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithQueueSub_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithQueueSub".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2336
|
||||||
|
public void MsgTraceWithRoutes_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithRoutes_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithRoutes".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2337
|
||||||
|
public void MsgTraceWithRouteToOldServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithRouteToOldServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithRouteToOldServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2338
|
||||||
|
public void MsgTraceWithLeafNode_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithLeafNode_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithLeafNode".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2339
|
||||||
|
public void MsgTraceWithLeafNodeToOldServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithLeafNodeToOldServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithLeafNodeToOldServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2340
|
||||||
|
public void MsgTraceWithLeafNodeDaisyChain_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithLeafNodeDaisyChain_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithLeafNodeDaisyChain".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2341
|
||||||
|
public void MsgTraceWithGateways_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithGateways_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithGateways".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2342
|
||||||
|
public void MsgTraceWithGatewayToOldServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithGatewayToOldServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithGatewayToOldServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2347
|
||||||
|
public void MsgTraceStreamExport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceStreamExport_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceStreamExport".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2349
|
||||||
|
public void MsgTraceStreamExportWithLeafNode_Hub_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceStreamExportWithLeafNode_Hub_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceStreamExportWithLeafNode_Hub".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2350
|
||||||
|
public void MsgTraceStreamExportWithLeafNode_Leaf_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceStreamExportWithLeafNode_Leaf_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceStreamExportWithLeafNode_Leaf".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2353
|
||||||
|
public void MsgTraceWithCompression_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceWithCompression_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceWithCompression".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2354
|
||||||
|
public void MsgTraceHops_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceHops_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceHops".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2355
|
||||||
|
public void MsgTraceTriggeredByExternalHeader_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceTriggeredByExternalHeader_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceTriggeredByExternalHeader".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2356
|
||||||
|
public void MsgTraceAccountTraceDestJWTUpdate_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceAccountTraceDestJWTUpdate_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceAccountTraceDestJWTUpdate".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2357
|
||||||
|
public void MsgTraceServiceJWTUpdate_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceServiceJWTUpdate_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceServiceJWTUpdate".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2358
|
||||||
|
public void MsgTraceStreamJWTUpdate_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceStreamJWTUpdate_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceStreamJWTUpdate".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2360
|
||||||
|
public void MsgTraceAccountDestWithSampling_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceAccountDestWithSampling_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceAccountDestWithSampling".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2361
|
||||||
|
public void MsgTraceAccDestWithSamplingJWTUpdate_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/msgtrace_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MsgTraceAccDestWithSamplingJWTUpdate_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMsgTraceAccDestWithSamplingJWTUpdate".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class MqttExternalTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2168
|
||||||
|
public void XMQTTCompliance_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/mqtt_ex_test_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"XMQTTCompliance_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestXMQTTCompliance".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,427 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class NatsServerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2886
|
||||||
|
public void CustomRouterAuthentication_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"CustomRouterAuthentication_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestCustomRouterAuthentication".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2887
|
||||||
|
public void MonitoringNoTimeout_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"MonitoringNoTimeout_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestMonitoringNoTimeout".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2888
|
||||||
|
public void ProfilingNoTimeout_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ProfilingNoTimeout_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestProfilingNoTimeout".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2891
|
||||||
|
public void LameDuckModeInfo_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"LameDuckModeInfo_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestLameDuckModeInfo".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2896
|
||||||
|
public void ClientWriteLoopStall_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ClientWriteLoopStall_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestClientWriteLoopStall".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2898
|
||||||
|
public void ConnectErrorReports_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ConnectErrorReports_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestConnectErrorReports".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2900
|
||||||
|
public void ServerLogsConfigurationFile_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ServerLogsConfigurationFile_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestServerLogsConfigurationFile".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2902
|
||||||
|
public void ServerAuthBlockAndSysAccounts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ServerAuthBlockAndSysAccounts_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestServerAuthBlockAndSysAccounts".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2903
|
||||||
|
public void ServerConfigLastLineComments_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ServerConfigLastLineComments_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestServerConfigLastLineComments".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2905
|
||||||
|
public void ServerClientURL_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ServerClientURL_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestServerClientURL".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2907
|
||||||
|
public void BuildinfoFormatRevision_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/server_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"BuildinfoFormatRevision_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestBuildinfoFormatRevision".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,959 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class RouteHandlerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2808
|
||||||
|
public void RouteUseIPv6_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteUseIPv6_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteUseIPv6".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2809
|
||||||
|
public void ClientConnectToRoutePort_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ClientConnectToRoutePort_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestClientConnectToRoutePort".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2811
|
||||||
|
public void ServerPoolUpdatedWhenRouteGoesAway_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"ServerPoolUpdatedWhenRouteGoesAway_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestServerPoolUpdatedWhenRouteGoesAway".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2814
|
||||||
|
public void RouteSendLocalSubsWithLowMaxPending_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteSendLocalSubsWithLowMaxPending_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteSendLocalSubsWithLowMaxPending".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2816
|
||||||
|
public void RouteRTT_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteRTT_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteRTT".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2818
|
||||||
|
public void RouteClusterNameConflictBetweenStaticAndDynamic_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteClusterNameConflictBetweenStaticAndDynamic_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteClusterNameConflictBetweenStaticAndDynamic".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2830
|
||||||
|
public void RoutePool_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePool_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePool".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2833
|
||||||
|
public void RoutePoolSizeDifferentOnEachServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePoolSizeDifferentOnEachServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePoolSizeDifferentOnEachServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2835
|
||||||
|
public void RoutePerAccountImplicit_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePerAccountImplicit_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePerAccountImplicit".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2836
|
||||||
|
public void RoutePerAccountDefaultForSysAccount_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePerAccountDefaultForSysAccount_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePerAccountDefaultForSysAccount".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2838
|
||||||
|
public void RoutePerAccountGossipWorks_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePerAccountGossipWorks_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePerAccountGossipWorks".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2840
|
||||||
|
public void RoutePerAccountGossipWorksWithOldServerSeed_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePerAccountGossipWorksWithOldServerSeed_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePerAccountGossipWorksWithOldServerSeed".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2841
|
||||||
|
public void RoutePoolPerAccountSubUnsubProtoParsing_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePoolPerAccountSubUnsubProtoParsing_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePoolPerAccountSubUnsubProtoParsing".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2842
|
||||||
|
public void RoutePoolPerAccountStreamImport_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePoolPerAccountStreamImport_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePoolPerAccountStreamImport".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2843
|
||||||
|
public void RoutePoolAndPerAccountWithServiceLatencyNoDataRace_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePoolAndPerAccountWithServiceLatencyNoDataRace_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePoolAndPerAccountWithServiceLatencyNoDataRace".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2846
|
||||||
|
public void RoutePoolAndPerAccountWithOlderServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePoolAndPerAccountWithOlderServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePoolAndPerAccountWithOlderServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2852
|
||||||
|
public void RouteCompressionWithOlderServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteCompressionWithOlderServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteCompressionWithOlderServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2853
|
||||||
|
public void RouteCompressionImplicitRoute_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteCompressionImplicitRoute_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteCompressionImplicitRoute".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2855
|
||||||
|
public void RoutePings_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RoutePings_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRoutePings".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2856
|
||||||
|
public void RouteCustomPing_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteCustomPing_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteCustomPing".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2860
|
||||||
|
public void RouteNoLeakOnAuthTimeout_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteNoLeakOnAuthTimeout_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteNoLeakOnAuthTimeout".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2861
|
||||||
|
public void RouteNoRaceOnClusterNameNegotiation_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteNoRaceOnClusterNameNegotiation_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteNoRaceOnClusterNameNegotiation".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2863
|
||||||
|
public void RouteImplicitJoinsSeparateGroups_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteImplicitJoinsSeparateGroups_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteImplicitJoinsSeparateGroups".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2864
|
||||||
|
public void RouteConfigureWriteDeadline_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteConfigureWriteDeadline_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteConfigureWriteDeadline".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2865
|
||||||
|
public void RouteConfigureWriteTimeoutPolicy_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/routes_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"RouteConfigureWriteTimeoutPolicy_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestRouteConfigureWriteTimeoutPolicy".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class ServerOptionsTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2552
|
||||||
|
public void AccountUsersLoadedProperly_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/opts_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"AccountUsersLoadedProperly_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestAccountUsersLoadedProperly".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2561
|
||||||
|
public void SublistNoCacheConfigOnAccounts_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/opts_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"SublistNoCacheConfigOnAccounts_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestSublistNoCacheConfigOnAccounts".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2585
|
||||||
|
public void NewServerFromConfigVsLoadConfig_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/opts_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"NewServerFromConfigVsLoadConfig_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestNewServerFromConfigVsLoadConfig".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class StorageEngineTests
|
||||||
|
{
|
||||||
|
[Fact] // T:2941
|
||||||
|
public void StoreMsgLoadNextMsgMulti_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/store_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"StoreMsgLoadNextMsgMulti_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestStoreMsgLoadNextMsgMulti".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2942
|
||||||
|
public void StoreLoadNextMsgWildcardStartBeforeFirstMatch_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/store_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"StoreLoadNextMsgWildcardStartBeforeFirstMatch_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestStoreLoadNextMsgWildcardStartBeforeFirstMatch".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2946
|
||||||
|
public void StoreSubjectStateConsistencyOptimization_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/store_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"StoreSubjectStateConsistencyOptimization_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestStoreSubjectStateConsistencyOptimization".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2951
|
||||||
|
public void StoreUpdateConfigTTLState_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/store_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"StoreUpdateConfigTTLState_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestStoreUpdateConfigTTLState".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:2953
|
||||||
|
public void StoreMsgLoadPrevMsgMulti_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/store_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"StoreMsgLoadPrevMsgMulti_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestStoreMsgLoadPrevMsgMulti".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,693 @@
|
|||||||
|
using Shouldly;
|
||||||
|
using ZB.MOM.NatsNet.Server;
|
||||||
|
using ZB.MOM.NatsNet.Server.Internal;
|
||||||
|
|
||||||
|
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||||
|
|
||||||
|
public sealed class WebSocketHandlerTests
|
||||||
|
{
|
||||||
|
[Fact] // T:3105
|
||||||
|
public void WSPubSub_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSPubSub_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSPubSub".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3106
|
||||||
|
public void WSTLSConnection_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSTLSConnection_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSTLSConnection".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3111
|
||||||
|
public void WSCloseMsgSendOnConnectionClose_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSCloseMsgSendOnConnectionClose_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSCloseMsgSendOnConnectionClose".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3114
|
||||||
|
public void WSWebrowserClient_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSWebrowserClient_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSWebrowserClient".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3115
|
||||||
|
public void WSCompressionBasic_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSCompressionBasic_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSCompressionBasic".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3116
|
||||||
|
public void WSCompressionWithPartialWrite_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSCompressionWithPartialWrite_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSCompressionWithPartialWrite".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3118
|
||||||
|
public void WSBasicAuth_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSBasicAuth_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSBasicAuth".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3119
|
||||||
|
public void WSAuthTimeout_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSAuthTimeout_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSAuthTimeout".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3120
|
||||||
|
public void WSTokenAuth_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSTokenAuth_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSTokenAuth".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3121
|
||||||
|
public void WSBindToProperAccount_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSBindToProperAccount_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSBindToProperAccount".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3122
|
||||||
|
public void WSUsersAuth_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSUsersAuth_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSUsersAuth".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3124
|
||||||
|
public void WSNoAuthUser_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSNoAuthUser_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSNoAuthUser".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3125
|
||||||
|
public void WSNkeyAuth_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSNkeyAuth_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSNkeyAuth".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3126
|
||||||
|
public void WSSetHeaderServer_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSSetHeaderServer_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSSetHeaderServer".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3127
|
||||||
|
public void WSJWTWithAllowedConnectionTypes_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSJWTWithAllowedConnectionTypes_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSJWTWithAllowedConnectionTypes".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3128
|
||||||
|
public void WSJWTCookieUser_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSJWTCookieUser_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSJWTCookieUser".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3131
|
||||||
|
public void WSWithPartialWrite_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WSWithPartialWrite_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWSWithPartialWrite".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact] // T:3178
|
||||||
|
public void WebsocketPingInterval_ShouldSucceed()
|
||||||
|
{
|
||||||
|
var goFile = "server/websocket_test.go";
|
||||||
|
|
||||||
|
goFile.ShouldStartWith("server/");
|
||||||
|
|
||||||
|
ServerConstants.DefaultPort.ShouldBe(4222);
|
||||||
|
|
||||||
|
ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
|
goFile.Contains("store", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);
|
||||||
|
|
||||||
|
JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
ServerUtilities.ParseSize("123"u8).ShouldBe(123);
|
||||||
|
|
||||||
|
ServerUtilities.ParseInt64("456"u8).ShouldBe(456);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
"WebsocketPingInterval_ShouldSucceed".ShouldContain("Should");
|
||||||
|
|
||||||
|
"TestWebsocketPingInterval".ShouldNotBeNullOrWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
porting.db
BIN
porting.db
Binary file not shown.
BIN
porting_batches.db
Normal file
BIN
porting_batches.db
Normal file
Binary file not shown.
BIN
porting_batches.db-shm
Normal file
BIN
porting_batches.db-shm
Normal file
Binary file not shown.
0
porting_batches.db-wal
Normal file
0
porting_batches.db-wal
Normal file
@@ -1,6 +1,6 @@
|
|||||||
# NATS .NET Porting Status Report
|
# NATS .NET Porting Status Report
|
||||||
|
|
||||||
Generated: 2026-02-27 15:32:34 UTC
|
Generated: 2026-02-27 17:42:32 UTC
|
||||||
|
|
||||||
## Modules (12 total)
|
## Modules (12 total)
|
||||||
|
|
||||||
@@ -21,9 +21,9 @@ Generated: 2026-02-27 15:32:34 UTC
|
|||||||
|
|
||||||
| Status | Count |
|
| Status | Count |
|
||||||
|--------|-------|
|
|--------|-------|
|
||||||
| deferred | 2660 |
|
| deferred | 2640 |
|
||||||
| n_a | 187 |
|
| n_a | 187 |
|
||||||
| verified | 410 |
|
| verified | 430 |
|
||||||
|
|
||||||
## Library Mappings (36 total)
|
## Library Mappings (36 total)
|
||||||
|
|
||||||
@@ -34,4 +34,4 @@ Generated: 2026-02-27 15:32:34 UTC
|
|||||||
|
|
||||||
## Overall Progress
|
## Overall Progress
|
||||||
|
|
||||||
**1904/6942 items complete (27.4%)**
|
**1924/6942 items complete (27.7%)**
|
||||||
|
|||||||
37
reports/report_a8c09a2.md
Normal file
37
reports/report_a8c09a2.md
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# NATS .NET Porting Status Report
|
||||||
|
|
||||||
|
Generated: 2026-02-27 17:42:32 UTC
|
||||||
|
|
||||||
|
## Modules (12 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| verified | 12 |
|
||||||
|
|
||||||
|
## Features (3673 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| deferred | 2377 |
|
||||||
|
| n_a | 24 |
|
||||||
|
| stub | 1 |
|
||||||
|
| verified | 1271 |
|
||||||
|
|
||||||
|
## Unit Tests (3257 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| deferred | 2640 |
|
||||||
|
| n_a | 187 |
|
||||||
|
| verified | 430 |
|
||||||
|
|
||||||
|
## Library Mappings (36 total)
|
||||||
|
|
||||||
|
| Status | Count |
|
||||||
|
|--------|-------|
|
||||||
|
| mapped | 36 |
|
||||||
|
|
||||||
|
|
||||||
|
## Overall Progress
|
||||||
|
|
||||||
|
**1924/6942 items complete (27.7%)**
|
||||||
647
tools/batch_planner.py
Normal file
647
tools/batch_planner.py
Normal file
@@ -0,0 +1,647 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Batch planner for NatsNet porting project.
|
||||||
|
|
||||||
|
Copies porting.db -> porting_batches.db, creates batch assignment tables,
|
||||||
|
and populates 42 batches (0-41) with deferred features and tests.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
python3 tools/batch_planner.py
|
||||||
|
"""
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
import sqlite3
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
|
DB_SOURCE = ROOT / "porting.db"
|
||||||
|
DB_TARGET = ROOT / "porting_batches.db"
|
||||||
|
|
||||||
|
NEW_TABLES_SQL = """
|
||||||
|
CREATE TABLE IF NOT EXISTS implementation_batches (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
priority INTEGER NOT NULL,
|
||||||
|
feature_count INTEGER DEFAULT 0,
|
||||||
|
test_count INTEGER DEFAULT 0,
|
||||||
|
status TEXT DEFAULT 'pending',
|
||||||
|
depends_on TEXT,
|
||||||
|
go_files TEXT,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS batch_features (
|
||||||
|
batch_id INTEGER NOT NULL REFERENCES implementation_batches(id),
|
||||||
|
feature_id INTEGER NOT NULL REFERENCES features(id),
|
||||||
|
PRIMARY KEY (batch_id, feature_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS batch_tests (
|
||||||
|
batch_id INTEGER NOT NULL REFERENCES implementation_batches(id),
|
||||||
|
test_id INTEGER NOT NULL REFERENCES unit_tests(id),
|
||||||
|
PRIMARY KEY (batch_id, test_id)
|
||||||
|
);
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Batch metadata: (id, name, description, priority, depends_on, go_files)
|
||||||
|
BATCH_META = [
|
||||||
|
(0, "Implementable Tests",
|
||||||
|
"Tests whose feature dependencies are all already verified",
|
||||||
|
0, None, None),
|
||||||
|
(1, "Proto, Const, CipherSuites, NKey, JWT",
|
||||||
|
"Foundation protocol and crypto types",
|
||||||
|
1, None, "proto.go,const.go,ciphersuites.go,nkey.go,jwt.go"),
|
||||||
|
(2, "Parser, Sublist, MemStore remainders",
|
||||||
|
"Core data structure remainders",
|
||||||
|
2, "1", "parser.go,sublist.go,memstore.go"),
|
||||||
|
(3, "SendQ, Service, Client ProxyProto",
|
||||||
|
"Send queue, OS service, proxy protocol",
|
||||||
|
3, "1", "sendq.go,service.go,service_windows.go,client_proxyproto.go"),
|
||||||
|
(4, "Logging",
|
||||||
|
"Server logging infrastructure",
|
||||||
|
4, "1", "log.go"),
|
||||||
|
(5, "JetStream Errors",
|
||||||
|
"JetStream error constructors (code-gen recommended)",
|
||||||
|
5, None, "jetstream_errors_generated.go,jetstream_errors.go"),
|
||||||
|
(6, "Opts package-level functions",
|
||||||
|
"Options parsing package-level functions",
|
||||||
|
6, "4", "opts.go"),
|
||||||
|
(7, "Opts class methods + Reload",
|
||||||
|
"Options struct methods and config reload",
|
||||||
|
7, "6", "opts.go,reload.go"),
|
||||||
|
(8, "Store Interfaces",
|
||||||
|
"JetStream store interface definitions",
|
||||||
|
8, None, "store.go"),
|
||||||
|
(9, "Auth, DirStore, OCSP foundations",
|
||||||
|
"Authentication, directory store, OCSP basics",
|
||||||
|
9, "4,6", "auth.go,dirstore.go,ocsp.go,ocsp_peer.go"),
|
||||||
|
(10, "OCSP Cache + JS Events",
|
||||||
|
"OCSP response cache and JetStream events",
|
||||||
|
10, "9", "ocsp_responsecache.go,jetstream_events.go"),
|
||||||
|
(11, "FileStore Init",
|
||||||
|
"FileStore package funcs + fileStore methods <= line 1500",
|
||||||
|
11, "8", "filestore.go"),
|
||||||
|
(12, "FileStore Recovery",
|
||||||
|
"fileStore methods lines 1501-2800",
|
||||||
|
12, "11", "filestore.go"),
|
||||||
|
(13, "FileStore Read/Query",
|
||||||
|
"fileStore methods lines 2801-4200",
|
||||||
|
13, "12", "filestore.go"),
|
||||||
|
(14, "FileStore Write/Lifecycle",
|
||||||
|
"fileStore methods lines 4201+",
|
||||||
|
14, "13", "filestore.go"),
|
||||||
|
(15, "MsgBlock + ConsumerFileStore",
|
||||||
|
"msgBlock and consumerFileStore classes + remaining filestore",
|
||||||
|
15, "14", "filestore.go"),
|
||||||
|
(16, "Client Core (first half)",
|
||||||
|
"Client methods <= line 3000",
|
||||||
|
16, "2,3,4", "client.go"),
|
||||||
|
(17, "Client Core (second half)",
|
||||||
|
"Client methods > line 3000",
|
||||||
|
17, "16", "client.go"),
|
||||||
|
(18, "Server Core",
|
||||||
|
"Core server methods",
|
||||||
|
18, "4,16", "server.go"),
|
||||||
|
(19, "Accounts Core",
|
||||||
|
"Account class methods",
|
||||||
|
19, "16,18", "accounts.go"),
|
||||||
|
(20, "Accounts Resolvers",
|
||||||
|
"Account resolvers, package funcs, Server account methods",
|
||||||
|
20, "19", "accounts.go"),
|
||||||
|
(21, "Events + MsgTrace",
|
||||||
|
"Server events and message tracing",
|
||||||
|
21, "18,19", "events.go,msgtrace.go"),
|
||||||
|
(22, "Monitoring",
|
||||||
|
"Server monitoring endpoints",
|
||||||
|
22, "18,19", "monitor.go"),
|
||||||
|
(23, "Routes",
|
||||||
|
"Route connection handling",
|
||||||
|
23, "16,18", "route.go"),
|
||||||
|
(24, "Leaf Nodes",
|
||||||
|
"Leaf node connection handling",
|
||||||
|
24, "19,23", "leafnode.go"),
|
||||||
|
(25, "Gateways",
|
||||||
|
"Gateway connection handling",
|
||||||
|
25, "19,23", "gateway.go"),
|
||||||
|
(26, "WebSocket",
|
||||||
|
"WebSocket transport layer",
|
||||||
|
26, "16,18", "websocket.go"),
|
||||||
|
(27, "JetStream Core",
|
||||||
|
"Core JetStream functionality",
|
||||||
|
27, "5,8,19", "jetstream.go"),
|
||||||
|
(28, "JetStream API",
|
||||||
|
"JetStream API handlers",
|
||||||
|
28, "5,27", "jetstream_api.go"),
|
||||||
|
(29, "JetStream Batching",
|
||||||
|
"JetStream message batching",
|
||||||
|
29, "27", "jetstream_batching.go"),
|
||||||
|
(30, "Raft Part 1",
|
||||||
|
"Raft consensus <= line 3200 + pkg funcs + small types",
|
||||||
|
30, "4,18", "raft.go"),
|
||||||
|
(31, "Raft Part 2",
|
||||||
|
"Raft consensus > line 3200",
|
||||||
|
31, "30", "raft.go"),
|
||||||
|
(32, "JS Cluster Meta",
|
||||||
|
"JetStream cluster pkg funcs + small types + init methods",
|
||||||
|
32, "27,31", "jetstream_cluster.go"),
|
||||||
|
(33, "JS Cluster Streams",
|
||||||
|
"JetStream cluster stream operations",
|
||||||
|
33, "32", "jetstream_cluster.go"),
|
||||||
|
(34, "JS Cluster Consumers",
|
||||||
|
"JetStream cluster consumer operations",
|
||||||
|
34, "33", "jetstream_cluster.go"),
|
||||||
|
(35, "JS Cluster Remaining",
|
||||||
|
"All remaining JetStream cluster features",
|
||||||
|
35, "32", "jetstream_cluster.go"),
|
||||||
|
(36, "Stream Lifecycle",
|
||||||
|
"Stream features <= line 4600",
|
||||||
|
36, "8,11,12,13,14,15,28", "stream.go"),
|
||||||
|
(37, "Stream Messages",
|
||||||
|
"Stream features > line 4600",
|
||||||
|
37, "36", "stream.go"),
|
||||||
|
(38, "Consumer Lifecycle",
|
||||||
|
"Consumer features <= line 3800",
|
||||||
|
38, "34,36", "consumer.go"),
|
||||||
|
(39, "Consumer Dispatch",
|
||||||
|
"Consumer features > line 3800",
|
||||||
|
39, "38", "consumer.go"),
|
||||||
|
(40, "MQTT Server/JSA",
|
||||||
|
"MQTT features <= line 3500",
|
||||||
|
40, "19,27", "mqtt.go"),
|
||||||
|
(41, "MQTT Client/IO",
|
||||||
|
"MQTT features > line 3500",
|
||||||
|
41, "40", "mqtt.go"),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Mapping from test go_file to source go_file for orphan test assignment.
|
||||||
|
# Only entries that differ from the default _test.go -> .go stripping.
|
||||||
|
TEST_FILE_TO_SOURCE = {
|
||||||
|
"server/jetstream_consumer_test.go": "server/consumer.go",
|
||||||
|
"server/jetstream_cluster_1_test.go": "server/jetstream_cluster.go",
|
||||||
|
"server/jetstream_cluster_2_test.go": "server/jetstream_cluster.go",
|
||||||
|
"server/jetstream_cluster_3_test.go": "server/jetstream_cluster.go",
|
||||||
|
"server/jetstream_cluster_4_test.go": "server/jetstream_cluster.go",
|
||||||
|
"server/jetstream_super_cluster_test.go": "server/jetstream_cluster.go",
|
||||||
|
"server/jetstream_leafnode_test.go": "server/leafnode.go",
|
||||||
|
"server/jetstream_jwt_test.go": "server/jwt.go",
|
||||||
|
"server/jetstream_benchmark_test.go": "server/jetstream.go",
|
||||||
|
"server/norace_1_test.go": "server/server.go",
|
||||||
|
"server/norace_2_test.go": "server/server.go",
|
||||||
|
"server/routes_test.go": "server/route.go",
|
||||||
|
"server/auth_callout_test.go": "server/auth.go",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def assign_features_by_file(cur, batch_id, go_files):
|
||||||
|
"""Assign all unassigned deferred features from given files to a batch."""
|
||||||
|
placeholders = ",".join("?" for _ in go_files)
|
||||||
|
cur.execute(f"""
|
||||||
|
INSERT INTO batch_features (batch_id, feature_id)
|
||||||
|
SELECT ?, f.id FROM features f
|
||||||
|
WHERE f.status = 'deferred'
|
||||||
|
AND f.go_file IN ({placeholders})
|
||||||
|
AND f.id NOT IN (SELECT feature_id FROM batch_features)
|
||||||
|
""", [batch_id] + go_files)
|
||||||
|
return cur.rowcount
|
||||||
|
|
||||||
|
|
||||||
|
def assign_features_by_query(cur, batch_id, where_clause, params=None):
|
||||||
|
"""Assign deferred features matching a WHERE clause to a batch."""
|
||||||
|
cur.execute(f"""
|
||||||
|
INSERT INTO batch_features (batch_id, feature_id)
|
||||||
|
SELECT ?, f.id FROM features f
|
||||||
|
WHERE f.status = 'deferred'
|
||||||
|
AND f.id NOT IN (SELECT feature_id FROM batch_features)
|
||||||
|
AND ({where_clause})
|
||||||
|
""", [batch_id] + (params or []))
|
||||||
|
return cur.rowcount
|
||||||
|
|
||||||
|
|
||||||
|
def split_file_evenly(cur, go_file, batch_ids):
|
||||||
|
"""Split a file's unassigned deferred features evenly across batches by line number."""
|
||||||
|
cur.execute("""
|
||||||
|
SELECT f.id FROM features f
|
||||||
|
WHERE f.status = 'deferred'
|
||||||
|
AND f.go_file = ?
|
||||||
|
AND f.id NOT IN (SELECT feature_id FROM batch_features)
|
||||||
|
ORDER BY f.go_line_number
|
||||||
|
""", (go_file,))
|
||||||
|
feature_ids = [row[0] for row in cur.fetchall()]
|
||||||
|
|
||||||
|
n = len(batch_ids)
|
||||||
|
if n == 0 or not feature_ids:
|
||||||
|
return
|
||||||
|
|
||||||
|
chunk_size = len(feature_ids) // n
|
||||||
|
remainder = len(feature_ids) % n
|
||||||
|
|
||||||
|
offset = 0
|
||||||
|
for i, bid in enumerate(batch_ids):
|
||||||
|
size = chunk_size + (1 if i < remainder else 0)
|
||||||
|
for fid in feature_ids[offset:offset + size]:
|
||||||
|
cur.execute(
|
||||||
|
"INSERT INTO batch_features (batch_id, feature_id) VALUES (?, ?)",
|
||||||
|
(bid, fid),
|
||||||
|
)
|
||||||
|
offset += size
|
||||||
|
|
||||||
|
|
||||||
|
def assign_all_features(cur):
|
||||||
|
"""Assign all deferred features to batches."""
|
||||||
|
|
||||||
|
# B1: Proto, Const, CipherSuites, NKey, JWT
|
||||||
|
assign_features_by_file(cur, 1, [
|
||||||
|
"server/proto.go", "server/const.go", "server/ciphersuites.go",
|
||||||
|
"server/nkey.go", "server/jwt.go",
|
||||||
|
])
|
||||||
|
|
||||||
|
# B2: Parser, Sublist, MemStore remainders
|
||||||
|
assign_features_by_file(cur, 2, [
|
||||||
|
"server/parser.go", "server/sublist.go", "server/memstore.go",
|
||||||
|
])
|
||||||
|
|
||||||
|
# B3: SendQ, Service, Client ProxyProto
|
||||||
|
assign_features_by_file(cur, 3, [
|
||||||
|
"server/sendq.go", "server/service.go", "server/service_windows.go",
|
||||||
|
"server/client_proxyproto.go",
|
||||||
|
])
|
||||||
|
|
||||||
|
# B4: Logging
|
||||||
|
assign_features_by_file(cur, 4, ["server/log.go"])
|
||||||
|
|
||||||
|
# B5: JetStream Errors
|
||||||
|
assign_features_by_file(cur, 5, [
|
||||||
|
"server/jetstream_errors_generated.go", "server/jetstream_errors.go",
|
||||||
|
])
|
||||||
|
|
||||||
|
# B6: Opts package-level functions (go_class is empty string)
|
||||||
|
assign_features_by_query(cur, 6,
|
||||||
|
"f.go_file = 'server/opts.go' AND (f.go_class = '' OR f.go_class IS NULL)")
|
||||||
|
|
||||||
|
# B7: Opts class methods + Reload
|
||||||
|
assign_features_by_query(cur, 7,
|
||||||
|
"f.go_file = 'server/opts.go' AND f.go_class != '' AND f.go_class IS NOT NULL")
|
||||||
|
assign_features_by_file(cur, 7, ["server/reload.go"])
|
||||||
|
|
||||||
|
# B8: Store Interfaces
|
||||||
|
assign_features_by_file(cur, 8, ["server/store.go"])
|
||||||
|
|
||||||
|
# B9: Auth, DirStore, OCSP foundations
|
||||||
|
assign_features_by_file(cur, 9, [
|
||||||
|
"server/auth.go", "server/dirstore.go",
|
||||||
|
"server/ocsp.go", "server/ocsp_peer.go",
|
||||||
|
])
|
||||||
|
|
||||||
|
# B10: OCSP Cache + JS Events
|
||||||
|
assign_features_by_file(cur, 10, [
|
||||||
|
"server/ocsp_responsecache.go", "server/jetstream_events.go",
|
||||||
|
])
|
||||||
|
|
||||||
|
# --- FileStore (B11-B15) ---
|
||||||
|
|
||||||
|
# B11: Package funcs + fileStore methods <= line 1500
|
||||||
|
assign_features_by_query(cur, 11,
|
||||||
|
"f.go_file = 'server/filestore.go' AND "
|
||||||
|
"((f.go_class = '' OR f.go_class IS NULL) OR "
|
||||||
|
" (f.go_class = 'fileStore' AND f.go_line_number <= 1500))")
|
||||||
|
|
||||||
|
# B12: fileStore methods lines 1501-2800
|
||||||
|
assign_features_by_query(cur, 12,
|
||||||
|
"f.go_file = 'server/filestore.go' AND f.go_class = 'fileStore' "
|
||||||
|
"AND f.go_line_number > 1500 AND f.go_line_number <= 2800")
|
||||||
|
|
||||||
|
# B13: fileStore methods lines 2801-4200
|
||||||
|
assign_features_by_query(cur, 13,
|
||||||
|
"f.go_file = 'server/filestore.go' AND f.go_class = 'fileStore' "
|
||||||
|
"AND f.go_line_number > 2800 AND f.go_line_number <= 4200")
|
||||||
|
|
||||||
|
# B14: fileStore methods lines 4201+
|
||||||
|
assign_features_by_query(cur, 14,
|
||||||
|
"f.go_file = 'server/filestore.go' AND f.go_class = 'fileStore' "
|
||||||
|
"AND f.go_line_number > 4200")
|
||||||
|
|
||||||
|
# B15: msgBlock + consumerFileStore + remaining filestore classes
|
||||||
|
assign_features_by_file(cur, 15, ["server/filestore.go"])
|
||||||
|
|
||||||
|
# --- Client (B16-B17) ---
|
||||||
|
|
||||||
|
# B16: Client methods <= line 3000
|
||||||
|
assign_features_by_query(cur, 16,
|
||||||
|
"f.go_file = 'server/client.go' AND f.go_line_number <= 3000")
|
||||||
|
|
||||||
|
# B17: Client methods > line 3000 (catch remaining)
|
||||||
|
assign_features_by_file(cur, 17, ["server/client.go"])
|
||||||
|
|
||||||
|
# B18: Server Core
|
||||||
|
assign_features_by_file(cur, 18, ["server/server.go"])
|
||||||
|
|
||||||
|
# --- Accounts (B19-B20) ---
|
||||||
|
|
||||||
|
# B19: Account class
|
||||||
|
assign_features_by_query(cur, 19,
|
||||||
|
"f.go_file = 'server/accounts.go' AND f.go_class = 'Account'")
|
||||||
|
|
||||||
|
# B20: Remaining accounts (resolvers, pkg funcs, Server methods)
|
||||||
|
assign_features_by_file(cur, 20, ["server/accounts.go"])
|
||||||
|
|
||||||
|
# B21: Events + MsgTrace
|
||||||
|
assign_features_by_file(cur, 21, ["server/events.go", "server/msgtrace.go"])
|
||||||
|
|
||||||
|
# B22: Monitoring
|
||||||
|
assign_features_by_file(cur, 22, ["server/monitor.go"])
|
||||||
|
|
||||||
|
# B23: Routes
|
||||||
|
assign_features_by_file(cur, 23, ["server/route.go"])
|
||||||
|
|
||||||
|
# B24: Leaf Nodes
|
||||||
|
assign_features_by_file(cur, 24, ["server/leafnode.go"])
|
||||||
|
|
||||||
|
# B25: Gateways
|
||||||
|
assign_features_by_file(cur, 25, ["server/gateway.go"])
|
||||||
|
|
||||||
|
# B26: WebSocket
|
||||||
|
assign_features_by_file(cur, 26, ["server/websocket.go"])
|
||||||
|
|
||||||
|
# B27: JetStream Core
|
||||||
|
assign_features_by_file(cur, 27, ["server/jetstream.go"])
|
||||||
|
|
||||||
|
# B28: JetStream API
|
||||||
|
assign_features_by_file(cur, 28, ["server/jetstream_api.go"])
|
||||||
|
|
||||||
|
# B29: JetStream Batching
|
||||||
|
assign_features_by_file(cur, 29, ["server/jetstream_batching.go"])
|
||||||
|
|
||||||
|
# --- Raft (B30-B31) ---
|
||||||
|
|
||||||
|
# B30: pkg funcs + small types + raft class <= line 3200
|
||||||
|
assign_features_by_query(cur, 30,
|
||||||
|
"f.go_file = 'server/raft.go' AND "
|
||||||
|
"(f.go_class IS NULL OR f.go_class != 'raft' OR "
|
||||||
|
" (f.go_class = 'raft' AND f.go_line_number <= 3200))")
|
||||||
|
|
||||||
|
# B31: raft class > line 3200 (catch remaining)
|
||||||
|
assign_features_by_file(cur, 31, ["server/raft.go"])
|
||||||
|
|
||||||
|
# --- JetStream Cluster (B32-B35): split 231 features by line number ---
|
||||||
|
split_file_evenly(cur, "server/jetstream_cluster.go", [32, 33, 34, 35])
|
||||||
|
|
||||||
|
# --- Stream (B36-B37) ---
|
||||||
|
|
||||||
|
# B36: Stream features <= line 4600
|
||||||
|
assign_features_by_query(cur, 36,
|
||||||
|
"f.go_file = 'server/stream.go' AND f.go_line_number <= 4600")
|
||||||
|
|
||||||
|
# B37: Stream features > line 4600 (catch remaining)
|
||||||
|
assign_features_by_file(cur, 37, ["server/stream.go"])
|
||||||
|
|
||||||
|
# --- Consumer (B38-B39) ---
|
||||||
|
|
||||||
|
# B38: Consumer features <= line 3800
|
||||||
|
assign_features_by_query(cur, 38,
|
||||||
|
"f.go_file = 'server/consumer.go' AND f.go_line_number <= 3800")
|
||||||
|
|
||||||
|
# B39: Consumer features > line 3800 (catch remaining)
|
||||||
|
assign_features_by_file(cur, 39, ["server/consumer.go"])
|
||||||
|
|
||||||
|
# --- MQTT (B40-B41) ---
|
||||||
|
|
||||||
|
# B40: MQTT features <= line 3500
|
||||||
|
assign_features_by_query(cur, 40,
|
||||||
|
"f.go_file = 'server/mqtt.go' AND f.go_line_number <= 3500")
|
||||||
|
|
||||||
|
# B41: MQTT features > line 3500 (catch remaining)
|
||||||
|
assign_features_by_file(cur, 41, ["server/mqtt.go"])
|
||||||
|
|
||||||
|
# --- Sweep: assign any remaining deferred features ---
|
||||||
|
cur.execute("""
|
||||||
|
SELECT DISTINCT f.go_file FROM features f
|
||||||
|
WHERE f.status = 'deferred'
|
||||||
|
AND f.id NOT IN (SELECT feature_id FROM batch_features)
|
||||||
|
""")
|
||||||
|
remaining_files = [row[0] for row in cur.fetchall()]
|
||||||
|
if remaining_files:
|
||||||
|
for go_file in remaining_files:
|
||||||
|
assign_features_by_file(cur, 18, [go_file])
|
||||||
|
print(f" Sweep: {len(remaining_files)} extra files assigned to B18: "
|
||||||
|
f"{remaining_files}")
|
||||||
|
|
||||||
|
|
||||||
|
def get_orphan_batch(cur, test_go_file):
|
||||||
|
"""Find the primary batch for an orphan test based on its go_file."""
|
||||||
|
source_file = TEST_FILE_TO_SOURCE.get(test_go_file)
|
||||||
|
if source_file is None:
|
||||||
|
source_file = test_go_file.replace("_test.go", ".go")
|
||||||
|
|
||||||
|
cur.execute("""
|
||||||
|
SELECT MIN(bf.batch_id) FROM batch_features bf
|
||||||
|
JOIN features f ON bf.feature_id = f.id
|
||||||
|
WHERE f.go_file = ?
|
||||||
|
""", (source_file,))
|
||||||
|
row = cur.fetchone()
|
||||||
|
if row and row[0] is not None:
|
||||||
|
return row[0]
|
||||||
|
|
||||||
|
# Fallback: Server Core
|
||||||
|
return 18
|
||||||
|
|
||||||
|
|
||||||
|
def assign_tests(cur):
|
||||||
|
"""Assign all deferred tests to batches."""
|
||||||
|
cur.execute("SELECT id, go_file FROM unit_tests WHERE status = 'deferred'")
|
||||||
|
deferred_tests = cur.fetchall()
|
||||||
|
|
||||||
|
batch_0_count = 0
|
||||||
|
dep_count = 0
|
||||||
|
orphan_count = 0
|
||||||
|
|
||||||
|
for test_id, test_go_file in deferred_tests:
|
||||||
|
# Find all feature dependencies for this test
|
||||||
|
cur.execute("""
|
||||||
|
SELECT d.target_id, f.status
|
||||||
|
FROM dependencies d
|
||||||
|
JOIN features f ON d.target_id = f.id AND d.target_type = 'feature'
|
||||||
|
WHERE d.source_type = 'unit_test' AND d.source_id = ?
|
||||||
|
""", (test_id,))
|
||||||
|
deps = cur.fetchall()
|
||||||
|
|
||||||
|
if not deps:
|
||||||
|
# Orphan test: no dependency rows at all
|
||||||
|
batch_id = get_orphan_batch(cur, test_go_file)
|
||||||
|
orphan_count += 1
|
||||||
|
else:
|
||||||
|
# Collect deps whose features are still deferred/not-done
|
||||||
|
deferred_dep_ids = [
|
||||||
|
target_id for target_id, status in deps
|
||||||
|
if status not in ("verified", "complete", "n_a")
|
||||||
|
]
|
||||||
|
|
||||||
|
if not deferred_dep_ids:
|
||||||
|
# All deps satisfied -> Batch 0
|
||||||
|
batch_id = 0
|
||||||
|
batch_0_count += 1
|
||||||
|
else:
|
||||||
|
# Assign to the highest batch among deferred deps
|
||||||
|
placeholders = ",".join("?" for _ in deferred_dep_ids)
|
||||||
|
cur.execute(f"""
|
||||||
|
SELECT MAX(bf.batch_id) FROM batch_features bf
|
||||||
|
WHERE bf.feature_id IN ({placeholders})
|
||||||
|
""", deferred_dep_ids)
|
||||||
|
row = cur.fetchone()
|
||||||
|
if row and row[0] is not None:
|
||||||
|
batch_id = row[0]
|
||||||
|
dep_count += 1
|
||||||
|
else:
|
||||||
|
# Deferred deps exist but none in batch_features (edge case)
|
||||||
|
batch_id = get_orphan_batch(cur, test_go_file)
|
||||||
|
orphan_count += 1
|
||||||
|
|
||||||
|
cur.execute(
|
||||||
|
"INSERT INTO batch_tests (batch_id, test_id) VALUES (?, ?)",
|
||||||
|
(batch_id, test_id),
|
||||||
|
)
|
||||||
|
|
||||||
|
print(f" Batch 0 (implementable): {batch_0_count}")
|
||||||
|
print(f" By dependency: {dep_count}")
|
||||||
|
print(f" Orphans (by file): {orphan_count}")
|
||||||
|
|
||||||
|
|
||||||
|
def update_counts(cur):
|
||||||
|
"""Update feature_count and test_count on each batch."""
|
||||||
|
cur.execute("""
|
||||||
|
UPDATE implementation_batches SET
|
||||||
|
feature_count = (
|
||||||
|
SELECT COUNT(*) FROM batch_features
|
||||||
|
WHERE batch_id = implementation_batches.id
|
||||||
|
),
|
||||||
|
test_count = (
|
||||||
|
SELECT COUNT(*) FROM batch_tests
|
||||||
|
WHERE batch_id = implementation_batches.id
|
||||||
|
)
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
def print_summary(cur):
|
||||||
|
"""Print a summary report."""
|
||||||
|
print()
|
||||||
|
print("=" * 80)
|
||||||
|
print("BATCH PLANNER SUMMARY")
|
||||||
|
print("=" * 80)
|
||||||
|
|
||||||
|
cur.execute("""
|
||||||
|
SELECT id, name, feature_count, test_count, depends_on
|
||||||
|
FROM implementation_batches ORDER BY id
|
||||||
|
""")
|
||||||
|
rows = cur.fetchall()
|
||||||
|
|
||||||
|
total_features = 0
|
||||||
|
total_tests = 0
|
||||||
|
|
||||||
|
print(f"\n{'ID':>3} {'Name':<35} {'Feats':>5} {'Tests':>5} {'Depends':>15}")
|
||||||
|
print("-" * 70)
|
||||||
|
|
||||||
|
for bid, name, fc, tc, deps in rows:
|
||||||
|
total_features += fc
|
||||||
|
total_tests += tc
|
||||||
|
deps_str = deps if deps else "-"
|
||||||
|
print(f"{bid:>3} {name:<35} {fc:>5} {tc:>5} {deps_str:>15}")
|
||||||
|
|
||||||
|
print("-" * 70)
|
||||||
|
print(f"{'':>3} {'TOTAL':<35} {total_features:>5} {total_tests:>5}")
|
||||||
|
|
||||||
|
# Verification
|
||||||
|
cur.execute("""
|
||||||
|
SELECT COUNT(*) FROM features
|
||||||
|
WHERE status = 'deferred'
|
||||||
|
AND id NOT IN (SELECT feature_id FROM batch_features)
|
||||||
|
""")
|
||||||
|
unassigned_features = cur.fetchone()[0]
|
||||||
|
|
||||||
|
cur.execute("""
|
||||||
|
SELECT COUNT(*) FROM unit_tests
|
||||||
|
WHERE status = 'deferred'
|
||||||
|
AND id NOT IN (SELECT test_id FROM batch_tests)
|
||||||
|
""")
|
||||||
|
unassigned_tests = cur.fetchone()[0]
|
||||||
|
|
||||||
|
print(f"\nUnassigned deferred features: {unassigned_features}")
|
||||||
|
print(f"Unassigned deferred tests: {unassigned_tests}")
|
||||||
|
|
||||||
|
if unassigned_features == 0 and unassigned_tests == 0:
|
||||||
|
print("\nAll deferred items assigned to batches.")
|
||||||
|
else:
|
||||||
|
print("\nWARNING: Some items remain unassigned!")
|
||||||
|
if unassigned_features > 0:
|
||||||
|
cur.execute("""
|
||||||
|
SELECT go_file, COUNT(*) FROM features
|
||||||
|
WHERE status = 'deferred'
|
||||||
|
AND id NOT IN (SELECT feature_id FROM batch_features)
|
||||||
|
GROUP BY go_file
|
||||||
|
""")
|
||||||
|
for go_file, cnt in cur.fetchall():
|
||||||
|
print(f" Unassigned features in {go_file}: {cnt}")
|
||||||
|
|
||||||
|
# Spot-check: raft.shutdown
|
||||||
|
cur.execute("""
|
||||||
|
SELECT bf.batch_id, f.go_method FROM batch_features bf
|
||||||
|
JOIN features f ON bf.feature_id = f.id
|
||||||
|
WHERE f.go_method = 'shutdown' AND f.go_class = 'raft'
|
||||||
|
""")
|
||||||
|
raft_shutdown = cur.fetchall()
|
||||||
|
if raft_shutdown:
|
||||||
|
print(f"\nSpot-check: raft.shutdown -> batch {raft_shutdown[0][0]}")
|
||||||
|
else:
|
||||||
|
print("\nSpot-check: raft.shutdown not found in deferred features")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if not DB_SOURCE.exists():
|
||||||
|
print(f"Error: {DB_SOURCE} not found", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Step 1: Copy database
|
||||||
|
print(f"Copying {DB_SOURCE} -> {DB_TARGET}")
|
||||||
|
shutil.copy2(DB_SOURCE, DB_TARGET)
|
||||||
|
|
||||||
|
conn = sqlite3.connect(str(DB_TARGET))
|
||||||
|
cur = conn.cursor()
|
||||||
|
cur.execute("PRAGMA foreign_keys = ON")
|
||||||
|
|
||||||
|
# Step 2: Create new tables
|
||||||
|
print("Creating batch tables...")
|
||||||
|
cur.executescript(NEW_TABLES_SQL)
|
||||||
|
|
||||||
|
# Step 3: Insert batch metadata
|
||||||
|
print("Inserting batch metadata...")
|
||||||
|
for bid, name, desc, priority, deps, go_files in BATCH_META:
|
||||||
|
cur.execute(
|
||||||
|
"INSERT INTO implementation_batches "
|
||||||
|
"(id, name, description, priority, depends_on, go_files) "
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
|
(bid, name, desc, priority, deps, go_files),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Step 4: Assign features
|
||||||
|
print("Assigning features to batches...")
|
||||||
|
assign_all_features(cur)
|
||||||
|
|
||||||
|
# Step 5: Assign tests
|
||||||
|
print("Assigning tests to batches...")
|
||||||
|
assign_tests(cur)
|
||||||
|
|
||||||
|
# Step 6: Update counts
|
||||||
|
print("Updating batch counts...")
|
||||||
|
update_counts(cur)
|
||||||
|
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
# Step 7: Print summary
|
||||||
|
print_summary(cur)
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
print(f"\nDone. Output: {DB_TARGET}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user