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

@@ -7,21 +7,18 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class CompactionWalCoordinationTests
{
/// <summary>
/// Verifies offline compaction checkpoints and leaves the WAL empty.
/// Verifies offline compaction checkpoints and leaves the WAL empty.
/// </summary>
[Fact]
public void OfflineCompact_ShouldCheckpointAndLeaveWalEmpty()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
var markerPath = $"{dbPath}.compact.state";
try
{
using var db = new TestDbContext(dbPath);
for (var i = 0; i < 80; i++)
{
db.Users.Insert(new User { Name = $"wal-compact-{i:D3}", Age = i });
}
for (var i = 0; i < 80; i++) db.Users.Insert(new User { Name = $"wal-compact-{i:D3}", Age = i });
db.SaveChanges();
db.Storage.GetWalSize().ShouldBeGreaterThan(0);
@@ -46,13 +43,13 @@ public class CompactionWalCoordinationTests
}
/// <summary>
/// Verifies compaction after WAL recovery preserves durable data.
/// Verifies compaction after WAL recovery preserves durable data.
/// </summary>
[Fact]
public void Compact_AfterWalRecovery_ShouldKeepDataDurable()
{
var dbPath = NewDbPath();
var walPath = Path.ChangeExtension(dbPath, ".wal");
string dbPath = NewDbPath();
string walPath = Path.ChangeExtension(dbPath, ".wal");
var expected = new List<(ObjectId Id, string Name)>();
try
@@ -76,10 +73,7 @@ public class CompactionWalCoordinationTests
{
recovered.Users.Count().ShouldBe(expected.Count);
foreach (var item in expected)
{
recovered.Users.FindById(item.Id)!.Name.ShouldBe(item.Name);
}
foreach (var item in expected) recovered.Users.FindById(item.Id)!.Name.ShouldBe(item.Name);
recovered.SaveChanges();
recovered.Compact();
@@ -89,10 +83,7 @@ public class CompactionWalCoordinationTests
using (var verify = new TestDbContext(dbPath))
{
verify.Users.Count().ShouldBe(expected.Count);
foreach (var item in expected)
{
verify.Users.FindById(item.Id)!.Name.ShouldBe(item.Name);
}
foreach (var item in expected) verify.Users.FindById(item.Id)!.Name.ShouldBe(item.Name);
}
}
finally
@@ -102,14 +93,16 @@ public class CompactionWalCoordinationTests
}
private static string NewDbPath()
=> Path.Combine(Path.GetTempPath(), $"compaction_wal_{Guid.NewGuid():N}.db");
{
return Path.Combine(Path.GetTempPath(), $"compaction_wal_{Guid.NewGuid():N}.db");
}
private static void CleanupFiles(string dbPath)
{
var walPath = Path.ChangeExtension(dbPath, ".wal");
string walPath = Path.ChangeExtension(dbPath, ".wal");
var markerPath = $"{dbPath}.compact.state";
if (File.Exists(dbPath)) File.Delete(dbPath);
if (File.Exists(walPath)) File.Delete(walPath);
if (File.Exists(markerPath)) File.Delete(markerPath);
}
}
}