mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
feature: [jaeger poc] add test grpc client
This commit is contained in:
parent
615d719fac
commit
df2c973e50
2 changed files with 44 additions and 1 deletions
app/vlinsert/jaeger
|
@ -3,6 +3,7 @@ package jaeger
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/insertutils"
|
||||
|
@ -16,7 +17,7 @@ type SpanWriterPluginServer struct {
|
|||
func (s *SpanWriterPluginServer) WriteSpan(ctx context.Context, req *proto.WriteSpanRequest) (*proto.WriteSpanResponse, error) {
|
||||
span := req.GetSpan()
|
||||
if span == nil {
|
||||
return nil, nil
|
||||
return &proto.WriteSpanResponse{}, fmt.Errorf("span not found")
|
||||
}
|
||||
|
||||
jsonSpan, err := json.Marshal(span)
|
||||
|
|
42
app/vlinsert/jaeger/test_client/grpc_client_test.go
Normal file
42
app/vlinsert/jaeger/test_client/grpc_client_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vlinsert/jaeger/proto"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func newSpanReaderPluginClient(t *testing.T) proto.SpanReaderPluginClient {
|
||||
conn, err := grpc.NewClient(fmt.Sprintf("0.0.0.0:%d", 17271), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("cannot connect to server: %v", err)
|
||||
}
|
||||
return proto.NewSpanReaderPluginClient(conn)
|
||||
}
|
||||
|
||||
func newSpanWriterPluginClient(t *testing.T) proto.SpanWriterPluginClient {
|
||||
conn, err := grpc.NewClient(fmt.Sprintf("0.0.0.0:%d", 17271), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatalf("cannot connect to server: %v", err)
|
||||
}
|
||||
return proto.NewSpanWriterPluginClient(conn)
|
||||
}
|
||||
|
||||
func TestSpanWriter(t *testing.T) {
|
||||
// This is NOT a unit test. Please run the VictoriaLogs before executing this test.
|
||||
client := newSpanWriterPluginClient(t)
|
||||
req := &proto.WriteSpanRequest{}
|
||||
resp, err := client.WriteSpan(context.Background(), req)
|
||||
fmt.Println(resp, err)
|
||||
}
|
||||
|
||||
func TestSpanReaderGetOperations(t *testing.T) {
|
||||
// This is NOT a unit test. Please run the VictoriaLogs before executing this test.
|
||||
client := newSpanReaderPluginClient(t)
|
||||
req := &proto.GetOperationsRequest{}
|
||||
resp, err := client.GetOperations(context.Background(), req)
|
||||
fmt.Println(resp, err)
|
||||
}
|
Loading…
Reference in a new issue