Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlakyFix: TestZk2Topo #14162

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions go/vt/topo/zk2topo/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
"fmt"
"path"
"testing"
"time"

"github.com/stretchr/testify/require"

"vitess.io/vitess/go/testfiles"
"vitess.io/vitess/go/vt/topo"
Expand Down Expand Up @@ -51,14 +54,25 @@ func TestZk2Topo(t *testing.T) {
// Note we exercise the observer feature here by passing in
// the same server twice, with a "|" separator.
ts, err := topo.OpenServer("zk2", serverAddr+"|"+serverAddr, globalRoot)
if err != nil {
t.Fatalf("OpenServer() failed: %v", err)
}
if err := ts.CreateCellInfo(context.Background(), test.LocalCellName, &topodatapb.CellInfo{
ServerAddress: serverAddr,
Root: cellRoot,
}); err != nil {
t.Fatalf("CreateCellInfo() failed: %v", err)
require.NoError(t, err, "OpenServer() failed")
// We retry creating the cell info until we no longer get a connection error.
timeout := time.After(15 * time.Second)
for {
err = ts.CreateCellInfo(context.Background(), test.LocalCellName, &topodatapb.CellInfo{
ServerAddress: serverAddr,
Root: cellRoot,
})
if err == nil {
break
}
select {
case <-timeout:
t.Fatalf("Timedout creating cell info - %v", err)
return nil
default:
require.ErrorContainsf(t, err, "could not connect to a server", "Received an error that isn't a connection error")
time.Sleep(1 * time.Second)
}
}

return ts
Expand Down
Loading