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

Function testModeChangeServerOption

test/xds/xds_server_integration_test.go:51–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49)
50
51func testModeChangeServerOption(t *testing.T) grpc.ServerOption {
52 // Create a server option to get notified about serving mode changes. We don't
53 // do anything other than throwing a log entry here. But this is required,
54 // since the server code emits a log entry at the default level (which is
55 // ERROR) if no callback is registered for serving mode changes. Our
56 // testLogger fails the test if there is any log entry at ERROR level. It does
57 // provide an ExpectError() method, but that takes a string and it would be
58 // painful to construct the exact error message expected here. Instead this
59 // works just fine.
60 return xds.ServingModeCallback(func(addr net.Addr, args xds.ServingModeChangeArgs) {
61 t.Logf("Serving mode for listener %q changed to %q, err: %v", addr.String(), args.Mode, args.Err)
62 })
63}
64
65// acceptNotifyingListener wraps a listener and notifies users when a server
66// calls the Listener.Accept() method. This can be used to ensure that the

Callers 1

setupGRPCServerFunction · 0.85

Calls 3

ServingModeCallbackFunction · 0.92
LogfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected