Files
nomad/e2e/framework/utils.go

22 lines
526 B
Go

package framework
import (
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/testutil"
"testing"
)
// retries is used to control how many times to retry checking if the cluster has a leader yet
const retries = 500
func WaitForLeader(t *testing.T, nomadClient *api.Client) {
statusAPI := nomadClient.Status()
testutil.WaitForResultRetries(retries, func() (bool, error) {
leader, err := statusAPI.Leader()
return leader != "", err
}, func(err error) {
t.Fatalf("failed to find leader: %v", err)
})
}