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

Function checkRPCSendOK

balancer/ringhash/ringhash_e2e_test.go:243–255  ·  view source on GitHub ↗

checkRPCSendOK sends num RPCs to the client. It returns a map of backend addresses as keys and number of RPCs sent to this address as value. Abort the test if any RPC fails.

(ctx context.Context, t *testing.T, client testgrpc.TestServiceClient, num int)

Source from the content-addressed store, hash-verified

241// addresses as keys and number of RPCs sent to this address as value. Abort the
242// test if any RPC fails.
243func checkRPCSendOK(ctx context.Context, t *testing.T, client testgrpc.TestServiceClient, num int) map[string]int {
244 t.Helper()
245
246 backendCount := make(map[string]int)
247 for i := 0; i < num; i++ {
248 var remote peer.Peer
249 if _, err := client.EmptyCall(ctx, &testpb.Empty{}, grpc.Peer(&remote)); err != nil {
250 t.Fatalf("rpc EmptyCall() failed: %v", err)
251 }
252 backendCount[remote.Addr.String()]++
253 }
254 return backendCount
255}
256
257// makeUnreachableBackends returns a slice of addresses of backends that close
258// connections as soon as they are established. Useful to simulate servers that

Calls 4

PeerFunction · 0.92
EmptyCallMethod · 0.65
FatalfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected