Reformat / cleanup
This commit is contained in:
@@ -7,12 +7,12 @@ namespace ZB.MOM.WW.CBDD.Tests;
|
||||
public class CompactionOnlineConcurrencyTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Verifies online compaction completes without deadlock under concurrent workload.
|
||||
/// Verifies online compaction completes without deadlock under concurrent workload.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task OnlineCompaction_WithConcurrentishWorkload_ShouldCompleteWithoutDeadlock()
|
||||
{
|
||||
var dbPath = NewDbPath();
|
||||
string dbPath = NewDbPath();
|
||||
var activeIds = new List<ObjectId>();
|
||||
var sync = new object();
|
||||
var completedOps = 0;
|
||||
@@ -48,10 +48,7 @@ public class CompactionOnlineConcurrencyTests
|
||||
ObjectId? candidate = null;
|
||||
lock (sync)
|
||||
{
|
||||
if (activeIds.Count > 0)
|
||||
{
|
||||
candidate = activeIds[i % activeIds.Count];
|
||||
}
|
||||
if (activeIds.Count > 0) candidate = activeIds[i % activeIds.Count];
|
||||
}
|
||||
|
||||
if (candidate.HasValue)
|
||||
@@ -76,10 +73,7 @@ public class CompactionOnlineConcurrencyTests
|
||||
}
|
||||
}
|
||||
|
||||
if (candidate.HasValue)
|
||||
{
|
||||
db.Users.Delete(candidate.Value);
|
||||
}
|
||||
if (candidate.HasValue) db.Users.Delete(candidate.Value);
|
||||
}
|
||||
|
||||
db.SaveChanges();
|
||||
@@ -115,10 +109,7 @@ public class CompactionOnlineConcurrencyTests
|
||||
}
|
||||
|
||||
var actualIds = allUsers.Select(x => x.Id).ToHashSet();
|
||||
foreach (var id in snapshotIds)
|
||||
{
|
||||
actualIds.ShouldContain(id);
|
||||
}
|
||||
foreach (var id in snapshotIds) actualIds.ShouldContain(id);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -127,14 +118,16 @@ public class CompactionOnlineConcurrencyTests
|
||||
}
|
||||
|
||||
private static string NewDbPath()
|
||||
=> Path.Combine(Path.GetTempPath(), $"compaction_online_{Guid.NewGuid():N}.db");
|
||||
{
|
||||
return Path.Combine(Path.GetTempPath(), $"compaction_online_{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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user