Fix potentially flaky stream.Read() usage
This commit is contained in:
parent
67e59cb35c
commit
578888e3f3
|
@ -119,7 +119,7 @@ func TestServeStreamHTTP(t *testing.T) {
|
|||
} else {
|
||||
assert.True(t, hasHeader(stream, ResponseMetaHeader, responseMetaHeaderOrigin))
|
||||
body := make([]byte, len(test.expectedBody))
|
||||
_, err = stream.Read(body)
|
||||
_, err = io.ReadFull(stream, body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, test.expectedBody, body)
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ func benchmarkServeStreamHTTPSimple(b *testing.B, test testRequest) {
|
|||
for i := 0; i < b.N; i++ {
|
||||
b.StartTimer()
|
||||
stream, openstreamErr := edgeMux.OpenStream(ctx, headers, nil)
|
||||
_, readBodyErr := stream.Read(body)
|
||||
_, readBodyErr := io.ReadFull(stream, body)
|
||||
b.StopTimer()
|
||||
|
||||
require.NoError(b, openstreamErr)
|
||||
|
|
|
@ -226,7 +226,7 @@ func quicServer(
|
|||
}
|
||||
|
||||
response := make([]byte, len(expectedResponse))
|
||||
if _, err = stream.Read(response); err != io.EOF {
|
||||
if _, err = io.ReadFull(stream, response); err != io.EOF {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -796,7 +796,7 @@ func TestMultipleStreamsWithDictionaries(t *testing.T) {
|
|||
|
||||
expectBody := strings.Replace(htmlBody, "paragraph", path, 1) + strconv.Itoa(index)
|
||||
responseBody := make([]byte, len(expectBody)*2)
|
||||
n, err := stream.Read(responseBody)
|
||||
n, err := stream.Read(responseBody) // potentially flaky because of the partial read
|
||||
if err != nil {
|
||||
errorsC <- fmt.Errorf("stream %d error from (*MuxedStream).Read: %s", stream.streamID, err)
|
||||
return
|
||||
|
|
|
@ -205,7 +205,7 @@ func writeVersion(stream io.Writer) error {
|
|||
|
||||
func readVersion(stream io.Reader) (string, error) {
|
||||
version := make([]byte, protocolVersionLength)
|
||||
_, err := stream.Read(version)
|
||||
_, err := io.ReadFull(stream, version)
|
||||
return string(version), err
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ func quicServer(t *testing.T, serverReady *sync.WaitGroup, conn net.PacketConn)
|
|||
|
||||
func clientRoundTrip(t *testing.T, stream io.ReadWriteCloser, mustWork bool) {
|
||||
response := make([]byte, len(testMsg))
|
||||
_, err := stream.Read(response)
|
||||
_, err := io.ReadFull(stream, response)
|
||||
if !mustWork {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue