From 77ea4bfcda20d43f8bfd7f51067230ae75d30814 Mon Sep 17 00:00:00 2001 From: Zach Leslie Date: Wed, 22 Sep 2021 08:36:44 -0600 Subject: [PATCH] Include simple e2e test to test searching --- integration/e2e/config-microservices.yaml | 4 ++- integration/e2e/e2e_test.go | 34 +++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/integration/e2e/config-microservices.yaml b/integration/e2e/config-microservices.yaml index 61aabababe7..0347f6c147d 100644 --- a/integration/e2e/config-microservices.yaml +++ b/integration/e2e/config-microservices.yaml @@ -1,3 +1,5 @@ +search_enabled: true + server: http_listen_port: 3200 @@ -45,4 +47,4 @@ memberlist: querier: frontend_worker: - frontend_address: tempo_e2e-query-frontend:9095 \ No newline at end of file + frontend_address: tempo_e2e-query-frontend:9095 diff --git a/integration/e2e/e2e_test.go b/integration/e2e/e2e_test.go index 6cd2a427052..5b7f5077d69 100644 --- a/integration/e2e/e2e_test.go +++ b/integration/e2e/e2e_test.go @@ -24,6 +24,7 @@ import ( util "github.com/grafana/tempo/integration" "github.com/grafana/tempo/integration/e2e/backend" "github.com/grafana/tempo/pkg/tempopb" + tempoUtil "github.com/grafana/tempo/pkg/util" ) const ( @@ -215,6 +216,9 @@ func TestMicroservices(t *testing.T) { // query an in-memory trace queryAndAssertTrace(t, "http://"+tempoQueryFrontend.Endpoint(3200)+"/api/traces/"+hexID, "my operation", 1) + // search an in-memory trace + searchAndAssertTrace(t, "http://"+tempoQueryFrontend.Endpoint(3200), batch.Spans[0].Tags[0].Key, batch.Spans[0].Tags[0].GetVStr(), hexID) + // stop another ingester and confirm things fail err = tempoIngester1.Stop() require.NoError(t, err) @@ -232,6 +236,7 @@ func makeThriftBatchWithSpanCount(n int) *thrift.Batch { traceIDLow := rand.Int63() traceIDHigh := rand.Int63() + tagValue := "y" for i := 0; i < n; i++ { spans = append(spans, &thrift.Span{ TraceIdLow: traceIDLow, @@ -243,8 +248,13 @@ func makeThriftBatchWithSpanCount(n int) *thrift.Batch { Flags: 0, StartTime: time.Now().Unix(), Duration: 1, - Tags: nil, - Logs: nil, + Tags: []*thrift.Tag{ + { + Key: "x", + VStr: &tagValue, + }, + }, + Logs: nil, }) } return &thrift.Batch{Spans: spans} @@ -269,6 +279,26 @@ func queryAndAssertTrace(t *testing.T, url string, expectedName string, expected defer res.Body.Close() } +func searchAndAssertTrace(t *testing.T, baseURL, key, value, expectedHex string) { + c := tempoUtil.NewClient(baseURL, "") + resp, err := c.SearchTag(key, value) + require.NoError(t, err) + + hasHex := func(hexId string) bool { + for _, s := range resp.Traces { + equal, err := tempoUtil.EqualHexStringTraceIDs(s.TraceID, hexId) + require.NoError(t, err) + if equal { + return true + } + } + + return false + } + + require.True(t, hasHex(expectedHex)) +} + func newJaegerGRPCClient(endpoint string) (*jaeger_grpc.Reporter, error) { // new jaeger grpc exporter conn, err := grpc.Dial(endpoint, grpc.WithInsecure())