diff --git a/tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs b/tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs index fb93fef5f..2534344cf 100644 --- a/tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs +++ b/tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs @@ -43,8 +43,8 @@ type Tests(testOutputHelper) = let! res = Events.append ctx streamName index <| TestEvents.Create(0,1) test <@ AppendResult.Ok 1L = res @> test <@ [EqxAct.Append] = capture.ExternalCalls @> - if eventsInTip then verifyRequestChargesMax 21 // 20.42 - else verifyRequestChargesMax 34 // 33.07 + if eventsInTip then verifyRequestChargesMax 24 // 23.72 + else verifyRequestChargesMax 36 // 35.97 // 43.53 observed // Clear the counters capture.Clear() @@ -53,8 +53,8 @@ type Tests(testOutputHelper) = test <@ AppendResult.Ok 6L = res @> test <@ [EqxAct.Append] = capture.ExternalCalls @> // We didnt request small batches or splitting so it's not dramatically more expensive to write N events - if eventsInTip then verifyRequestChargesMax 40 // 39.13 - else verifyRequestChargesMax 41 // 40.68 + if eventsInTip then verifyRequestChargesMax 42 // 41.36 + else verifyRequestChargesMax 43 // 42.82 } // It's conceivable that in the future we might allow zero-length batches as long as a sync mechanism leveraging the etags and unfolds update mechanisms @@ -136,7 +136,7 @@ type Tests(testOutputHelper) = pos <- pos + 42L pos =! res test <@ [EqxAct.Append] = capture.ExternalCalls @> - if eventsInTip then verifyRequestChargesMax 45 // was 44.65 + if eventsInTip then verifyRequestChargesMax 48 // 47.58 else verifyRequestChargesMax 50 // 49.74 capture.Clear() @@ -152,7 +152,8 @@ type Tests(testOutputHelper) = let extrasCount = match extras with x when x > 50 -> 5000 | x when x < 1 -> 1 | x -> x*100 let! _pos = ctx.NonIdempotentAppend(stream, TestEvents.Create (int pos,extrasCount)) test <@ [EqxAct.Append] = capture.ExternalCalls @> - verifyRequestChargesMax 448 // 447.5 // 463.01 observed + if eventsInTip then verifyRequestChargesMax 451 // 450.03 + else verifyRequestChargesMax 448 // 447.5 // 463.01 observed capture.Clear() let! pos = ctx.Sync(stream,?position=None) @@ -252,7 +253,8 @@ type Tests(testOutputHelper) = | _ -> None // validate that, because we stopped after 1 item, we only needed one trip (which contained 4 events) [1,4] =! capture.ChooseCalls queryRoundTripsAndItemCounts - verifyRequestChargesMax 3 // 2.97 + if eventsInTip then verifyRequestChargesMax 4 // 3.06 + else verifyRequestChargesMax 4 // 3.08 } (* Backward *) diff --git a/tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs b/tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs index 50a2e1be9..b80655d96 100644 --- a/tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs +++ b/tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs @@ -189,13 +189,15 @@ type Tests(testOutputHelper) = let batchBackwardsAndAppend = singleBatchBackwards @ [EqxAct.Append] [] - let ``Can correctly read and update against Cosmos with LatestKnownEvent Access Strategy`` (eventsInTip, value) = Async.RunSynchronously <| async { + let ``Can correctly read and update against Cosmos with LatestKnownEvent Access Strategy`` (eventsInTip, value : ContactPreferences.Events.Preferences) = Async.RunSynchronously <| async { let context = createPrimaryContextEx log 1 (if eventsInTip then 1 else 0) let service = ContactPreferences.createService log context + // We need to be sure every Update changes something as we rely on an expected number of events in the end + let value = if value <> ContactPreferences.Fold.initial then value else { value with manyPromotions = true } let id = ContactPreferences.Id (let g = System.Guid.NewGuid() in g.ToString "N") // Ensure there will be something to be changed by the Update below - for i in 1..13 do + for i in 0..13 do do! service.Update(id, if i % 2 = 0 then value else { value with quickSurveys = not value.quickSurveys }) capture.Clear() @@ -215,8 +217,8 @@ type Tests(testOutputHelper) = let streamName = ContactPreferences.streamName id |> FsCodec.StreamName.toString // Prune all the events - let! deleted, deferred, trimmedPos = Core.Events.prune ctx streamName 14L - test <@ deleted = 14 && deferred = 0 && trimmedPos = 14L @> + let! deleted, deferred, trimmedPos = Core.Events.prune ctx streamName 15L + test <@ deleted = 15 && deferred = 0 && trimmedPos = 15L @> // Prove they're gone capture.Clear() @@ -239,7 +241,7 @@ type Tests(testOutputHelper) = let service = ContactPreferences.createServiceWithLatestKnownEvent context log CachingStrategy.NoCaching let id = ContactPreferences.Id (let g = System.Guid.NewGuid() in g.ToString "N") - // Feed some junk into the stream; Ensure there will be something to be changed by the Update below + // Ensure there will be something to be changed by the Update below for i in 1..13 do do! service.Update(id, if i % 2 = 0 then value else { value with quickSurveys = not value.quickSurveys }) capture.Clear()