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

Function TestDoSearch

cmd/tempo-vulture/main_test.go:539–577  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

537}
538
539func TestDoSearch(t *testing.T) {
540 seed := time.Date(2008, 1, 1, 12, 0, 0, 0, time.UTC)
541 traceInfo := util.NewTraceInfo(seed, "test")
542
543 // Define the configuration
544 config := vultureConfiguration{
545 tempoOrgID: "orgID",
546 // This is a hack to ensure the trace is "ready"
547 tempoWriteBackoffDuration: -time.Hour * 10000,
548 tempoRetentionDuration: time.Second * 10,
549 }
550
551 logger = zap.NewNop()
552
553 searchResponse := []*tempopb.TraceSearchMetadata{
554 {
555 SpanSets: []*tempopb.SpanSet{
556 {
557 Spans: []*tempopb.Span{
558 {
559 SpanID: traceInfo.HexID(),
560 StartTimeUnixNano: 1000000000000,
561 DurationNanos: 1000000000,
562 Name: "",
563 Attributes: []*v1_common.KeyValue{
564 {Key: "foo", Value: &v1_common.AnyValue{Value: &v1_common.AnyValue_StringValue{StringValue: "Bar"}}},
565 },
566 },
567 },
568 },
569 },
570 },
571 }
572
573 mockHTTPClient := MockHTTPClient{err: nil, searchResponse: searchResponse}
574
575 doSearch(&mockHTTPClient, config, traceInfo, logger)
576 assert.Greater(t, mockHTTPClient.GetSearchesCount(), 0)
577}
578
579func TestDoSearchError(t *testing.T) {
580 seed := time.Date(2008, 1, 1, 12, 0, 0, 0, time.UTC)

Callers

nothing calls this directly

Calls 4

HexIDMethod · 0.95
GetSearchesCountMethod · 0.95
NewTraceInfoFunction · 0.92
doSearchFunction · 0.85

Tested by

no test coverage detected