-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Propagate TraceNotFound error from grpc storage plugins #2455
Changes from 3 commits
d8016fc
7e5f034
62848a0
799b5e7
82bd25c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import ( | |
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
"google.golang.org/grpc/metadata" | ||
"google.golang.org/grpc/status" | ||
|
||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/proto-gen/storage_v1" | ||
|
@@ -200,9 +201,11 @@ func TestGRPCClientGetTrace_NoTrace(t *testing.T) { | |
} | ||
|
||
func TestGRPCClientGetTrace_StreamErrorTraceNotFound(t *testing.T) { | ||
s, _ := status.FromError(spanstore.ErrTraceNotFound) | ||
|
||
withGRPCClient(func(r *grpcClientTest) { | ||
traceClient := new(grpcMocks.SpanReaderPlugin_GetTraceClient) | ||
traceClient.On("Recv").Return(nil, spanstore.ErrTraceNotFound) | ||
traceClient.On("Recv").Return(nil, s.Err()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should write a test that goes through client and server, not just mocking the client. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. I can't say I have time right now to knock it out. Perhaps if i find some time in the next week or two I'll dig into it. |
||
r.spanReader.On("GetTrace", mock.Anything, &storage_v1.GetTraceRequest{ | ||
TraceID: mockTraceID, | ||
}).Return(traceClient, nil) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasn't this if statement mostly correct, except the condition should be
ok
instead of!ok
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's true. I prefer what I have pushed b/c it doesn't matter if
err
is anerror
or astatus.Status
if the message is "trace not found" then it will return the correct error.We can do the minimal change if it's preferred though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original version (aside from !ok) seems better, because your version is ignoring the error, so
s
may be undefined.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. I am relying on
status.FromError
to return a non-nil status. I think this would the best constructionok
just indicates ifFromError
had to create a newstatus.Status
or if it was able to retrieve one using theGRPCStatus()
method. For our purposes we don't care, we're just going to compares.Message()
to "trace not found" either way.