MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestStreamingSends

Function TestStreamingSends

pkg/ingester/client/cortex_util_test.go:21–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestStreamingSends(t *testing.T) {
22 tests := map[string]struct {
23 streamName string
24 serverSend func(grpc.ServerStream) error
25 clientRecv func(context.Context, IngesterClient) error
26 }{
27 "testing SendQueryStream": {
28 streamName: "QueryStream",
29 serverSend: func(stream grpc.ServerStream) error {
30 return SendQueryStream(stream.(Ingester_QueryStreamServer), &QueryStreamResponse{})
31 },
32 clientRecv: func(ctx context.Context, client IngesterClient) error {
33 stream, err := client.QueryStream(ctx, &QueryRequest{})
34 require.NoError(t, err)
35
36 // Try to receive the response and assert the error we get is the context.Canceled
37 // wrapped within a gRPC error.
38 _, err = stream.Recv()
39 return err
40 },
41 },
42 "testing SendMetricsForLabelMatchersStream": {
43 streamName: "MetricsForLabelMatchersStream",
44 serverSend: func(stream grpc.ServerStream) error {
45 return SendMetricsForLabelMatchersStream(stream.(Ingester_MetricsForLabelMatchersStreamServer), &MetricsForLabelMatchersStreamResponse{})
46 },
47 clientRecv: func(ctx context.Context, client IngesterClient) error {
48 stream, err := client.MetricsForLabelMatchersStream(ctx, &MetricsForLabelMatchersRequest{})
49 require.NoError(t, err)
50
51 // Try to receive the response and assert the error we get is the context.Canceled
52 // wrapped within a gRPC error.
53 _, err = stream.Recv()
54 return err
55 },
56 },
57 "testing LabelNamesStream": {
58 streamName: "LabelNamesStream",
59 serverSend: func(stream grpc.ServerStream) error {
60 return SendLabelNamesStream(stream.(Ingester_LabelNamesStreamServer), &LabelNamesStreamResponse{})
61 },
62 clientRecv: func(ctx context.Context, client IngesterClient) error {
63 stream, err := client.LabelNamesStream(ctx, &LabelNamesRequest{})
64 require.NoError(t, err)
65
66 // Try to receive the response and assert the error we get is the context.Canceled
67 // wrapped within a gRPC error.
68 _, err = stream.Recv()
69 return err
70 },
71 },
72 "testing LabelValuesStream": {
73 streamName: "LabelValuesStream",
74 serverSend: func(stream grpc.ServerStream) error {
75 return SendLabelValuesStream(stream.(Ingester_LabelValuesStreamServer), &LabelValuesStreamResponse{})
76 },
77 clientRecv: func(ctx context.Context, client IngesterClient) error {
78 stream, err := client.LabelValuesStream(ctx, &LabelValuesRequest{})

Callers

nothing calls this directly

Calls 15

QueryStreamMethod · 0.95
LabelNamesStreamMethod · 0.95
LabelValuesStreamMethod · 0.95
PollFunction · 0.92
IsGRPCContextCanceledFunction · 0.92
SendQueryStreamFunction · 0.85
SendLabelNamesStreamFunction · 0.85
SendLabelValuesStreamFunction · 0.85
RegisterIngesterServerFunction · 0.85
NewIngesterClientFunction · 0.85

Tested by

no test coverage detected