From 1944f028d6089d018ea3a3527814cbde7bafa56c Mon Sep 17 00:00:00 2001 From: Alex Robinson Date: Tue, 29 Nov 2016 11:30:32 -0500 Subject: [PATCH] acceptance: Wait in StartCluster until nodes can serve SQL 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. --- pkg/acceptance/util.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/acceptance/util.go b/pkg/acceptance/util.go index d7866a5e5d9d..7a433af33681 100644 --- a/pkg/acceptance/util.go +++ b/pkg/acceptance/util.go @@ -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 }