mirror of https://github.com/k3s-io/k3s
Merge pull request #16241 from smarterclayton/fix_flake_stream
Auto commit by PR queue botpull/6/head
commit
275e978b90
|
@ -110,6 +110,7 @@ func TestStreamSurvivesPanic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestStreamClosedDuringRead(t *testing.T) {
|
||||
for i := 0; i < 25; i++ {
|
||||
ch := make(chan struct{})
|
||||
input := "some random text"
|
||||
errs := &errorReader{
|
||||
|
@ -124,15 +125,17 @@ func TestStreamClosedDuringRead(t *testing.T) {
|
|||
|
||||
data, err := readWebSocket(r, t, func(c *websocket.Conn) {
|
||||
c.Close()
|
||||
time.Sleep(time.Millisecond)
|
||||
close(ch)
|
||||
})
|
||||
if !reflect.DeepEqual(data, []byte(input)) {
|
||||
t.Errorf("unexpected server read: %v", data)
|
||||
}
|
||||
// verify that the data returned by the server on an early close always has a specific error
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type errorReader struct {
|
||||
|
|
Loading…
Reference in New Issue