Skip to content

Commit 8f780a5

Browse files
committed
Fix pruning test, rebaseline Cosmos
1 parent 3472b38 commit 8f780a5

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

tests/Equinox.CosmosStore.Integration/CosmosCoreIntegration.fs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ type Tests(testOutputHelper) =
4343
let! res = Events.append ctx streamName index <| TestEvents.Create(0,1)
4444
test <@ AppendResult.Ok 1L = res @>
4545
test <@ [EqxAct.Append] = capture.ExternalCalls @>
46-
if eventsInTip then verifyRequestChargesMax 21 // 20.42
47-
else verifyRequestChargesMax 34 // 33.07
46+
if eventsInTip then verifyRequestChargesMax 24 // 23.72
47+
else verifyRequestChargesMax 36 // 35.97 // 43.53 observed
4848

4949
// Clear the counters
5050
capture.Clear()
@@ -53,8 +53,8 @@ type Tests(testOutputHelper) =
5353
test <@ AppendResult.Ok 6L = res @>
5454
test <@ [EqxAct.Append] = capture.ExternalCalls @>
5555
// We didnt request small batches or splitting so it's not dramatically more expensive to write N events
56-
if eventsInTip then verifyRequestChargesMax 40 // 39.13
57-
else verifyRequestChargesMax 41 // 40.68
56+
if eventsInTip then verifyRequestChargesMax 42 // 41.36
57+
else verifyRequestChargesMax 43 // 42.82
5858
}
5959

6060
// 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) =
136136
pos <- pos + 42L
137137
pos =! res
138138
test <@ [EqxAct.Append] = capture.ExternalCalls @>
139-
if eventsInTip then verifyRequestChargesMax 45 // was 44.65
139+
if eventsInTip then verifyRequestChargesMax 48 // 47.58
140140
else verifyRequestChargesMax 50 // 49.74
141141
capture.Clear()
142142

@@ -152,7 +152,8 @@ type Tests(testOutputHelper) =
152152
let extrasCount = match extras with x when x > 50 -> 5000 | x when x < 1 -> 1 | x -> x*100
153153
let! _pos = ctx.NonIdempotentAppend(stream, TestEvents.Create (int pos,extrasCount))
154154
test <@ [EqxAct.Append] = capture.ExternalCalls @>
155-
verifyRequestChargesMax 448 // 447.5 // 463.01 observed
155+
if eventsInTip then verifyRequestChargesMax 451 // 450.03
156+
else verifyRequestChargesMax 448 // 447.5 // 463.01 observed
156157
capture.Clear()
157158

158159
let! pos = ctx.Sync(stream,?position=None)
@@ -252,7 +253,8 @@ type Tests(testOutputHelper) =
252253
| _ -> None
253254
// validate that, because we stopped after 1 item, we only needed one trip (which contained 4 events)
254255
[1,4] =! capture.ChooseCalls queryRoundTripsAndItemCounts
255-
verifyRequestChargesMax 3 // 2.97
256+
if eventsInTip then verifyRequestChargesMax 4 // 3.06
257+
else verifyRequestChargesMax 4 // 3.08
256258
}
257259

258260
(* Backward *)

tests/Equinox.CosmosStore.Integration/CosmosIntegration.fs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,15 @@ type Tests(testOutputHelper) =
189189
let batchBackwardsAndAppend = singleBatchBackwards @ [EqxAct.Append]
190190

191191
[<AutoData(MaxTest = 2, SkipIfRequestedViaEnvironmentVariable="EQUINOX_INTEGRATION_SKIP_COSMOS")>]
192-
let ``Can correctly read and update against Cosmos with LatestKnownEvent Access Strategy`` (eventsInTip, value) = Async.RunSynchronously <| async {
192+
let ``Can correctly read and update against Cosmos with LatestKnownEvent Access Strategy`` (eventsInTip, value : ContactPreferences.Events.Preferences) = Async.RunSynchronously <| async {
193193
let context = createPrimaryContextEx log 1 (if eventsInTip then 1 else 0)
194194
let service = ContactPreferences.createService log context
195+
// We need to be sure every Update changes something as we rely on an expected number of events in the end
196+
let value = if value <> ContactPreferences.Fold.initial then value else { value with manyPromotions = true }
195197

196198
let id = ContactPreferences.Id (let g = System.Guid.NewGuid() in g.ToString "N")
197199
// Ensure there will be something to be changed by the Update below
198-
for i in 1..13 do
200+
for i in 0..13 do
199201
do! service.Update(id, if i % 2 = 0 then value else { value with quickSurveys = not value.quickSurveys })
200202
capture.Clear()
201203

@@ -215,8 +217,8 @@ type Tests(testOutputHelper) =
215217
let streamName = ContactPreferences.streamName id |> FsCodec.StreamName.toString
216218

217219
// Prune all the events
218-
let! deleted, deferred, trimmedPos = Core.Events.prune ctx streamName 14L
219-
test <@ deleted = 14 && deferred = 0 && trimmedPos = 14L @>
220+
let! deleted, deferred, trimmedPos = Core.Events.prune ctx streamName 15L
221+
test <@ deleted = 15 && deferred = 0 && trimmedPos = 15L @>
220222

221223
// Prove they're gone
222224
capture.Clear()
@@ -239,7 +241,7 @@ type Tests(testOutputHelper) =
239241
let service = ContactPreferences.createServiceWithLatestKnownEvent context log CachingStrategy.NoCaching
240242

241243
let id = ContactPreferences.Id (let g = System.Guid.NewGuid() in g.ToString "N")
242-
// Feed some junk into the stream; Ensure there will be something to be changed by the Update below
244+
// Ensure there will be something to be changed by the Update below
243245
for i in 1..13 do
244246
do! service.Update(id, if i % 2 = 0 then value else { value with quickSurveys = not value.quickSurveys })
245247
capture.Clear()

0 commit comments

Comments
 (0)