Skip to content

Commit

Permalink
Flakes: Address flakiness in TestZkConnClosedOnDisconnect (#17194)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord authored Nov 9, 2024
1 parent 8af57c0 commit 655f7fa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions go/vt/topo/zk2topo/zk_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package zk2topo
import (
"context"
"testing"
"time"

"github.com/stretchr/testify/require"
"github.com/z-division/go-zookeeper/zk"
Expand All @@ -42,12 +43,16 @@ func TestZkConnClosedOnDisconnect(t *testing.T) {
oldConn := conn.conn

// force a disconnect
zkd.Shutdown()
zkd.Start()
err = zkd.Shutdown()
require.NoError(t, err)
err = zkd.Start()
require.NoError(t, err)

// do another get to trigger a new connection
_, _, err = conn.Get(context.Background(), "/")
require.NoError(t, err, "Get() failed")
require.Eventually(t, func() bool {
_, _, err = conn.Get(context.Background(), "/")
return err == nil
}, 10*time.Second, 100*time.Millisecond)

// Check that old connection is closed
_, _, err = oldConn.Get("/")
Expand Down

0 comments on commit 655f7fa

Please sign in to comment.