From c3c8cfb2da2a89521f0a043f4ef8613590f843fe Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Wed, 27 May 2015 16:01:18 -0700 Subject: [PATCH] fix tests --- test/end2end_test.go | 6 ++--- transport/http2_client.go | 4 ++-- transport/transport_test.go | 48 ------------------------------------- 3 files changed, 5 insertions(+), 53 deletions(-) diff --git a/test/end2end_test.go b/test/end2end_test.go index cc475cfb..cf1e2915 100644 --- a/test/end2end_test.go +++ b/test/end2end_test.go @@ -797,11 +797,11 @@ func testExceedMaxStreamsLimit(t *testing.T, e env) { defer tearDown(s, cc) // Perform an unary RPC to make sure the new settings were propagated to the client. if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}); err != nil { - t.Fatalf("fhaof") + t.Fatalf("%v.EmptyCall(_, _) = _, %v, want _, ", tc, err) } // Initiate the 1st stream if _, err := tc.StreamingInputCall(context.Background()); err != nil { - t.Fatalf("faf") + t.Fatalf("%v.StreamingInputCall(_) = %v, want ", tc, err) } var wg sync.WaitGroup wg.Add(1) @@ -809,7 +809,7 @@ func testExceedMaxStreamsLimit(t *testing.T, e env) { // The 2nd stream should block until its deadline exceeds. ctx, _ := context.WithTimeout(context.Background(), time.Second) if _, err := tc.StreamingInputCall(ctx); grpc.Code(err) != codes.DeadlineExceeded { - t.Fatalf("1414") + t.Fatalf("%v.StreamingInputCall(%v) = _, %v, want error code %d", tc, ctx, err, codes.DeadlineExceeded) } wg.Done() }() diff --git a/transport/http2_client.go b/transport/http2_client.go index 00a16720..d776f503 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -572,8 +572,8 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame) { switch s.ID { case http2.SettingMaxConcurrentStreams: // TODO(zhaoq): This is a hack to avoid significant refactoring of the - // code to deal with int32 overflow. Have a better way to handle this - // later. + // code to deal with the unrealistic int32 overflow. Probably will try + // to find a better way to handle this later. if v > math.MaxInt32 { v = math.MaxInt32 } diff --git a/transport/transport_test.go b/transport/transport_test.go index adbb3e00..fafbbf23 100644 --- a/transport/transport_test.go +++ b/transport/transport_test.go @@ -299,54 +299,6 @@ func TestClientMix(t *testing.T) { } } -func TestExceedMaxStreamsLimit(t *testing.T) { - server, ct := setUp(t, 0, 1, normal) - defer func() { - ct.Close() - server.stop() - }() - callHdr := &CallHdr{ - Host: "localhost", - Method: "foo.Small", - } - // Creates the 1st stream and keep it alive. - _, err1 := ct.NewStream(context.Background(), callHdr) - if err1 != nil { - t.Fatalf("failed to open stream: %v", err1) - } - // Creates the 2nd stream. It has chance to succeed when the settings - // frame from the server has not received at the client. - s, err2 := ct.NewStream(context.Background(), callHdr) - if err2 != nil { - se, ok := err2.(StreamError) - if !ok { - t.Fatalf("Received unexpected error %v", err2) - } - if se.Code != codes.Unavailable { - t.Fatalf("Got error code: %d, want: %d", se.Code, codes.Unavailable) - } - return - } - // If the 2nd stream is created successfully, sends the request. - if err := ct.Write(s, expectedRequest, &Options{Last: true, Delay: false}); err != nil { - t.Fatalf("failed to send data: %v", err) - } - // The 2nd stream was rejected by the server via a reset. - p := make([]byte, len(expectedResponse)) - _, recvErr := io.ReadFull(s, p) - if recvErr != io.EOF || s.StatusCode() != codes.Unavailable { - t.Fatalf("Error: %v, StatusCode: %d; want , %d", recvErr, s.StatusCode(), codes.Unavailable) - } - // Server's setting has been received. From now on, new stream will be rejected instantly. - _, err3 := ct.NewStream(context.Background(), callHdr) - if err3 == nil { - t.Fatalf("Received unexpected , want an error with code %d", codes.Unavailable) - } - if se, ok := err3.(StreamError); !ok || se.Code != codes.Unavailable { - t.Fatalf("Got: %v, want a StreamError with error code %d", err3, codes.Unavailable) - } -} - func TestLargeMessage(t *testing.T) { server, ct := setUp(t, 0, math.MaxUint32, normal) callHdr := &CallHdr{