improve the test

This commit is contained in:
iamqizhao
2016-07-19 11:54:35 -07:00
parent 8635e25ebb
commit 01ed6b1741

View File

@ -433,6 +433,7 @@ func TestMaxStreams(t *testing.T) {
} }
done := make(chan struct{}) done := make(chan struct{})
ch := make(chan int) ch := make(chan int)
ready := make(chan struct{})
go func() { go func() {
for { for {
select { select {
@ -441,6 +442,8 @@ func TestMaxStreams(t *testing.T) {
case <-time.After(5 * time.Second): case <-time.After(5 * time.Second):
close(done) close(done)
return return
case <-ready:
return
} }
} }
}() }()
@ -467,6 +470,7 @@ func TestMaxStreams(t *testing.T) {
} }
cc.mu.Unlock() cc.mu.Unlock()
} }
close(ready)
// Close the pending stream so that the streams quota becomes available for the next new stream. // Close the pending stream so that the streams quota becomes available for the next new stream.
ct.CloseStream(s, nil) ct.CloseStream(s, nil)
select { select {
@ -690,7 +694,8 @@ func TestClientWithMisbehavedServer(t *testing.T) {
Host: "localhost", Host: "localhost",
Method: "foo.MaxFrame", Method: "foo.MaxFrame",
} }
for i := 0; i < int(initialConnWindowSize/initialWindowSize+10); i++ { // Make the server flood the traffic to violate flow control window size of the connection.
for {
s, err := ct.NewStream(context.Background(), callHdr) s, err := ct.NewStream(context.Background(), callHdr)
if err != nil { if err != nil {
break break