diff --git a/tests/deployments_test.go b/tests/deployments_test.go index ae88a1fe2..17a467fd7 100644 --- a/tests/deployments_test.go +++ b/tests/deployments_test.go @@ -127,14 +127,30 @@ func deploymentSubTest(t *testing.T, mode api.DeploymentMode, engine api.Storage if err != nil { t.Fatal("Unable to create connection to: %v", agent.ID) } - waitUntilVersionUp(dbclient) + + if err := waitUntilVersionUp(dbclient); err != nil { + t.Fatal("Version check failed for: %v", agent.ID) + } } + + var goodResults, noLeaderResults int for _, single := range singles { dbclient, err := arangod.CreateArangodClient(ctx, k8sClient.CoreV1(), deployment, api.ServerGroupAgents, single.ID) if err != nil { t.Fatal("Unable to create connection to: %v", single.ID) } - waitUntilVersionUp(dbclient) + + if err := waitUntilVersionUp(dbclient, true); err == nil { + goodResults++ + } else if driver.IsNoLeader(err) { + noLeaderResults++ + } else { + t.Fatal("Version check failed for: %v", single.ID) + } + } + + if goodResults < 1 || noLeaderResults > 1 { + t.Fatal("Wrong number of results: good %v - noleader %v", goodResults, noLeaderResults) } default: t.Fatalf("DeploymentMode %v is not supported!", mode) diff --git a/tests/test_util.go b/tests/test_util.go index eaac48f02..fa187a3c5 100644 --- a/tests/test_util.go +++ b/tests/test_util.go @@ -207,17 +207,30 @@ func waitUntilClusterHealth(cli driver.Client, predicate func(driver.ClusterHeal // waitUntilVersionUp waits until the arango database responds to // an `/_api/version` request without an error. -func waitUntilVersionUp(cli driver.Client) error { +func waitUntilVersionUp(cli driver.Client, allowNoLeaderResponse ...bool) error { + var noLeaderErr error + allowNoLead := len(allowNoLeaderResponse) > 0 && allowNoLeaderResponse[0] ctx := context.Background() + op := func() error { - if _, err := cli.Version(ctx); err != nil { + if _, err := cli.Version(ctx); allowNoLead && driver.IsNoLeader(err) { + noLeaderErr = err + return nil //return nil to make the retry below pass + } else if err != nil { return maskAny(err) } return nil } + if err := retry.Retry(op, deploymentReadyTimeout); err != nil { return maskAny(err) } + + // noLeadErr updated in op + if noLeaderErr != nil { + return maskAny(noLeaderErr) + } + return nil }