You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests: Refactors 409 dedup tests to use (PK, id) uniqueness simulation
Replaces order-dependent callCount-based mock with ConcurrentDictionary
tracking (PartitionKey, id) composite keys. The mock now returns 409
only when the same (PK, id) pair is seen again, faithfully simulating
Cosmos DB's per-logical-partition id uniqueness constraint regardless
of call order.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ChangeFeed/DocumentServiceLeaseManagerCosmosTests.cs
+40-15Lines changed: 40 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
namespaceMicrosoft.Azure.Cosmos.ChangeFeed.Tests
6
6
{
7
7
usingSystem;
8
+
usingSystem.Collections.Concurrent;
8
9
usingSystem.IO;
9
10
usingSystem.Net;
10
11
usingSystem.Threading;
@@ -329,9 +330,10 @@ public async Task CreatesPartitionKeyBasedLeaseWithLegacyGuidPartitionKeyWhenOpt
329
330
}
330
331
331
332
/// <summary>
332
-
/// Verifies the full 409 dedup chain: first call succeeds (200), second concurrent call for the
333
-
/// same lease token gets 409 Conflict and returns null. This proves the deterministic PK value
334
-
/// ensures both creates land in the same logical partition, triggering the id-uniqueness conflict.
333
+
/// Verifies the 409 dedup chain by simulating Cosmos DB's uniqueness constraint:
334
+
/// a duplicate (PartitionKey, id) combination returns 409 Conflict regardless of call order.
335
+
/// This proves the deterministic PK value ensures both creates land in the same logical
336
+
/// partition and trigger the id-uniqueness conflict.
0 commit comments