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

Method TestGetMethodConfig

test/end2end_test.go:1113–1198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1111}
1112
1113func (s) TestGetMethodConfig(t *testing.T) {
1114 te := testServiceConfigSetup(t, tcpClearRREnv)
1115 defer te.tearDown()
1116 r := manual.NewBuilderWithScheme("whatever")
1117
1118 te.resolverScheme = r.Scheme()
1119 cc := te.clientConn(grpc.WithResolvers(r))
1120 addrs := []resolver.Address{{Addr: te.srvAddr}}
1121 r.UpdateState(resolver.State{
1122 Addresses: addrs,
1123 ServiceConfig: parseServiceConfig(t, r, `{
1124 "methodConfig": [
1125 {
1126 "name": [
1127 {
1128 "service": "grpc.testing.TestService",
1129 "method": "EmptyCall"
1130 }
1131 ],
1132 "waitForReady": true,
1133 "timeout": ".001s"
1134 },
1135 {
1136 "name": [
1137 {
1138 "service": "grpc.testing.TestService"
1139 }
1140 ],
1141 "waitForReady": false
1142 }
1143 ]
1144}`)})
1145
1146 tc := testgrpc.NewTestServiceClient(cc)
1147
1148 // Make sure service config has been processed by grpc.
1149 for {
1150 if cc.GetMethodConfig("/grpc.testing.TestService/EmptyCall").WaitForReady != nil {
1151 break
1152 }
1153 time.Sleep(time.Millisecond)
1154 }
1155
1156 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
1157 defer cancel()
1158 // The following RPCs are expected to become non-fail-fast ones with 1ms deadline.
1159 var err error
1160 if _, err = tc.EmptyCall(ctx, &testpb.Empty{}); status.Code(err) != codes.DeadlineExceeded {
1161 t.Fatalf("TestService/EmptyCall(_, _) = _, %v, want _, %s", err, codes.DeadlineExceeded)
1162 }
1163
1164 r.UpdateState(resolver.State{Addresses: addrs, ServiceConfig: parseServiceConfig(t, r, `{
1165 "methodConfig": [
1166 {
1167 "name": [
1168 {
1169 "service": "grpc.testing.TestService",
1170 "method": "UnaryCall"

Callers

nothing calls this directly

Calls 12

EmptyCallMethod · 0.95
NewBuilderWithSchemeFunction · 0.92
WithResolversFunction · 0.92
testServiceConfigSetupFunction · 0.85
GetMethodConfigMethod · 0.80
CodeMethod · 0.80
parseServiceConfigFunction · 0.70
SchemeMethod · 0.65
UpdateStateMethod · 0.65
FatalfMethod · 0.65
tearDownMethod · 0.45
clientConnMethod · 0.45

Tested by

no test coverage detected