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

Method TestKeepaliveClientFrequency

internal/transport/keepalive_test.go:430–458  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

428// explicitly makes sure the fix works and the client sends a ping every [Time]
429// period.
430func (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

Callers

nothing calls this directly

Calls 8

ExpectErrorFunction · 0.92
DefaultBufferPoolFunction · 0.92
setUpWithOptionsFunction · 0.85
CloseMethod · 0.65
ErrorfMethod · 0.65
stopMethod · 0.65
FatalMethod · 0.65

Tested by

no test coverage detected