MCPcopy
hub / github.com/grpc/grpc-go / TestGRPCLBStatsStreamingDrop

Method TestGRPCLBStatsStreamingDrop

balancer/grpclb/grpclb_test.go:1551–1585  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1549}
1550
1551func (s) TestGRPCLBStatsStreamingDrop(t *testing.T) {
1552 if err := runAndCheckStats(t, true, nil, func(cc *grpc.ClientConn) {
1553 testC := testgrpc.NewTestServiceClient(cc)
1554 ctx, cancel := context.WithTimeout(context.Background(), defaultFallbackTimeout)
1555 defer cancel()
1556 // The first non-failfast RPC succeeds, all connections are up.
1557 stream, err := testC.FullDuplexCall(ctx, grpc.WaitForReady(true))
1558 if err != nil {
1559 t.Fatalf("%v.FullDuplexCall(_, _) = _, %v, want _, <nil>", testC, err)
1560 }
1561 for {
1562 if _, err = stream.Recv(); err == io.EOF {
1563 break
1564 }
1565 }
1566 for i := 0; i < countRPC-1; i++ {
1567 stream, err = testC.FullDuplexCall(ctx)
1568 if err == nil {
1569 // Wait for stream to end if err is nil.
1570 for {
1571 if _, err = stream.Recv(); err == io.EOF {
1572 break
1573 }
1574 }
1575 }
1576 }
1577 }, &rpcStats{
1578 numCallsStarted: int64(countRPC),
1579 numCallsFinished: int64(countRPC),
1580 numCallsFinishedKnownReceived: int64(countRPC) / 2,
1581 numCallsDropped: map[string]int64{lbToken: int64(countRPC) / 2},
1582 }); err != nil {
1583 t.Fatal(err)
1584 }
1585}
1586
1587func (s) TestGRPCLBStatsStreamingFailedToSend(t *testing.T) {
1588 if err := runAndCheckStats(t, false, nil, func(cc *grpc.ClientConn) {

Callers

nothing calls this directly

Calls 6

FullDuplexCallMethod · 0.95
WaitForReadyFunction · 0.92
runAndCheckStatsFunction · 0.85
FatalfMethod · 0.65
RecvMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected