From 53b3ca586640f8c37b4dede9379a76f5ba777150 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Tue, 15 Sep 2020 13:45:00 -0400 Subject: [PATCH] Fix test Signed-off-by: Yuri Shkuro --- plugin/storage/badger/spanstore/read_write_test.go | 2 +- plugin/storage/badger/spanstore/reader.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin/storage/badger/spanstore/read_write_test.go b/plugin/storage/badger/spanstore/read_write_test.go index 0c5f921dd76..91796387c0a 100644 --- a/plugin/storage/badger/spanstore/read_write_test.go +++ b/plugin/storage/badger/spanstore/read_write_test.go @@ -303,7 +303,7 @@ func TestFindNothing(t *testing.T) { trs, err := sr.FindTraces(context.Background(), params) assert.NoError(t, err) - assert.Equal(t, 0, len(trs)) + assert.Len(t, trs, 0) tr, err := sr.GetTrace(context.Background(), model.TraceID{High: 0, Low: 0}) assert.Equal(t, spanstore.ErrTraceNotFound, err) diff --git a/plugin/storage/badger/spanstore/reader.go b/plugin/storage/badger/spanstore/reader.go index c5d2ccf848f..83c722f8b75 100644 --- a/plugin/storage/badger/spanstore/reader.go +++ b/plugin/storage/badger/spanstore/reader.go @@ -54,6 +54,9 @@ var ( // ErrNotSupported during development, don't support every option - yet ErrNotSupported = errors.New("this query parameter is not supported yet") + + // ErrInternalConsistencyError indicates internal data quality sissue + ErrInternalConsistencyError = errors.New("internal data quality sissue") ) const ( @@ -160,11 +163,14 @@ func (r *TraceReader) GetTrace(ctx context.Context, traceID model.TraceID) (*mod if err != nil { return nil, err } + if len(traces) == 0 { + return nil, spanstore.ErrTraceNotFound + } if len(traces) == 1 { return traces[0], nil } - return nil, spanstore.ErrTraceNotFound + return nil, ErrInternalConsistencyError } // scanTimeRange returns all the Traces found between startTs and endTs