Remove debugging logs and add license.

This commit is contained in:
iamqizhao 2016-05-16 15:47:46 -07:00
parent aa532d5baf
commit 73ff8375a6
3 changed files with 34 additions and 58 deletions

View File

@ -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 (

View File

@ -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{

View File

@ -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 _, <nil>", 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 _, <nil>", grpc.Connecting, err)
//}
//if state, err := cc.State(); err != nil || state != grpc.Ready {
// t.Fatalf("cc.State() = %s, %v, want %s, <nil>", 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 _, <nil>", 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, <nil>", 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 _, <nil>", 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 _, <nil>", grpc.Connecting, err)
//}
//if state, err := cc.State(); err != nil || state != grpc.Ready {
// t.Fatalf("cc.State() = %s, %v, want %s, <nil>", 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) = _, <nil>, 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 _, <nil>", grpc.Ready, err)
}
if state, err := cc.State(); err != nil || state != grpc.Shutdown {
t.Fatalf("cc.State() = %s, %v, want %s, <nil>", state, err, grpc.Shutdown)
}
*/
}
func TestFailedEmptyUnary(t *testing.T) {