Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test for ErrTraceNotFound #2478

Merged
merged 4 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin/storage/badger/spanstore/read_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestFindNothing(t *testing.T) {
assert.Equal(t, 0, len(trs))

tr, err := sr.GetTrace(context.Background(), model.TraceID{High: 0, Low: 0})
assert.NoError(t, err)
assert.Equal(t, spanstore.ErrTraceNotFound, err)
assert.Nil(t, tr)
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/badger/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (r *TraceReader) GetTrace(ctx context.Context, traceID model.TraceID) (*mod
return traces[0], nil
}

return nil, nil
return nil, spanstore.ErrTraceNotFound
}

// scanTimeRange returns all the Traces found between startTs and endTs
Expand Down
7 changes: 7 additions & 0 deletions plugin/storage/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ func (s *StorageIntegration) testGetTrace(t *testing.T) {
if !assert.True(t, found) {
CompareTraces(t, expected, actual)
}

t.Run("NotFound error", func(t *testing.T) {
fakeTraceID := model.TraceID{High: 0, Low: 0}
trace, err := s.SpanReader.GetTrace(context.Background(), fakeTraceID)
assert.Equal(t, spanstore.ErrTraceNotFound, err)
assert.Nil(t, trace)
})
}

func (s *StorageIntegration) testFindTraces(t *testing.T) {
Expand Down
21 changes: 21 additions & 0 deletions storage/spanstore/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,31 @@ type Writer interface {

// Reader finds and loads traces and other data from storage.
type Reader interface {
// GetTrace retrieves the trace with a given id.
//
// If no spans are stored for this trace, it returns ErrTraceNotFound.
GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error)

// GetServices returns all service names known to the backend from spans
// within its retention period.
GetServices(ctx context.Context) ([]string, error)

// GetOperations returns all operation names for a given service
// known to the backend from spans within its retention period.
GetOperations(ctx context.Context, query OperationQueryParameters) ([]Operation, error)

// FindTraces returns all traces matching query parameters. There's currently
// an implementation-dependent abiguity whether all query filters (such as
// multiple tags) must apply to the same span within a trace, or can be satisfied
// by different spans.
//
// If no matching traces are found, the function returns (nil, nil).
FindTraces(ctx context.Context, query *TraceQueryParameters) ([]*model.Trace, error)

// FindTraceIDs does the same search as FindTraces, but returns only the list
// of matching trace IDs.
//
// If no matching traces are found, the function returns (nil, nil).
FindTraceIDs(ctx context.Context, query *TraceQueryParameters) ([]model.TraceID, error)
}

Expand Down