feat(batch14): complete group1 write path and wave1 tests
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics;
|
||||
using Shouldly;
|
||||
using ZB.MOM.NatsNet.Server;
|
||||
|
||||
@@ -134,6 +135,47 @@ public sealed partial class ConcurrencyTests1
|
||||
}
|
||||
}
|
||||
|
||||
[Fact] // T:2441
|
||||
public void NoRaceJetStreamFileStoreLargeKVAccessTiming_ShouldSucceed()
|
||||
{
|
||||
var value = Enumerable.Repeat((byte)'Z', 256).ToArray();
|
||||
const int keyCount = 5_000;
|
||||
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
for (var i = 1; i <= keyCount; i++)
|
||||
{
|
||||
fs.StoreMsg($"KV.STREAM_NAME.{i}", null, value, 0).Seq.ShouldBeGreaterThan(0UL);
|
||||
}
|
||||
|
||||
var sw = Stopwatch.StartNew();
|
||||
var last = fs.LoadLastMsg($"KV.STREAM_NAME.{keyCount}", null);
|
||||
sw.Stop();
|
||||
var lastLookup = sw.Elapsed;
|
||||
|
||||
last.ShouldNotBeNull();
|
||||
last!.Msg.ShouldBe(value);
|
||||
|
||||
sw.Restart();
|
||||
var first = fs.LoadLastMsg("KV.STREAM_NAME.1", null);
|
||||
sw.Stop();
|
||||
var firstLookup = sw.Elapsed;
|
||||
|
||||
first.ShouldNotBeNull();
|
||||
first!.Msg.ShouldBe(value);
|
||||
|
||||
// Keep generous bounds to avoid machine-specific flakiness while still
|
||||
// asserting access stays fast under a large key set.
|
||||
lastLookup.ShouldBeLessThan(TimeSpan.FromMilliseconds(250));
|
||||
firstLookup.ShouldBeLessThan(TimeSpan.FromMilliseconds(350));
|
||||
|
||||
var firstState = fs.FilteredState(1, "KV.STREAM_NAME.1");
|
||||
var lastState = fs.FilteredState(1, $"KV.STREAM_NAME.{keyCount}");
|
||||
firstState.First.ShouldBeGreaterThan(0UL);
|
||||
lastState.First.ShouldBeGreaterThan(0UL);
|
||||
}, DefaultStreamConfig());
|
||||
}
|
||||
|
||||
private static void WithStore(Action<JetStreamFileStore, string> action, StreamConfig? cfg = null)
|
||||
{
|
||||
var root = NewRoot();
|
||||
|
||||
Reference in New Issue
Block a user