Replace BLite with Surreal embedded persistence
All checks were successful
NuGet Package Publish / nuget (push) Successful in 1m21s

This commit is contained in:
Joseph Doherty
2026-02-22 05:21:53 -05:00
parent 7ebc2cb567
commit 9c2a77dc3c
56 changed files with 6613 additions and 3177 deletions

View File

@@ -1,47 +1,54 @@
using System.Text.Json;
using Microsoft.Extensions.Logging.Abstractions;
using ZB.MOM.WW.CBDDC.Core;
using ZB.MOM.WW.CBDDC.Core.Network;
using ZB.MOM.WW.CBDDC.Core.Sync;
using ZB.MOM.WW.CBDDC.Persistence;
using ZB.MOM.WW.CBDDC.Persistence.BLite;
using ZB.MOM.WW.CBDDC.Core.Network;
using ZB.MOM.WW.CBDDC.Core.Sync;
using ZB.MOM.WW.CBDDC.Persistence;
using ZB.MOM.WW.CBDDC.Persistence.Surreal;
namespace ZB.MOM.WW.CBDDC.Sample.Console.Tests;
/// <summary>
/// Tests for BLite persistence stores: Export, Import, Merge, Drop operations.
/// </summary>
public class BLiteStoreExportImportTests : IDisposable
{
/// <summary>
/// Tests for Surreal persistence stores: Export, Import, Merge, Drop operations.
/// </summary>
public class SurrealStoreExportImportTests : IDisposable
{
private readonly IPeerNodeConfigurationProvider _configProvider;
private readonly SampleDbContext _context;
private readonly SampleDocumentStore _documentStore;
private readonly BLiteOplogStore<SampleDbContext> _oplogStore;
private readonly BLitePeerConfigurationStore<SampleDbContext> _peerConfigStore;
private readonly BLiteSnapshotMetadataStore<SampleDbContext> _snapshotMetadataStore;
private readonly SurrealOplogStore _oplogStore;
private readonly SurrealPeerConfigurationStore _peerConfigStore;
private readonly SurrealSnapshotMetadataStore _snapshotMetadataStore;
private readonly string _testDbPath;
/// <summary>
/// Initializes a new instance of the <see cref="BLiteStoreExportImportTests" /> class.
/// </summary>
public BLiteStoreExportImportTests()
{
_testDbPath = Path.Combine(Path.GetTempPath(), $"test-export-import-{Guid.NewGuid()}.blite");
_context = new SampleDbContext(_testDbPath);
_configProvider = CreateConfigProvider("test-node");
var vectorClock = new VectorClockService();
_documentStore = new SampleDocumentStore(_context, _configProvider, vectorClock,
NullLogger<SampleDocumentStore>.Instance);
_snapshotMetadataStore = new BLiteSnapshotMetadataStore<SampleDbContext>(
_context, NullLogger<BLiteSnapshotMetadataStore<SampleDbContext>>.Instance);
_oplogStore = new BLiteOplogStore<SampleDbContext>(
_context, _documentStore, new LastWriteWinsConflictResolver(),
vectorClock,
_snapshotMetadataStore,
NullLogger<BLiteOplogStore<SampleDbContext>>.Instance);
_peerConfigStore = new BLitePeerConfigurationStore<SampleDbContext>(
_context, NullLogger<BLitePeerConfigurationStore<SampleDbContext>>.Instance);
/// <summary>
/// Initializes a new instance of the <see cref="SurrealStoreExportImportTests" /> class.
/// </summary>
public SurrealStoreExportImportTests()
{
_testDbPath = Path.Combine(Path.GetTempPath(), $"test-export-import-{Guid.NewGuid()}.rocksdb");
_context = new SampleDbContext(_testDbPath);
_configProvider = CreateConfigProvider("test-node");
var vectorClock = new VectorClockService();
_documentStore = new SampleDocumentStore(_context, _configProvider, vectorClock,
logger: NullLogger<SampleDocumentStore>.Instance);
_snapshotMetadataStore = new SurrealSnapshotMetadataStore(
_context.SurrealEmbeddedClient,
_context.SchemaInitializer,
NullLogger<SurrealSnapshotMetadataStore>.Instance);
_oplogStore = new SurrealOplogStore(
_context.SurrealEmbeddedClient,
_context.SchemaInitializer,
_documentStore,
new LastWriteWinsConflictResolver(),
vectorClock,
_snapshotMetadataStore,
NullLogger<SurrealOplogStore>.Instance);
_peerConfigStore = new SurrealPeerConfigurationStore(
_context.SurrealEmbeddedClient,
_context.SchemaInitializer,
NullLogger<SurrealPeerConfigurationStore>.Instance);
}
/// <summary>
@@ -52,13 +59,13 @@ public class BLiteStoreExportImportTests : IDisposable
_documentStore?.Dispose();
_context?.Dispose();
if (File.Exists(_testDbPath))
try
{
File.Delete(_testDbPath);
}
catch
{
if (Directory.Exists(_testDbPath))
try
{
Directory.Delete(_testDbPath, true);
}
catch
{
}
}
@@ -506,4 +513,4 @@ public class BLiteStoreExportImportTests : IDisposable
}
#endregion
}
}