Skip to content

Commit

Permalink
acceptance: Wait in StartCluster until nodes can serve SQL
Browse files Browse the repository at this point in the history
Now that there's a delay between when a node starts serving kv and when
it starts serving SQL (due to the SQL migration code path), acceptance
tests that rely on SQL can have a bad time without this.
  • Loading branch information
a-robinson committed Dec 12, 2016
1 parent fdd7aef commit 4cc1a79
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/acceptance/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,21 @@ func StartCluster(ctx context.Context, t *testing.T, cfg cluster.TestConfig) (c
})
}

// Ensure that all nodes are serving SQL by making sure a simple
// read-only query succeeds.
for i := 0; i < c.NumNodes(); i++ {
util.SucceedsSoon(t, func() error {
db, err := gosql.Open("postgres", c.PGUrl(ctx, i))
if err != nil {
return err
}
if _, err := db.Exec("SHOW DATABASES;"); err != nil {
return err
}
return nil
})
}

completed = true
return c
}
Expand Down

0 comments on commit 4cc1a79

Please sign in to comment.