Skip to content

Commit

Permalink
Fix pruning test, rebaseline Cosmos
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Oct 28, 2020
1 parent 3472b38 commit 8f780a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
16 changes: 9 additions & 7 deletions tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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)
Expand Down Expand Up @@ -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 *)
Expand Down
12 changes: 7 additions & 5 deletions tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ type Tests(testOutputHelper) =
let batchBackwardsAndAppend = singleBatchBackwards @ [EqxAct.Append]

[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
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()

Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 8f780a5

Please sign in to comment.