(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func TestExecutionStateVUIDs(t *testing.T) { |
| 22 | t.Parallel() |
| 23 | |
| 24 | testCases := []struct { |
| 25 | seq, seg string |
| 26 | }{ |
| 27 | {}, |
| 28 | {seq: "0,1/4,3/4,1", seg: "0:1/4"}, |
| 29 | {seq: "0,0.3,0.5,0.6,0.7,0.8,0.9,1", seg: "0.5:0.6"}, |
| 30 | } |
| 31 | |
| 32 | for _, tc := range testCases { |
| 33 | t.Run(fmt.Sprintf("seq:%s;segment:%s", tc.seq, tc.seg), func(t *testing.T) { |
| 34 | t.Parallel() |
| 35 | ess, err := lib.NewExecutionSegmentSequenceFromString(tc.seq) |
| 36 | require.NoError(t, err) |
| 37 | segment, err := lib.NewExecutionSegmentFromString(tc.seg) |
| 38 | require.NoError(t, err) |
| 39 | et, err := lib.NewExecutionTuple(segment, &ess) |
| 40 | require.NoError(t, err) |
| 41 | |
| 42 | start, offsets, _ := et.GetStripedOffsets() |
| 43 | es := lib.NewExecutionState(nil, et, 0, 0) |
| 44 | |
| 45 | idl, idg := es.GetUniqueVUIdentifiers() |
| 46 | assert.EqualValues(t, 1, idl) |
| 47 | expGlobal := start + 1 |
| 48 | assert.EqualValues(t, expGlobal, idg) |
| 49 | |
| 50 | idl, idg = es.GetUniqueVUIdentifiers() |
| 51 | assert.EqualValues(t, 2, idl) |
| 52 | expGlobal += offsets[0] |
| 53 | assert.EqualValues(t, expGlobal, idg) |
| 54 | |
| 55 | idl, idg = es.GetUniqueVUIdentifiers() |
| 56 | assert.EqualValues(t, 3, idl) |
| 57 | expGlobal += offsets[0] |
| 58 | assert.EqualValues(t, expGlobal, idg) |
| 59 | |
| 60 | seed := time.Now().UnixNano() |
| 61 | r := rand.New(rand.NewSource(seed)) |
| 62 | t.Logf("Random source seeded with %d\n", seed) |
| 63 | count := 100 + r.Intn(50) |
| 64 | |
| 65 | synctest.Test(t, func(t *testing.T) { |
| 66 | for range count { |
| 67 | go func() { |
| 68 | es.GetUniqueVUIdentifiers() |
| 69 | }() |
| 70 | } |
| 71 | synctest.Wait() |
| 72 | idl, idg = es.GetUniqueVUIdentifiers() |
| 73 | assert.EqualValues(t, 4+count, idl) |
| 74 | assert.EqualValues(t, (3+count)*int(offsets[0])+int(start+1), idg) |
| 75 | }) |
| 76 | }) |
| 77 | } |
| 78 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…