Skip to content

Commit

Permalink
Verify FindTraces() received a query (#2979)
Browse files Browse the repository at this point in the history
* Verify FindTraces() received a query

Signed-off-by: Ed Snible <snible@us.ibm.com>

* Simplify test

Signed-off-by: Ed Snible <snible@us.ibm.com>

* Rename test

Signed-off-by: Ed Snible <snible@us.ibm.com>
  • Loading branch information
esnible committed May 6, 2021
1 parent 87f1283 commit f076065
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/query/app/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (g *GRPCHandler) ArchiveTrace(ctx context.Context, r *api_v2.ArchiveTraceRe
// FindTraces is the gRPC handler to fetch traces based on TraceQueryParameters.
func (g *GRPCHandler) FindTraces(r *api_v2.FindTracesRequest, stream api_v2.QueryService_FindTracesServer) error {
query := r.GetQuery()
if query == nil {
return status.Errorf(codes.InvalidArgument, "missing query")
}
queryParams := spanstore.TraceQueryParameters{
ServiceName: query.ServiceName,
OperationName: query.OperationName,
Expand Down
13 changes: 13 additions & 0 deletions cmd/query/app/grpc_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,19 @@ func TestSearchSuccess_SpanStreamingGRPC(t *testing.T) {
})
}

func TestSearchInvalid_GRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
res, err := client.FindTraces(context.Background(), &api_v2.FindTracesRequest{
Query: nil,
})
assert.NoError(t, err)

spanResChunk, err := res.Recv()
assert.Error(t, err)
assert.Nil(t, spanResChunk)
})
}

func TestSearchFailure_GRPC(t *testing.T) {
withServerAndClient(t, func(server *grpcServer, client *grpcClient) {
mockErrorGRPC := fmt.Errorf("whatsamattayou")
Expand Down

0 comments on commit f076065

Please sign in to comment.