Commit 275e978b authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #16241 from smarterclayton/fix_flake_stream

Auto commit by PR queue bot
parents 33d948b5 f79c74e3
...@@ -110,28 +110,31 @@ func TestStreamSurvivesPanic(t *testing.T) { ...@@ -110,28 +110,31 @@ func TestStreamSurvivesPanic(t *testing.T) {
} }
func TestStreamClosedDuringRead(t *testing.T) { func TestStreamClosedDuringRead(t *testing.T) {
ch := make(chan struct{}) for i := 0; i < 25; i++ {
input := "some random text" ch := make(chan struct{})
errs := &errorReader{ input := "some random text"
reads: [][]byte{ errs := &errorReader{
[]byte("some random"), reads: [][]byte{
[]byte(" text"), []byte("some random"),
}, []byte(" text"),
err: fmt.Errorf("stuff"), },
pause: ch, err: fmt.Errorf("stuff"),
} pause: ch,
r := NewReader(errs, false) }
r := NewReader(errs, false)
data, err := readWebSocket(r, t, func(c *websocket.Conn) {
c.Close() data, err := readWebSocket(r, t, func(c *websocket.Conn) {
time.Sleep(time.Millisecond) c.Close()
close(ch) close(ch)
}) })
if !reflect.DeepEqual(data, []byte(input)) { // verify that the data returned by the server on an early close always has a specific error
t.Errorf("unexpected server read: %v", data) if err == nil || !strings.Contains(err.Error(), "use of closed network connection") {
} t.Fatal(err)
if err == nil || !strings.Contains(err.Error(), "use of closed network connection") { }
t.Fatal(err) // verify that the data returned is a strict subset of the input
if !bytes.HasPrefix([]byte(input), data) && len(data) != 0 {
t.Fatalf("unexpected server read: %q", string(data))
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment