(t *testing.T)
| 229 | } |
| 230 | |
| 231 | func (s) TestClientUpdatesParamsAfterGoAway(t *testing.T) { |
| 232 | grpctest.ExpectError("Client received GoAway with error code ENHANCE_YOUR_CALM and debug data equal to ASCII \"too_many_pings\"") |
| 233 | |
| 234 | lis, err := net.Listen("tcp", "localhost:0") |
| 235 | if err != nil { |
| 236 | t.Fatalf("Failed to listen. Err: %v", err) |
| 237 | } |
| 238 | defer lis.Close() |
| 239 | connected := grpcsync.NewEvent() |
| 240 | defer connected.Fire() |
| 241 | go func() { |
| 242 | conn, err := lis.Accept() |
| 243 | if err != nil { |
| 244 | t.Errorf("error accepting connection: %v", err) |
| 245 | return |
| 246 | } |
| 247 | defer conn.Close() |
| 248 | f := http2.NewFramer(conn, conn) |
| 249 | // Start a goroutine to read from the conn to prevent the client from |
| 250 | // blocking after it writes its preface. |
| 251 | go func() { |
| 252 | for { |
| 253 | if _, err := f.ReadFrame(); err != nil { |
| 254 | return |
| 255 | } |
| 256 | } |
| 257 | }() |
| 258 | if err := f.WriteSettings(http2.Setting{}); err != nil { |
| 259 | t.Errorf("error writing settings: %v", err) |
| 260 | return |
| 261 | } |
| 262 | <-connected.Done() |
| 263 | if err := f.WriteGoAway(0, http2.ErrCodeEnhanceYourCalm, []byte("too_many_pings")); err != nil { |
| 264 | t.Errorf("error writing GOAWAY: %v", err) |
| 265 | return |
| 266 | } |
| 267 | }() |
| 268 | addr := lis.Addr().String() |
| 269 | ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| 270 | defer cancel() |
| 271 | cc, err := DialContext(ctx, addr, WithBlock(), WithTransportCredentials(insecure.NewCredentials()), WithKeepaliveParams(keepalive.ClientParameters{ |
| 272 | Time: 10 * time.Second, |
| 273 | Timeout: 100 * time.Millisecond, |
| 274 | PermitWithoutStream: true, |
| 275 | })) |
| 276 | if err != nil { |
| 277 | t.Fatalf("DialContext(%s) failed: %v, want: nil", addr, err) |
| 278 | } |
| 279 | defer cc.Close() |
| 280 | connected.Fire() |
| 281 | for { |
| 282 | time.Sleep(10 * time.Millisecond) |
| 283 | cc.mu.RLock() |
| 284 | v := cc.keepaliveParams.Time |
| 285 | cc.mu.RUnlock() |
| 286 | if v == 20*time.Second { |
| 287 | // Success |
| 288 | return |
nothing calls this directly
no test coverage detected