TestKeepaliveClientFrequency creates a server which expects at most 1 client ping for every 100 ms, while the client is configured to send a ping every 50 ms. So, this configuration should end up with the client transport being closed. But we had a bug wherein the client was sending one ping every [
(t *testing.T)
| 428 | // explicitly makes sure the fix works and the client sends a ping every [Time] |
| 429 | // period. |
| 430 | func (s) TestKeepaliveClientFrequency(t *testing.T) { |
| 431 | grpctest.ExpectError("Client received GoAway with error code ENHANCE_YOUR_CALM and debug data equal to ASCII \"too_many_pings\"") |
| 432 | |
| 433 | serverConfig := &ServerConfig{ |
| 434 | BufferPool: mem.DefaultBufferPool(), |
| 435 | KeepalivePolicy: keepalive.EnforcementPolicy{ |
| 436 | MinTime: 100 * time.Millisecond, |
| 437 | PermitWithoutStream: true, |
| 438 | }, |
| 439 | } |
| 440 | clientOptions := ConnectOptions{ |
| 441 | BufferPool: mem.DefaultBufferPool(), |
| 442 | KeepaliveParams: keepalive.ClientParameters{ |
| 443 | Time: 50 * time.Millisecond, |
| 444 | Timeout: time.Second, |
| 445 | PermitWithoutStream: true, |
| 446 | }, |
| 447 | } |
| 448 | server, client, cancel := setUpWithOptions(t, 0, serverConfig, normal, clientOptions) |
| 449 | defer func() { |
| 450 | client.Close(fmt.Errorf("closed manually by test")) |
| 451 | server.stop() |
| 452 | cancel() |
| 453 | }() |
| 454 | |
| 455 | if err := waitForGoAwayTooManyPings(client); err != nil { |
| 456 | t.Fatal(err) |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | // TestKeepaliveServerEnforcementWithAbusiveClientNoRPC verifies that the |
| 461 | // server closes a client transport when it sends too many keepalive pings |
nothing calls this directly
no test coverage detected