Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,19 @@ let ``Cancel running jobs with the same key`` () =
// detach requests from their running computations
cts.Cancel()

// Cancel the Get reequests, leaving the jobs running unawaited.
for job in jobsToCancel do assertTaskCanceled job

// Start another request.
let job = cache.Get(key 11, work) |> Async.StartAsTask

// up til now the jobs should have been running unobserved
let current = eventsWhen events (received Requested)
Assert.Equal(0, current |> countOf Canceled)

// waitUntil events (countOf Canceled >> (=) 10)

waitUntil events (received Started)
waitUntil events (countOf Started >> (=) 11)

// Allow the single current request to finish.
jobCanContinue.Set() |> ignore

job.Wait()
Expand Down
8 changes: 8 additions & 0 deletions tests/FSharp.Test.Utilities/XunitHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ open OpenTelemetry.Trace
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Method, AllowMultiple = false)>]
type RunTestCasesInSequenceAttribute() = inherit Attribute()

// Helper for stress testing.
// Runs a test case many times in parallel.
// Example usage: [<Theory; Repeat(Count = 1000)>]
type RepeatAttribute([<ParamArray>] data: obj array) =
inherit DataAttribute()
member val Count = 1 with get, set
override this.GetData _ = Seq.init this.Count (fun i -> [| yield! data; yield box i |])

#if XUNIT_EXTRAS

// To use xUnit means to customize it. The following abomination adds 2 features:
Expand Down