(t *testing.T)
| 953 | } |
| 954 | |
| 955 | func TestPollNotification(t *testing.T) { |
| 956 | r, w, _, _ := testConfig(t, 0) |
| 957 | |
| 958 | ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second) |
| 959 | defer cancel() |
| 960 | |
| 961 | r.EnablePolling(ctx, &mockJobSharder{}, false) |
| 962 | |
| 963 | blockID := backend.NewUUID() |
| 964 | |
| 965 | wal := w.WAL() |
| 966 | |
| 967 | meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID} |
| 968 | head, err := wal.NewBlock(meta, model.CurrentEncoding) |
| 969 | assert.NoError(t, err) |
| 970 | |
| 971 | dec := model.MustNewSegmentDecoder(model.CurrentEncoding) |
| 972 | |
| 973 | // write |
| 974 | numMsgs := 10 |
| 975 | reqs := make([]*tempopb.Trace, numMsgs) |
| 976 | ids := make([]common.ID, numMsgs) |
| 977 | for i := range numMsgs { |
| 978 | ids[i] = test.ValidTraceID(nil) |
| 979 | reqs[i] = test.MakeTrace(10, ids[i]) |
| 980 | writeTraceToWal(t, head, dec, ids[i], reqs[i], 0, 0) |
| 981 | } |
| 982 | |
| 983 | _, err = w.CompleteBlock(ctx, head) |
| 984 | assert.NoError(t, err) |
| 985 | start := time.Now() |
| 986 | sleepTime := 1 * time.Second |
| 987 | |
| 988 | wg := &sync.WaitGroup{} |
| 989 | for range 10 { |
| 990 | |
| 991 | wg.Add(1) |
| 992 | go func() { |
| 993 | defer wg.Done() |
| 994 | <-r.PollNotification(ctx) |
| 995 | require.Greater(t, time.Since(start), sleepTime, "PollNotification should not return before the first PollNow call") |
| 996 | }() |
| 997 | } |
| 998 | |
| 999 | time.Sleep(sleepTime) |
| 1000 | |
| 1001 | r.PollNow(ctx) |
| 1002 | |
| 1003 | wg.Wait() |
| 1004 | |
| 1005 | require.NoError(t, ctx.Err(), "context should not be cancelled before all goroutines finish") |
| 1006 | } |
nothing calls this directly
no test coverage detected