mirror of https://github.com/grpc/grpc-go.git
client: make handshake required 'on' by default, not 'hybrid' (#2565)
This commit is contained in:
parent
98a94b0cb0
commit
6cc789b34b
|
@ -95,10 +95,8 @@ func newFuncDialOption(f func(*dialOptions)) *funcDialOption {
|
|||
// WithWaitForHandshake blocks until the initial settings frame is received from
|
||||
// the server before assigning RPCs to the connection.
|
||||
//
|
||||
// Deprecated: this will become the default behavior in the 1.18 release, and
|
||||
// will be removed after the 1.18 release. To override the default behavior in
|
||||
// the 1.18 release, either use this dial option or set the environment
|
||||
// variable GRPC_GO_READY_BEFORE_HANDSHAKE=on.
|
||||
// Deprecated: this is the default behavior, and this option will be removed
|
||||
// after the 1.18 release.
|
||||
func WithWaitForHandshake() DialOption {
|
||||
return newFuncDialOption(func(o *dialOptions) {
|
||||
o.reqHandshake = envconfig.RequireHandshakeOn
|
||||
|
|
|
@ -59,6 +59,7 @@ var (
|
|||
func init() {
|
||||
switch strings.ToLower(os.Getenv(requireHandshakeStr)) {
|
||||
case "on":
|
||||
default:
|
||||
RequireHandshake = RequireHandshakeOn
|
||||
case "off":
|
||||
RequireHandshake = RequireHandshakeOff
|
||||
|
|
|
@ -1655,7 +1655,6 @@ func (s) TestCZSubChannelConnectivityState(t *testing.T) {
|
|||
defer cleanup()
|
||||
r.InitialAddrs([]resolver.Address{{Addr: te.srvAddr}})
|
||||
te.resolverScheme = r.Scheme()
|
||||
te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()}
|
||||
cc := te.clientConn()
|
||||
defer te.tearDown()
|
||||
tc := testpb.NewTestServiceClient(cc)
|
||||
|
@ -1750,7 +1749,6 @@ func (s) TestCZChannelConnectivityState(t *testing.T) {
|
|||
defer cleanup()
|
||||
r.InitialAddrs([]resolver.Address{{Addr: te.srvAddr}})
|
||||
te.resolverScheme = r.Scheme()
|
||||
te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()}
|
||||
cc := te.clientConn()
|
||||
defer te.tearDown()
|
||||
tc := testpb.NewTestServiceClient(cc)
|
||||
|
|
|
@ -986,7 +986,6 @@ func (s) TestTimeoutOnDeadServer(t *testing.T) {
|
|||
|
||||
func testTimeoutOnDeadServer(t *testing.T, e env) {
|
||||
te := newTest(t, e)
|
||||
te.customDialOptions = []grpc.DialOption{grpc.WithWaitForHandshake()}
|
||||
te.userAgent = testAppUA
|
||||
te.declareLogNoise(
|
||||
"transport: http2Client.notifyError got notified that the client transport was broken EOF",
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"google.golang.org/grpc/internal/envconfig"
|
||||
testpb "google.golang.org/grpc/test/grpc_testing"
|
||||
)
|
||||
|
||||
|
@ -106,6 +107,11 @@ func (d *delayConn) Read(b []byte) (n int, err error) {
|
|||
}
|
||||
|
||||
func (s) TestGracefulStop(t *testing.T) {
|
||||
// Set default behavior and restore current setting after test.
|
||||
old := envconfig.RequireHandshake
|
||||
envconfig.RequireHandshake = envconfig.RequireHandshakeOff
|
||||
defer func() { envconfig.RequireHandshake = old }()
|
||||
|
||||
// This test ensures GracefulStop cannot race and break RPCs on new
|
||||
// connections created after GracefulStop was called but before
|
||||
// listener.Accept() returns a "closing" error.
|
||||
|
@ -176,6 +182,7 @@ func (s) TestGracefulStop(t *testing.T) {
|
|||
defer dialCancel()
|
||||
cc, err := grpc.DialContext(ctx, "", grpc.WithInsecure(), grpc.WithBlock(), grpc.WithDialer(d))
|
||||
if err != nil {
|
||||
dlis.allowClientRead()
|
||||
t.Fatalf("grpc.Dial(%q) = %v", lis.Addr().String(), err)
|
||||
}
|
||||
client := testpb.NewTestServiceClient(cc)
|
||||
|
|
|
@ -387,7 +387,6 @@ func (s) TestHealthCheckWithConnClose(t *testing.T) {
|
|||
cc, r, deferFunc, err := setupClient(&clientConfig{
|
||||
balancerName: "round_robin",
|
||||
testHealthCheckFuncWrapper: testHealthCheckFuncWrapper,
|
||||
extraDialOption: []grpc.DialOption{grpc.WithWaitForHandshake()},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -689,7 +688,6 @@ func (s) TestHealthCheckWithoutReportHealthCalled(t *testing.T) {
|
|||
_, r, deferFunc, err := setupClient(&clientConfig{
|
||||
balancerName: "round_robin",
|
||||
testHealthCheckFuncWrapper: testHealthCheckFuncWrapper,
|
||||
extraDialOption: []grpc.DialOption{grpc.WithWaitForHandshake()},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue