Skip to content

Commit

Permalink
Include simple e2e test to test searching
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Sep 22, 2021
1 parent e5f7ded commit 77ea4bf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 3 additions & 1 deletion integration/e2e/config-microservices.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
search_enabled: true

server:
http_listen_port: 3200

Expand Down Expand Up @@ -45,4 +47,4 @@ memberlist:

querier:
frontend_worker:
frontend_address: tempo_e2e-query-frontend:9095
frontend_address: tempo_e2e-query-frontend:9095
34 changes: 32 additions & 2 deletions integration/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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}
Expand All @@ -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())
Expand Down

0 comments on commit 77ea4bf

Please sign in to comment.