Reformat / cleanup
All checks were successful
NuGet Publish / build-and-pack (push) Successful in 46s
NuGet Publish / publish-to-gitea (push) Successful in 56s

This commit is contained in:
Joseph Doherty
2026-02-21 08:10:36 -05:00
parent 4c6aaa5a3f
commit a70d8befae
176 changed files with 50555 additions and 49587 deletions

View File

@@ -1,5 +1,4 @@
using System.Reflection;
using ZB.MOM.WW.CBDD.Bson;
using ZB.MOM.WW.CBDD.Core.Storage;
using ZB.MOM.WW.CBDD.Core.Transactions;
using ZB.MOM.WW.CBDD.Shared;
@@ -9,12 +8,12 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class CheckpointModeTests
{
/// <summary>
/// Verifies default checkpoint mode truncates WAL.
/// Verifies default checkpoint mode truncates WAL.
/// </summary>
[Fact]
public void Checkpoint_Default_ShouldUseTruncate()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
using var db = new TestDbContext(dbPath);
@@ -36,12 +35,12 @@ public class CheckpointModeTests
}
/// <summary>
/// Verifies passive mode skips when checkpoint lock is contended.
/// Verifies passive mode skips when checkpoint lock is contended.
/// </summary>
[Fact]
public void Checkpoint_Passive_ShouldSkip_WhenLockIsContended()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
using var storage = new StorageEngine(dbPath, PageFileConfig.Default);
@@ -67,13 +66,13 @@ public class CheckpointModeTests
}
/// <summary>
/// Verifies full checkpoint applies data and appends a checkpoint marker without truncating WAL.
/// Verifies full checkpoint applies data and appends a checkpoint marker without truncating WAL.
/// </summary>
[Fact]
public void Checkpoint_Full_ShouldAppendMarker_AndPreserveWal()
{
var dbPath = NewDbPath();
var walPath = Path.ChangeExtension(dbPath, ".wal");
string dbPath = NewDbPath();
string walPath = Path.ChangeExtension(dbPath, ".wal");
try
{
@@ -82,7 +81,7 @@ public class CheckpointModeTests
db.Users.Insert(new User { Name = "checkpoint-full", Age = 50 });
db.SaveChanges();
var walBefore = db.Storage.GetWalSize();
long walBefore = db.Storage.GetWalSize();
walBefore.ShouldBeGreaterThan(0);
var result = db.Checkpoint(CheckpointMode.Full);
@@ -103,12 +102,12 @@ public class CheckpointModeTests
}
/// <summary>
/// Verifies restart checkpoint clears WAL and allows subsequent writes.
/// Verifies restart checkpoint clears WAL and allows subsequent writes.
/// </summary>
[Fact]
public void Checkpoint_Restart_ShouldResetWal_AndAcceptNewWrites()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
using var db = new TestDbContext(dbPath);
@@ -134,12 +133,12 @@ public class CheckpointModeTests
}
/// <summary>
/// Verifies recovery remains deterministic after a full checkpoint boundary.
/// Verifies recovery remains deterministic after a full checkpoint boundary.
/// </summary>
[Fact]
public void Recover_AfterFullCheckpoint_ShouldApplyLatestCommitDeterministically()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
uint pageId;
@@ -182,12 +181,12 @@ public class CheckpointModeTests
}
/// <summary>
/// Verifies asynchronous mode-based checkpoints return expected result metadata.
/// Verifies asynchronous mode-based checkpoints return expected result metadata.
/// </summary>
[Fact]
public async Task CheckpointAsync_Full_ShouldReturnResult()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
using var db = new TestDbContext(dbPath);
@@ -213,16 +212,18 @@ public class CheckpointModeTests
}
private static string NewDbPath()
=> Path.Combine(Path.GetTempPath(), $"checkpoint_mode_{Guid.NewGuid():N}.db");
{
return Path.Combine(Path.GetTempPath(), $"checkpoint_mode_{Guid.NewGuid():N}.db");
}
private static void CleanupFiles(string dbPath)
{
if (File.Exists(dbPath)) File.Delete(dbPath);
var walPath = Path.ChangeExtension(dbPath, ".wal");
string walPath = Path.ChangeExtension(dbPath, ".wal");
if (File.Exists(walPath)) File.Delete(walPath);
var markerPath = $"{dbPath}.compact.state";
if (File.Exists(markerPath)) File.Delete(markerPath);
}
}
}