diff --git a/balancer.go b/balancer.go index fa09318d..2d45eee5 100644 --- a/balancer.go +++ b/balancer.go @@ -1,3 +1,36 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + package grpc import ( diff --git a/clientconn.go b/clientconn.go index 2db6b903..09136204 100644 --- a/clientconn.go +++ b/clientconn.go @@ -335,11 +335,6 @@ func (cc *ClientConn) watchAddrUpdates() error { if err := cc.newAddrConn(addr); err != nil { return err } - /* - cc.mu.Lock() - cc.conns[addr] = ac - cc.mu.Unlock() - */ case naming.Delete: cc.mu.Lock() addr := Address{ diff --git a/test/end2end_test.go b/test/end2end_test.go index ea87c7c3..ccf7cf43 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -598,21 +598,6 @@ func testTimeoutOnDeadServer(t *testing.T, e env) { cc := te.clientConn() tc := testpb.NewTestServiceClient(cc) - //ctx, _ := context.WithTimeout(context.Background(), time.Second) - //if _, err := cc.WaitForStateChange(ctx, grpc.Idle); err != nil { - // t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, ", grpc.Idle, err) - //} - //ctx, _ = context.WithTimeout(context.Background(), time.Second) - //if _, err := cc.WaitForStateChange(ctx, grpc.Connecting); err != nil { - // t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, ", grpc.Connecting, err) - //} - //if state, err := cc.State(); err != nil || state != grpc.Ready { - // t.Fatalf("cc.State() = %s, %v, want %s, ", state, err, grpc.Ready) - //} - //ctx, _ = context.WithTimeout(context.Background(), time.Second) - //if _, err := cc.WaitForStateChange(ctx, grpc.Ready); err != context.DeadlineExceeded { - // t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, %v", grpc.Ready, err, context.DeadlineExceeded) - //} te.srv.Stop() // Set -1 as the timeout to make sure if transportMonitor gets error // notification in time the failure path of the 1st invoke of @@ -621,15 +606,7 @@ func testTimeoutOnDeadServer(t *testing.T, e env) { if _, err := tc.EmptyCall(ctx, &testpb.Empty{}); grpc.Code(err) != codes.DeadlineExceeded { t.Fatalf("TestService/EmptyCall(%v, _) = _, error %v, want _, error code: %d", ctx, err, codes.DeadlineExceeded) } - //ctx, _ = context.WithTimeout(context.Background(), time.Second) - //if _, err := cc.WaitForStateChange(ctx, grpc.Ready); err != nil { - // t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, ", grpc.Ready, err) - //} - //if state, err := cc.State(); err != nil || (state != grpc.Connecting && state != grpc.TransientFailure) { - // t.Fatalf("cc.State() = %s, %v, want %s or %s, ", state, err, grpc.Connecting, grpc.TransientFailure) - //} - //cc.Close() - //awaitNewConnLogOutput() + awaitNewConnLogOutput() } func healthCheck(d time.Duration, cc *grpc.ClientConn, serviceName string) (*healthpb.HealthCheckResponse, error) { @@ -786,25 +763,6 @@ func testEmptyUnaryWithUserAgent(t *testing.T, e env) { defer te.tearDown() cc := te.clientConn() - - // Wait until cc is connected. - //ctx, _ := context.WithTimeout(context.Background(), time.Second) - //if _, err := cc.WaitForStateChange(ctx, grpc.Idle); err != nil { - // t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, ", grpc.Idle, err) - //} - //ctx, _ = context.WithTimeout(context.Background(), time.Second) - //if _, err := cc.WaitForStateChange(ctx, grpc.Connecting); err != nil { - // t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, ", grpc.Connecting, err) - //} - //if state, err := cc.State(); err != nil || state != grpc.Ready { - // t.Fatalf("cc.State() = %s, %v, want %s, ", state, err, grpc.Ready) - //} - /* - ctx, _ = context.WithTimeout(context.Background(), time.Second) - if _, err := cc.WaitForStateChange(ctx, grpc.Ready); err == nil { - t.Fatalf("cc.WaitForStateChange(_, %s) = _, , want _, %v", grpc.Ready, context.DeadlineExceeded) - } - */ tc := testpb.NewTestServiceClient(cc) var header metadata.MD reply, err := tc.EmptyCall(context.Background(), &testpb.Empty{}, grpc.Header(&header)) @@ -816,16 +774,6 @@ func testEmptyUnaryWithUserAgent(t *testing.T, e env) { } te.srv.Stop() - cc.Close() - /* - ctx, _ = context.WithTimeout(context.Background(), 5*time.Second) - if _, err := cc.WaitForStateChange(ctx, grpc.Ready); err != nil { - t.Fatalf("cc.WaitForStateChange(_, %s) = _, %v, want _, ", grpc.Ready, err) - } - if state, err := cc.State(); err != nil || state != grpc.Shutdown { - t.Fatalf("cc.State() = %s, %v, want %s, ", state, err, grpc.Shutdown) - } - */ } func TestFailedEmptyUnary(t *testing.T) {