fix tests
This commit is contained in:
Родитель
a1baa00131
Коммит
c3c8cfb2da
|
@ -797,11 +797,11 @@ func testExceedMaxStreamsLimit(t *testing.T, e env) {
|
||||||
defer tearDown(s, cc)
|
defer tearDown(s, cc)
|
||||||
// Perform an unary RPC to make sure the new settings were propagated to the client.
|
// 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 {
|
if _, err := tc.EmptyCall(context.Background(), &testpb.Empty{}); err != nil {
|
||||||
t.Fatalf("fhaof")
|
t.Fatalf("%v.EmptyCall(_, _) = _, %v, want _, <nil>", tc, err)
|
||||||
}
|
}
|
||||||
// Initiate the 1st stream
|
// Initiate the 1st stream
|
||||||
if _, err := tc.StreamingInputCall(context.Background()); err != nil {
|
if _, err := tc.StreamingInputCall(context.Background()); err != nil {
|
||||||
t.Fatalf("faf")
|
t.Fatalf("%v.StreamingInputCall(_) = %v, want <nil>", tc, err)
|
||||||
}
|
}
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
@ -809,7 +809,7 @@ func testExceedMaxStreamsLimit(t *testing.T, e env) {
|
||||||
// The 2nd stream should block until its deadline exceeds.
|
// The 2nd stream should block until its deadline exceeds.
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
||||||
if _, err := tc.StreamingInputCall(ctx); grpc.Code(err) != codes.DeadlineExceeded {
|
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()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -572,8 +572,8 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
|
||||||
switch s.ID {
|
switch s.ID {
|
||||||
case http2.SettingMaxConcurrentStreams:
|
case http2.SettingMaxConcurrentStreams:
|
||||||
// TODO(zhaoq): This is a hack to avoid significant refactoring of the
|
// 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
|
// code to deal with the unrealistic int32 overflow. Probably will try
|
||||||
// later.
|
// to find a better way to handle this later.
|
||||||
if v > math.MaxInt32 {
|
if v > math.MaxInt32 {
|
||||||
v = math.MaxInt32
|
v = math.MaxInt32
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 <EOF>, %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 <nil>, 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) {
|
func TestLargeMessage(t *testing.T) {
|
||||||
server, ct := setUp(t, 0, math.MaxUint32, normal)
|
server, ct := setUp(t, 0, math.MaxUint32, normal)
|
||||||
callHdr := &CallHdr{
|
callHdr := &CallHdr{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче