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

Function testServerStats

stats/stats_test.go:829–915  ·  view source on GitHub ↗
(t *testing.T, tc *testConfig, cc *rpcConfig, checkFuncs []func(t *testing.T, d *gotData, e *expectedData))

Source from the content-addressed store, hash-verified

827}
828
829func testServerStats(t *testing.T, tc *testConfig, cc *rpcConfig, checkFuncs []func(t *testing.T, d *gotData, e *expectedData)) {
830 h := &statshandler{}
831 te := newTest(t, tc, nil, []stats.Handler{h})
832 te.startServer(newStatsTestStubServer())
833 defer te.tearDown()
834
835 var (
836 reqs []proto.Message
837 resps []proto.Message
838 err error
839 method string
840
841 isClientStream bool
842 isServerStream bool
843
844 req proto.Message
845 resp proto.Message
846 e error
847 )
848
849 switch cc.callType {
850 case unaryRPC:
851 method = "/grpc.testing.TestService/UnaryCall"
852 req, resp, e = te.doUnaryCall(cc)
853 reqs = []proto.Message{req}
854 resps = []proto.Message{resp}
855 err = e
856 case clientStreamRPC:
857 method = "/grpc.testing.TestService/StreamingInputCall"
858 reqs, resp, e = te.doClientStreamCall(cc)
859 resps = []proto.Message{resp}
860 err = e
861 isClientStream = true
862 case serverStreamRPC:
863 method = "/grpc.testing.TestService/StreamingOutputCall"
864 req, resps, e = te.doServerStreamCall(cc)
865 reqs = []proto.Message{req}
866 err = e
867 isServerStream = true
868 case fullDuplexStreamRPC:
869 method = "/grpc.testing.TestService/FullDuplexCall"
870 reqs, resps, err = te.doFullDuplexCallRoundtrip(cc)
871 isClientStream = true
872 isServerStream = true
873 }
874 if cc.success != (err == nil) {
875 t.Fatalf("cc.success: %v, got error: %v", cc.success, err)
876 }
877 te.cc.Close()
878 te.srv.GracefulStop() // Wait for the server to stop.
879
880 for {
881 h.mu.Lock()
882 if len(h.gotRPC) >= len(checkFuncs) {
883 h.mu.Unlock()
884 break
885 }
886 h.mu.Unlock()

Calls 15

newStatsTestStubServerFunction · 0.85
checkConnStatsFunction · 0.85
checkServerStatsFunction · 0.85
newTestFunction · 0.70
FatalfMethod · 0.65
CloseMethod · 0.65
GracefulStopMethod · 0.65
startServerMethod · 0.45
tearDownMethod · 0.45
doUnaryCallMethod · 0.45
doClientStreamCallMethod · 0.45
doServerStreamCallMethod · 0.45

Tested by

no test coverage detected