feat(batch15): complete group 6 msgblock/consumerfilestore

This commit is contained in:
Joseph Doherty
2026-02-28 18:34:28 -05:00
parent 854f410aad
commit cfddfc9084
10 changed files with 720 additions and 45 deletions

View File

@@ -3246,6 +3246,81 @@ public sealed partial class JetStreamFileStoreTests
}
}
[Fact]
public void FileStoreConsumerStopFlushesDirtyState_ShouldSucceed()
{
var root = NewRoot();
Directory.CreateDirectory(root);
try
{
var fs = JetStreamFileStore.NewFileStore(new FileStoreConfig { StoreDir = root }, DefaultStreamConfig());
var cfg = new ConsumerConfig { AckPolicy = AckPolicy.AckExplicit };
var consumer = fs.ConsumerStore("o-stop", DateTime.UtcNow, cfg);
var ts = DateTimeOffset.UtcNow.ToUnixTimeSeconds() * 1_000_000_000L;
consumer.UpdateDelivered(1, 1, 1, ts);
consumer.UpdateDelivered(2, 1, 2, ts);
consumer.UpdateDelivered(3, 2, 1, ts);
consumer.Stop();
consumer = fs.ConsumerStore("o-stop", DateTime.UtcNow, cfg);
var (state, err) = consumer.State();
err.ShouldBeNull();
state.ShouldNotBeNull();
state!.Pending.ShouldNotBeNull();
state.Pending!.Count.ShouldBe(2);
state.Redelivered.ShouldNotBeNull();
state.Redelivered![1].ShouldBe(1UL);
consumer.Stop();
fs.Stop();
}
finally
{
Directory.Delete(root, recursive: true);
}
}
[Fact]
public void FileStoreConsumerConvertCipherPreservesState_ShouldSucceed()
{
var root = NewRoot();
Directory.CreateDirectory(root);
try
{
var fs = JetStreamFileStore.NewFileStore(new FileStoreConfig { StoreDir = root }, DefaultStreamConfig());
var cfg = new ConsumerConfig { AckPolicy = AckPolicy.AckExplicit };
var consumer = fs.ConsumerStore("o-cipher", DateTime.UtcNow, cfg);
var cfs = consumer.ShouldBeOfType<ConsumerFileStore>();
var ts = DateTimeOffset.UtcNow.ToUnixTimeSeconds() * 1_000_000_000L;
consumer.UpdateDelivered(1, 1, 1, ts);
consumer.UpdateDelivered(2, 1, 2, ts);
var convertErr = cfs.ConvertCipher();
convertErr.ShouldBeNull();
consumer.Stop();
consumer = fs.ConsumerStore("o-cipher", DateTime.UtcNow, cfg);
var (state, err) = consumer.State();
err.ShouldBeNull();
state.ShouldNotBeNull();
state!.Delivered.Consumer.ShouldBe(2UL);
state.Redelivered.ShouldNotBeNull();
state.Redelivered![1].ShouldBe(1UL);
consumer.Stop();
fs.Stop();
}
finally
{
Directory.Delete(root, recursive: true);
}
}
[Fact] // T:402
public void FileStoreBadConsumerState_ShouldSucceed()
{