diff --git a/Makefile b/Makefile index aba820c6b..1c1b14f22 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,8 @@ GO_DIRS ?= $(shell glide nv -x ) GO_PKGS ?= $(shell glide nv) +BIN_DIR := bin +PATH_WITH_BIN = PATH="$(shell pwd)/$(BIN_DIR):$(PATH)" ROOTFS := rootfs CLIENT := cmd/helm @@ -86,6 +88,18 @@ test-flake8: test-style: @scripts/validate-go.sh +.PHONY: test-e2e +test-e2e: container + $(PATH_WITH_BIN) go test -tags=e2e ./test/e2e -v --manager-image=${DOCKER_REGISTRY}/manager:${TAG} --resourcifier-image=${DOCKER_REGISTRY}/resourcifier:${TAG} --expandybird-image=${DOCKER_REGISTRY}/expandybird:${TAG} + +.PHONY: local-cluster-up +local-cluster-up: + @scripts/kube-up.sh + +.PHONY: local-cluster-down +local-cluster-down: + @scripts/kube-down.sh + HAS_GLIDE := $(shell command -v glide;) HAS_GOLINT := $(shell command -v golint;) HAS_GOVET := $(shell command -v go tool vet;) diff --git a/circle.yml b/circle.yml index c66114bea..a60780894 100644 --- a/circle.yml +++ b/circle.yml @@ -30,4 +30,4 @@ dependencies: test: override: - - cd $GOPATH/src/$IMPORT_PATH && make bootstrap test + - cd $GOPATH/src/$IMPORT_PATH && make info bootstrap test local-cluster-up test-e2e DOCKER_REGISTRY=e2e diff --git a/scripts/docker.sh b/scripts/docker.sh index c6174598a..9cd21f6e6 100644 --- a/scripts/docker.sh +++ b/scripts/docker.sh @@ -44,11 +44,3 @@ delete_container() { docker wait "${container[@]}" &>/dev/null || : docker rm --force --volumes "${container[@]}" &>/dev/null || : } - -dev_registry() { - if docker inspect registry >/dev/null 2>&1; then - docker start registry - else - docker run --restart="always" -d -p 5000:5000 --name registry registry:2 - fi -} diff --git a/test/e2e/command.go b/test/e2e/command.go index fbe22ff9a..c01f18293 100644 --- a/test/e2e/command.go +++ b/test/e2e/command.go @@ -12,6 +12,7 @@ import ( "time" ) +// Cmd provides helpers for command output type Cmd struct { t *testing.T path string diff --git a/test/e2e/helm.go b/test/e2e/helm.go index c1bd743a8..e7af6a21b 100644 --- a/test/e2e/helm.go +++ b/test/e2e/helm.go @@ -4,9 +4,6 @@ package e2e import ( "net/http" - "os" - "path" - "path/filepath" "testing" "time" ) @@ -26,7 +23,7 @@ type HelmContext struct { func NewHelmContext(t *testing.T) *HelmContext { return &HelmContext{ t: t, - Path: RepoRoot() + "/bin/helm", + Path: "helm", Timeout: time.Second * 20, } } @@ -50,7 +47,7 @@ func (h *HelmContext) Run(args ...string) *Cmd { func (h *HelmContext) RunFail(args ...string) *Cmd { cmd := h.newCmd(args...) if status := cmd.exec(); status == nil { - h.t.Fatalf("helm unexpected to fail: %v", args, status) + h.t.Fatalf("helm unexpected to fail: %v %v", args, status) } return cmd } @@ -76,7 +73,3 @@ func (h *HelmContext) Running() bool { //out := h.MustRun("server", "status").Stdout() //return strings.Count(out, "Running") == 5 } - -func RepoRoot() string { - return filepath.Clean(filepath.Join(path.Base(os.Args[0]), "../../..")) -} diff --git a/test/e2e/helm_test.go b/test/e2e/helm_test.go index 691164837..281b0e6a4 100644 --- a/test/e2e/helm_test.go +++ b/test/e2e/helm_test.go @@ -53,15 +53,11 @@ func TestHelm(t *testing.T) { } t.Logf("Using host: %v", helm.Host) - //TODO skip check if running local binaries if !helm.Running() { - t.Error("Helm is not installed") + t.Log("Helm is not installed") + + install(helm) - //TODO wire in flag overides - helm.MustRun("server", "install") - if err := wait(helm.Running); err != nil { - t.Fatal(err) - } } // Add repo if it does not exsit @@ -128,3 +124,21 @@ func helmHost() string { } return os.Getenv("HELM_HOST") } + +func install(h *HelmContext) { + args := []string{"server", "install"} + if *expandybirdImage != "" { + args = append(args, *expandybirdImage) + } + if *managerImage != "" { + args = append(args, *managerImage) + } + if *resourcifierImage != "" { + args = append(args, *resourcifierImage) + } + + h.MustRun(args...) + if err := wait(h.Running); err != nil { + h.t.Fatal(err) + } +}