MCPcopy
hub / github.com/grafana/dskit / TestGrpcStatsMaxStreamsDisabled

Function TestGrpcStatsMaxStreamsDisabled

middleware/grpc_stats_test.go:266–307  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

264}
265
266func TestGrpcStatsMaxStreamsDisabled(t *testing.T) {
267 reg := prometheus.NewRegistry()
268
269 received := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
270 Name: "received_payload_bytes",
271 Help: "Size of received gRPC messages",
272 Buckets: BodySizeBuckets,
273 }, []string{"method", "route"})
274
275 sent := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
276 Name: "sent_payload_bytes",
277 Help: "Size of sent gRPC",
278 Buckets: BodySizeBuckets,
279 }, []string{"method", "route"})
280
281 inflightRequests := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
282 Name: "inflight_requests",
283 Help: "Current number of inflight requests.",
284 }, []string{"method", "route"})
285
286 stats := NewStatsHandler(reg, received, sent, inflightRequests, false)
287
288 serv := grpc.NewServer(grpc.StatsHandler(stats), grpc.MaxRecvMsgSize(10e6))
289 defer serv.GracefulStop()
290
291 listener, err := net.Listen("tcp", "localhost:0")
292 require.NoError(t, err)
293
294 middleware_test.RegisterEchoServerServer(serv, &halfEcho{log: t.Log})
295
296 go func() {
297 require.NoError(t, serv.Serve(listener))
298 }()
299
300 ctx, cancel1 := context.WithCancel(context.Background())
301 defer cancel1()
302 conn1 := launchConnWithStreams(t, ctx, listener, 10)
303 defer conn1.Close()
304
305 err = testutil.GatherAndCompare(reg, bytes.NewBufferString(``), "grpc_concurrent_streams_by_conn_max")
306 assert.NoError(t, err)
307}
308
309func TestGrpcStatsMaxStreams(t *testing.T) {
310 const (

Callers

nothing calls this directly

Calls 5

RegisterEchoServerServerFunction · 0.92
NewStatsHandlerFunction · 0.85
launchConnWithStreamsFunction · 0.85
WithMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected