(t *testing.T)
| 767 | } |
| 768 | |
| 769 | func TestInstanceSearchDoesNotRace(t *testing.T) { |
| 770 | i, ls := defaultInstanceAndTmpDir(t) |
| 771 | |
| 772 | // add dummy search data |
| 773 | tagKey := foo |
| 774 | tagValue := bar |
| 775 | |
| 776 | req := &tempopb.SearchRequest{ |
| 777 | Query: fmt.Sprintf(`{ span.%s = "%s" }`, tagKey, tagValue), |
| 778 | } |
| 779 | |
| 780 | end := make(chan struct{}) |
| 781 | wg := sync.WaitGroup{} |
| 782 | |
| 783 | concurrent := func(f func()) { |
| 784 | wg.Add(1) |
| 785 | go func() { |
| 786 | defer wg.Done() |
| 787 | for { |
| 788 | select { |
| 789 | case <-end: |
| 790 | return |
| 791 | default: |
| 792 | f() |
| 793 | } |
| 794 | } |
| 795 | }() |
| 796 | } |
| 797 | |
| 798 | concurrent(func() { |
| 799 | id := make([]byte, 16) |
| 800 | _, err := crand.Read(id) |
| 801 | require.NoError(t, err) |
| 802 | |
| 803 | trace := test.MakeTrace(10, id) |
| 804 | traceBytes, err := trace.Marshal() |
| 805 | require.NoError(t, err) |
| 806 | |
| 807 | // Create a push request for livestore |
| 808 | req := &tempopb.PushBytesRequest{ |
| 809 | Traces: []tempopb.PreallocBytes{{Slice: traceBytes}}, |
| 810 | Ids: [][]byte{id}, |
| 811 | } |
| 812 | i.pushBytes(t.Context(), time.Now(), req) |
| 813 | }) |
| 814 | |
| 815 | concurrent(func() { |
| 816 | drained, err := i.cutIdleTraces(t.Context(), true) |
| 817 | require.NoError(t, err, "error cutting complete traces") |
| 818 | require.True(t, drained, "should drain live traces in one iteration") |
| 819 | }) |
| 820 | |
| 821 | concurrent(func() { |
| 822 | // Cut wal, complete |
| 823 | blockID, _ := i.cutBlocks(t.Context(), true) |
| 824 | if blockID != uuid.Nil { |
| 825 | _, err := i.completeBlock(t.Context(), blockID) |
| 826 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected