Skip to content

Commit 48eef9c

Browse files
committed
test: fix TestStructuredAuthenticationConfigReload flake by handling expected network errors
Signed-off-by: Anish Ramasekar <[email protected]>
1 parent 1ce98e3 commit 48eef9c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/integration/apiserver/oidc/egress_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ package oidc
1818

1919
import (
2020
"context"
21+
"errors"
2122
"io"
2223
"net"
2324
"net/http"
24-
"strings"
2525
"sync"
2626
"sync/atomic"
2727
"testing"
2828
"time"
2929

30+
utilnet "k8s.io/apimachinery/pkg/util/net"
3031
"k8s.io/apimachinery/pkg/util/wait"
3132
)
3233

@@ -86,15 +87,15 @@ func runEgressProxy(t testing.TB, udsName string, ready chan<- struct{}) {
8687

8788
go func() {
8889
_, err := io.Copy(backendConn, requestHijackedConn)
89-
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
90+
if err != nil && !utilnet.IsProbableEOF(err) {
9091
t.Errorf("unexpected writer error: %v", err)
9192
}
9293
close(writerComplete)
9394
}()
9495

9596
go func() {
9697
_, err := io.Copy(requestHijackedConn, backendConn)
97-
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
98+
if err != nil && !utilnet.IsProbableEOF(err) {
9899
t.Errorf("unexpected reader error: %v", err)
99100
}
100101
close(readerComplete)
@@ -116,7 +117,9 @@ func runEgressProxy(t testing.TB, udsName string, ready chan<- struct{}) {
116117
}
117118

118119
err := server.Shutdown(context.Background())
119-
t.Logf("shutdown exit error: %v", err)
120+
if err != nil && !utilnet.IsProbableEOF(err) {
121+
t.Logf("shutdown exit error: %v", err)
122+
}
120123
})
121124

122125
var once sync.Once
@@ -147,5 +150,7 @@ func runEgressProxy(t testing.TB, udsName string, ready chan<- struct{}) {
147150
}()
148151

149152
err = server.Serve(l)
150-
t.Logf("egress exit error: %v", err)
153+
if err != nil && !errors.Is(err, http.ErrServerClosed) {
154+
t.Logf("egress exit error: %v", err)
155+
}
151156
}

0 commit comments

Comments
 (0)