feat: complete jetstream deep operational parity closure
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using NATS.Server.JetStream.Storage;
|
||||
using System.Text;
|
||||
|
||||
namespace NATS.Server.Tests;
|
||||
|
||||
public class JetStreamFileStoreDurabilityParityTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task File_store_recovers_block_index_map_after_restart_without_full_log_scan()
|
||||
{
|
||||
var dir = Path.Combine(Path.GetTempPath(), $"nats-js-fs-durable-{Guid.NewGuid():N}");
|
||||
var options = new FileStoreOptions
|
||||
{
|
||||
Directory = dir,
|
||||
BlockSizeBytes = 256,
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
await using (var store = new FileStore(options))
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
await store.AppendAsync("orders.created", Encoding.UTF8.GetBytes($"payload-{i}"), default);
|
||||
}
|
||||
|
||||
File.Exists(Path.Combine(dir, options.IndexManifestFileName)).ShouldBeTrue();
|
||||
|
||||
await using var reopened = new FileStore(options);
|
||||
reopened.UsedIndexManifestOnStartup.ShouldBeTrue();
|
||||
var state = await reopened.GetStateAsync(default);
|
||||
state.Messages.ShouldBe((ulong)1000);
|
||||
reopened.BlockCount.ShouldBeGreaterThan(1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(dir))
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user