porter: add better warning if missing

This commit is contained in:
Frank Schroeder 2017-10-18 09:31:08 +02:00 committed by Frank Schröder
parent 9dec64dd17
commit 86901b887d

View File

@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"strings"
) )
var DefaultAddr = "127.0.0.1:7965" var DefaultAddr = "127.0.0.1:7965"
@ -23,6 +24,9 @@ func RandomPorts(n int) ([]int, error) {
} }
resp, err := http.Get(fmt.Sprintf("http://%s/%d", addr, n)) resp, err := http.Get(fmt.Sprintf("http://%s/%d", addr, n))
if err != nil { if err != nil {
if strings.Contains(err.Error(), "connection refused") {
return nil, fmt.Errorf("Are you running porter?\nInstall with 'go install github.com/hashicorp/consul/test/porter/cmd/porter'\nThen run 'porter go test ...'\n%s", err)
}
return nil, err return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()