Skip to content

Commit

Permalink
make TestEtcdWithHangLeaderEnableCheck stable
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Apr 16, 2024
1 parent a767a5f commit d78d374
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/utils/etcdutil/etcdutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,10 @@ func checkEtcdWithHangLeader(t *testing.T) error {
etcd2 := MustAddEtcdMember(t, &cfg1, client1)
defer etcd2.Close()
checkMembers(re, client1, []*embed.Etcd{etcd1, etcd2})
time.Sleep(1 * time.Second) // wait for etcd client sync endpoints

// Hang the etcd1 and wait for the client to connect to etcd2.
enableDiscard.Store(true)
time.Sleep(time.Second)
time.Sleep(3 * time.Second)
_, err = EtcdKVGet(client1, "test/key1")
return err
}
Expand Down Expand Up @@ -366,7 +365,8 @@ func ioCopy(ctx context.Context, dst io.Writer, src io.Reader, enableDiscard *at
return nil
default:
if enableDiscard.Load() {
io.Copy(io.Discard, src)
_, err := io.Copy(io.Discard, src)
return err
}
readNum, errRead := src.Read(buffer)
if readNum > 0 {
Expand Down

0 comments on commit d78d374

Please sign in to comment.