MCPcopy
hub / github.com/grafana/tempo / testSearch

Function testSearch

integration/api/multi_tenant_test.go:29–71  ·  integration/api/multi_tenant_test.go::testSearch
(t *testing.T, tenant string)

Source from the content-addressed store, hash-verified

27}
28
29func testSearch(t *testing.T, tenant string) {
30 util.RunIntegrationTests(t, util.TestHarnessConfig{
31 ConfigOverlay: "config-multi-tenant.yaml",
32 }, func(h *util.TempoHarness) {
33 h.WaitTracesWritable(t)
34
35 var info *tempoUtil.TraceInfo
36
37 tenants := strings.Split(tenant, "|")
38 tenantSize := len(tenants)
39
40 // write traces for all tenants
41 for _, tenant := range tenants {
42 info = tempoUtil.NewTraceInfo(time.Now(), tenant)
43 require.NoError(t, h.WriteTraceInfo(info, tenant))
44 }
45
46 // assert that we have one trace for each tenant and correct number of spans received
47 h.WaitTracesQueryable(t, tenantSize)
48
49 // check trace by id
50 apiClient := h.APIClientHTTP(tenant)
51 util.SearchTraceQLAndAssertTrace(t, apiClient, info)
52
53 // call search tags endpoints, ensure no errors and results are not empty
54 tagsV2Resp, err := apiClient.SearchTagsV2()
55 require.NoError(t, err)
56 require.Equal(t, 4, len(tagsV2Resp.GetScopes())) // resource, span, event, link, instrumentation intrinsics
57 for _, s := range tagsV2Resp.Scopes {
58 require.NotEmpty(t, s.Tags)
59 }
60
61 tagsValuesV2Resp, err := apiClient.SearchTagValuesV2("span.vulture-0", "{}")
62 require.NoError(t, err)
63 require.NotEmpty(t, tagsValuesV2Resp.TagValues)
64
65 grpcClient, ctx, err := h.APIClientGRPC(tenant)
66 require.NoError(t, err)
67
68 now := time.Now()
69 util.SearchStreamAndAssertTrace(t, ctx, grpcClient, info, now.Add(-time.Hour).Unix(), now.Add(time.Hour).Unix())
70 })
71}

Callers 4

TestSingleTenantSearchFunction · 0.70
TestWildCardTenantSearchFunction · 0.70
TestTwoTenantsSearchFunction · 0.70
TestThreeTenantsSearchFunction · 0.70

Calls 11

WaitTracesWritableMethod · 0.80
WriteTraceInfoMethod · 0.80
WaitTracesQueryableMethod · 0.80
APIClientHTTPMethod · 0.80
GetScopesMethod · 0.80
APIClientGRPCMethod · 0.80
NowMethod · 0.65
SearchTagsV2Method · 0.65
SearchTagValuesV2Method · 0.65
AddMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected