MCPcopy Create free account
hub / github.com/coder/coder / Test_LinearExecutionStrategy

Function Test_LinearExecutionStrategy

scaletest/harness/strategies_test.go:20–50  ·  view source on GitHub ↗

nolint:paralleltest // this tests uses timings to determine if it's working

(t *testing.T)

Source from the content-addressed store, hash-verified

18
19//nolint:paralleltest // this tests uses timings to determine if it's working
20func Test_LinearExecutionStrategy(t *testing.T) {
21 var (
22 lastSeenI atomic.Int64
23 count atomic.Int64
24 )
25 lastSeenI.Store(-1)
26 runs, fns := strategyTestData(100, func(_ context.Context, i int, _ io.Writer) error {
27 count.Add(1)
28 swapped := lastSeenI.CompareAndSwap(int64(i-1), int64(i))
29 assert.True(t, swapped)
30 time.Sleep(2 * time.Millisecond)
31
32 if i%2 == 0 {
33 return xerrors.New("error")
34 }
35 return nil
36 })
37
38 strategy := harness.LinearExecutionStrategy{}
39 runErrs, err := strategy.Run(context.Background(), fns)
40 require.NoError(t, err)
41 require.Len(t, runErrs, 50)
42 require.EqualValues(t, 100, count.Load())
43
44 lastStartTime := time.Time{}
45 for _, run := range runs {
46 startTime := run.Result().StartedAt
47 require.True(t, startTime.After(lastStartTime))
48 lastStartTime = startTime
49 }
50}
51
52//nolint:paralleltest // this tests uses timings to determine if it's working
53func Test_ConcurrentExecutionStrategy(t *testing.T) {

Callers

nothing calls this directly

Calls 9

RunMethod · 0.95
strategyTestDataFunction · 0.85
CompareAndSwapMethod · 0.80
AddMethod · 0.65
NewMethod · 0.65
StoreMethod · 0.45
LenMethod · 0.45
LoadMethod · 0.45
ResultMethod · 0.45

Tested by

no test coverage detected