Skip to content

Commit 1f235c8

Browse files
knight42liggitt
authored andcommitted
test(apiserver): deflake TestClientReceivedGOAWAY
protect `localAddr` from concurrent read and write Signed-off-by: knight42 <[email protected]>
1 parent 6125e6b commit 1f235c8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

staging/src/k8s.io/apiserver/pkg/server/filters/goaway_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func TestClientReceivedGOAWAY(t *testing.T) {
342342

343343
for _, tc := range cases {
344344
t.Run(tc.name, func(t *testing.T) {
345+
var mu sync.Mutex
345346
// localAddr indicates how many TCP connection set up
346347
localAddr := make([]string, 0)
347348

@@ -350,7 +351,10 @@ func TestClientReceivedGOAWAY(t *testing.T) {
350351
if err != nil {
351352
t.Fatalf("unexpect connection err: %v", err)
352353
}
354+
355+
mu.Lock()
353356
localAddr = append(localAddr, conn.LocalAddr().String())
357+
mu.Unlock()
354358
return
355359
})
356360
if err != nil {

0 commit comments

Comments
 (0)