feat(batch14): complete group3 purge compact state and wave3 tests

This commit is contained in:
Joseph Doherty
2026-02-28 15:43:05 -05:00
parent 9a35e2dfc5
commit 045faf7423
5 changed files with 894 additions and 9 deletions

View File

@@ -92,6 +92,36 @@ public sealed partial class ConcurrencyTests2
});
}
[Fact] // T:2480
public void NoRaceFileStoreLargeMsgsAndFirstMatching_ShouldSucceed()
{
var cfg = DefaultStreamConfig();
cfg.Subjects = [">"];
WithStore((fs, _) =>
{
for (var i = 0; i < 4_000; i++)
fs.StoreMsg($"foo.bar.{i}", null, null, 0);
for (var i = 0; i < 4_000; i++)
fs.StoreMsg($"foo.baz.{i}", null, null, 0);
var blocks = InvokePrivate<int>(fs, "NumMsgBlocks");
blocks.ShouldBeGreaterThanOrEqualTo(1);
var start = fs.State().FirstSeq;
for (var seq = start; seq < start + 7_600; seq++)
fs.RemoveMsg(seq).Removed.ShouldBeTrue();
var sw = System.Diagnostics.Stopwatch.StartNew();
var (sm, _) = fs.LoadNextMsg("*.baz.*", true, start, null);
sw.Stop();
sm.ShouldNotBeNull();
sm!.Subject.ShouldContain(".baz.");
sw.ElapsedMilliseconds.ShouldBeLessThan(50);
}, cfg);
}
private static void WithStore(Action<JetStreamFileStore, string> action, StreamConfig? cfg = null)
{
var root = NewRoot();
@@ -134,5 +164,15 @@ public sealed partial class ConcurrencyTests2
method!.Invoke(target, args);
}
private static T InvokePrivate<T>(object target, string methodName, params object[] args)
{
var method = target.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
method.ShouldNotBeNull();
var result = method!.Invoke(target, args);
if (result == null)
return default!;
return (T)result;
}
private static string NewRoot() => Path.Combine(Path.GetTempPath(), $"impl-fs-c2-{Guid.NewGuid():N}");
}