test(batch27): port wave-b filestore-consumer-concurrency tests
This commit is contained in:
@@ -613,6 +613,117 @@ public sealed partial class JetStreamFileStoreTests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact] // T:356
|
||||
public void FileStoreWriteExpireWrite_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
fs.StoreMsg("expire", null, "first"u8.ToArray(), 0).Seq.ShouldBe(1UL);
|
||||
Thread.Sleep(30);
|
||||
fs.StoreMsg("expire", null, "second"u8.ToArray(), 0).Seq.ShouldBeGreaterThan(0UL);
|
||||
|
||||
var state = fs.State();
|
||||
state.Msgs.ShouldBeLessThanOrEqualTo(1UL);
|
||||
state.LastSeq.ShouldBeGreaterThanOrEqualTo(2UL);
|
||||
}, cfg: DefaultStreamConfig(maxAge: TimeSpan.FromMilliseconds(10)));
|
||||
}
|
||||
|
||||
[Fact] // T:379
|
||||
public void FileStoreReadCache_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
fs.StoreMsg("cache", null, "payload"u8.ToArray(), 0).Seq.ShouldBe(1UL);
|
||||
|
||||
var first = fs.LoadMsg(1, null);
|
||||
var second = fs.LoadMsg(1, null);
|
||||
first.ShouldNotBeNull();
|
||||
second.ShouldNotBeNull();
|
||||
second!.Msg.ShouldBe(first!.Msg);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact] // T:389
|
||||
public void FileStorePerf_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
for (var i = 0; i < 250; i++)
|
||||
{
|
||||
fs.StoreMsg("perf", null, "x"u8.ToArray(), 0).Seq.ShouldBeGreaterThan(0UL);
|
||||
}
|
||||
|
||||
var state = fs.State();
|
||||
state.Msgs.ShouldBe(250UL);
|
||||
state.LastSeq.ShouldBe(250UL);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact] // T:390
|
||||
public void FileStoreReadBackMsgPerf_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
for (var i = 0; i < 100; i++)
|
||||
fs.StoreMsg("readback", null, "m"u8.ToArray(), 0);
|
||||
|
||||
for (ulong seq = 100; seq >= 90; seq--)
|
||||
{
|
||||
var msg = fs.LoadMsg(seq, null);
|
||||
msg.ShouldNotBeNull();
|
||||
msg!.Subject.ShouldBe("readback");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[Fact] // T:391
|
||||
public void FileStoreStoreLimitRemovePerf_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
for (var i = 0; i < 120; i++)
|
||||
fs.StoreMsg("limit", null, "x"u8.ToArray(), 0);
|
||||
|
||||
var state = fs.State();
|
||||
state.Msgs.ShouldBeLessThanOrEqualTo(50UL);
|
||||
state.FirstSeq.ShouldBeGreaterThan(1UL);
|
||||
}, cfg: DefaultStreamConfig(maxMsgs: 50));
|
||||
}
|
||||
|
||||
[Fact] // T:392
|
||||
public void FileStorePubPerfWithSmallBlkSize_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
for (var i = 0; i < 40; i++)
|
||||
{
|
||||
fs.StoreMsg("blk", null, "payload"u8.ToArray(), 0).Seq.ShouldBeGreaterThan(0UL);
|
||||
}
|
||||
|
||||
fs.State().Msgs.ShouldBe(40UL);
|
||||
}, fcfg: new FileStoreConfig
|
||||
{
|
||||
BlockSize = FileStoreDefaults.DefaultTinyBlockSize,
|
||||
Cipher = StoreCipher.Aes,
|
||||
});
|
||||
}
|
||||
|
||||
[Fact] // T:463
|
||||
public void FileStoreCompactingBlocksOnSync_ShouldSucceed()
|
||||
{
|
||||
WithStore((fs, _) =>
|
||||
{
|
||||
for (var i = 0; i < 60; i++)
|
||||
fs.StoreMsg("compact", null, "x"u8.ToArray(), 0);
|
||||
|
||||
for (ulong seq = 1; seq <= 30; seq++)
|
||||
fs.RemoveMsg(seq).Removed.ShouldBeTrue();
|
||||
|
||||
fs.Compact(35).Error.ShouldBeNull();
|
||||
fs.State().Msgs.ShouldBeInRange(1UL, 30UL);
|
||||
});
|
||||
}
|
||||
|
||||
private static void WithStore(
|
||||
Action<JetStreamFileStore, string> action,
|
||||
StreamConfig? cfg = null,
|
||||
|
||||
Reference in New Issue
Block a user