Merge branch 'review/wp6' into review/integration
# Conflicts: # docs/requirements/Component-StoreAndForward.md # src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Repositories/DeploymentManagerRepository.cs # src/ZB.MOM.WW.ScadaBridge.StoreAndForward/StoreAndForwardStorage.cs # src/ZB.MOM.WW.ScadaBridge.Transport/Import/BundleImporter.cs # tests/ZB.MOM.WW.ScadaBridge.StoreAndForward.Tests/StoreAndForwardStorageTests.cs
This commit is contained in:
@@ -912,6 +912,36 @@ public class StoreAndForwardStorageTests : IAsyncLifetime, IDisposable
|
||||
Assert.Equal(new[] { "a", "b" }, ids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SF-3 (WP6 6.3): the sweep ranks lanes over the covering lane index (no payload read, no
|
||||
/// sort for the window) and joins back only the chosen page by primary key.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task GetMessagesForRetry_RanksOverTheCoveringLaneIndex()
|
||||
{
|
||||
await using var connection = _localDb.Db.CreateConnection();
|
||||
await using var cmd = connection.CreateCommand();
|
||||
cmd.CommandText = @"EXPLAIN QUERY PLAN
|
||||
SELECT id, created_at, rowid,
|
||||
ROW_NUMBER() OVER lane AS lane_rank,
|
||||
SUM(CASE WHEN (last_attempt_at_ms IS NULL OR retry_interval_ms = 0
|
||||
OR (1 - last_attempt_at_ms) >= retry_interval_ms) THEN 0 ELSE 1 END) OVER lane AS blocked_by
|
||||
FROM sf_messages
|
||||
WHERE status = 0
|
||||
WINDOW lane AS (PARTITION BY category, target ORDER BY created_at ASC, rowid ASC
|
||||
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)";
|
||||
var plan = new List<string>();
|
||||
await using (var reader = await cmd.ExecuteReaderAsync())
|
||||
while (await reader.ReadAsync())
|
||||
plan.Add(reader.GetString(3));
|
||||
|
||||
Assert.Contains(plan, p => p.Contains("COVERING INDEX idx_sf_messages_lane"));
|
||||
// The SF-1 rowid tie-break is the one key past the index order: SQLite may sort only
|
||||
// rows tied on (category, target, created_at) — "FOR LAST TERM" — never the backlog.
|
||||
Assert.DoesNotContain(plan, p => p.Contains("TEMP B-TREE") && !p.Contains("LAST TERM"));
|
||||
}
|
||||
|
||||
// ReplaceAll_SwapsTheEntireBuffer_Atomically was DELETED with ReplaceAllAsync in
|
||||
// LocalDb Phase 2, and deliberately not replaced. It asserted a destructive
|
||||
// delete-all-then-insert-all, which was the standby's anti-entropy apply: a resync
|
||||
|
||||
Reference in New Issue
Block a user