From 3009c88865f7453b563bde1c60b24b25d75736a4 Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Sun, 7 Dec 2014 15:29:30 -0800 Subject: [PATCH] Check if cluster is up before e2e test without -up Minor usability nuisance: If you run: go run hack/e2e.go -v -test .. and you don't happen to have an up e2e cluster, it should fail fast, rather than chugging through every test and having them fall over. --- hack/e2e.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hack/e2e.go b/hack/e2e.go index 30ca9e9cc8..79f72d1a5e 100644 --- a/hack/e2e.go +++ b/hack/e2e.go @@ -70,7 +70,7 @@ func main() { if *isup { status := 1 - if runBash("get status", `$KUBECFG -server_version`) { + if IsUp() { status = 0 log.Printf("Cluster is UP") } else { @@ -130,12 +130,22 @@ func Up() bool { return true } +// Is the e2e cluster up? +func IsUp() bool { + return runBash("get status", `$KUBECFG -server_version`) +} + func tryUp() bool { return runBash("up", path.Join(*root, "/cluster/kube-up.sh; test-setup;")) } func Test() (failed, passed []string) { defer runBashUntil("watchEvents", "$KUBECTL --watch-only get events")() + + if !IsUp() { + log.Fatal("Testing requested, but e2e cluster not up!") + } + // run tests! dir, err := os.Open(filepath.Join(*root, "hack", "e2e-suite")) if err != nil {