test(localdb): review fixes — index assertion, AUTOINCREMENT rationale, ReadMeta guard, concurrent HLC test
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Concurrent;
|
||||
using ZB.MOM.WW.LocalDb.Hlc;
|
||||
|
||||
namespace ZB.MOM.WW.LocalDb.Tests;
|
||||
@@ -87,4 +88,20 @@ public sealed class HybridLogicalClockTests
|
||||
Assert.Equal(ms + 1, HybridLogicalClock.PhysicalMs(next));
|
||||
Assert.Equal(0, HybridLogicalClock.Counter(next));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Next_ConcurrentCallers_NoDuplicates_StrictlyIncreasing()
|
||||
{
|
||||
var clock = new HybridLogicalClock();
|
||||
var results = new ConcurrentBag<long>();
|
||||
|
||||
Parallel.For(0, 8, _ =>
|
||||
{
|
||||
for (var i = 0; i < 1000; i++)
|
||||
results.Add(clock.Next());
|
||||
});
|
||||
|
||||
Assert.Equal(8000, results.Count);
|
||||
Assert.Equal(8000, results.Distinct().Count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ public sealed class LocalDbSchemaTests : IDisposable
|
||||
"__localdb_row_version", "__localdb_applying", "__localdb_dead_letter"
|
||||
})
|
||||
Assert.Contains(expected, tables);
|
||||
|
||||
Assert.Equal(1, ScalarLong(conn,
|
||||
"SELECT count(*) FROM sqlite_master WHERE type='index' AND name='__localdb_oplog_hlc'"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user