(t *testing.T)
| 925 | } |
| 926 | |
| 927 | func TestInstanceFindByTraceID(t *testing.T) { |
| 928 | i, ls := defaultInstanceAndTmpDir(t) |
| 929 | |
| 930 | tagKey := foo |
| 931 | tagValue := bar |
| 932 | ids, _, _, _ := writeTracesForSearch(t, i, "", tagKey, tagValue, false, false) |
| 933 | require.Greater(t, len(ids), 0, "writeTracesForSearch should create traces") |
| 934 | |
| 935 | // Test 1: Find traces after being cut to WAL |
| 936 | resp, err := i.FindByTraceID(t.Context(), ids[0], true) |
| 937 | require.NoError(t, err) |
| 938 | require.NotNil(t, resp) |
| 939 | require.NotNil(t, resp.Trace) |
| 940 | require.Equal(t, ids[0], resp.Trace.ResourceSpans[0].ScopeSpans[0].Spans[0].TraceId) |
| 941 | |
| 942 | // Test 2: Move traces through different sections |
| 943 | blockID, err := i.cutBlocks(t.Context(), true) |
| 944 | require.NoError(t, err) |
| 945 | require.NotEqual(t, blockID, uuid.Nil) |
| 946 | |
| 947 | // Verify we can still find traces from walBlocks |
| 948 | resp, err = i.FindByTraceID(t.Context(), ids[0], true) |
| 949 | require.NoError(t, err) |
| 950 | require.NotNil(t, resp.Trace) |
| 951 | |
| 952 | // Test 3: Complete block (moves to completeBlocks) |
| 953 | _, err = i.completeBlock(t.Context(), blockID) |
| 954 | require.NoError(t, err) |
| 955 | |
| 956 | // Verify we can find traces from completed blocks |
| 957 | resp, err = i.FindByTraceID(t.Context(), ids[0], true) |
| 958 | require.NoError(t, err) |
| 959 | require.NotNil(t, resp.Trace) |
| 960 | |
| 961 | // Test 4: Add more traces to new head block |
| 962 | moreIDs, _, _, _ := writeTracesForSearch(t, i, "", tagKey, "baz", false, false) |
| 963 | require.Greater(t, len(moreIDs), 0, "should create more traces") |
| 964 | |
| 965 | // Verify we can find both old and new traces |
| 966 | resp1, err := i.FindByTraceID(t.Context(), ids[0], true) |
| 967 | require.NoError(t, err) |
| 968 | require.NotNil(t, resp1.Trace, "Should find trace from completed blocks") |
| 969 | |
| 970 | resp2, err := i.FindByTraceID(t.Context(), moreIDs[0], true) |
| 971 | require.NoError(t, err) |
| 972 | require.NotNil(t, resp2.Trace, "Should find trace from head block") |
| 973 | |
| 974 | err = services.StopAndAwaitTerminated(t.Context(), ls) |
| 975 | require.NoError(t, err) |
| 976 | } |
| 977 | |
| 978 | func TestInstanceFindByTraceIDWithSizeLimits(t *testing.T) { |
| 979 | // Test that the maxBytesPerTrace limit is being passed to the combiner correctly |
nothing calls this directly
no test coverage detected