Skip to content

Commit

Permalink
Containerize integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Feb 7, 2019
1 parent 9c5a9db commit 75ab151
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# Release config file backups
.goreleaser.brew.combined.yml

# Locally built binary
# Locally built binaries
/eksctl
/eksctl-integration-test

# Bad deps
vendor/k8s.io/kops/docs
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ ENV JUNIT_REPORT_DIR $GOPATH/src/github.com/weaveworks/eksctl/test-results/ginkg
RUN mkdir -p "${JUNIT_REPORT_DIR}"

WORKDIR $EKSCTL
RUN make $TEST_TARGET
RUN make lint
RUN make $TEST_TARGET
RUN make build \
&& cp ./eksctl /out/usr/local/bin/eksctl
RUN make build-integration-test \
&& cp ./eksctl-integration-test /out/usr/local/bin/eksctl-integration-test

RUN go build ./vendor/github.com/kubernetes-sigs/aws-iam-authenticator/cmd/aws-iam-authenticator \
&& cp ./aws-iam-authenticator /out/usr/local/bin/aws-iam-authenticator
Expand Down
59 changes: 36 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ EKSCTL_IMAGE ?= weaveworks/eksctl:latest

.DEFAULT_GOAL := help

ifneq ($(TEST_V),)
TEST_ARGS ?= -v -ginkgo.v
endif

ifneq ($(DELETE_TEST_CLUSTER),)
INTEGRATION_TEST_ARGS ?= -eksctl.delete=false
endif

##@ Dependencies

.PHONY: install-build-deps
Expand All @@ -30,34 +22,59 @@ build: ## Build eksctl

##@ Testing & CI

ifneq ($(TEST_V),)
UNIT_TEST_ARGS ?= -v -ginkgo.v
INTEGRATION_TEST_ARGS ?= -test.v -ginkgo.v
endif

.PHONY: ci
ci: lint test ## Target for CI system to invoke to run tests and linting

LINTER ?= gometalinter ./...
.PHONY: lint
lint: ## Run linter over the codebase
@$(GOPATH)/bin/$(LINTER)

.PHONY: test
test: generate ## Run unit test (and re-generate code under test)
@git diff --exit-code pkg/nodebootstrap/assets.go > /dev/null || (git --no-pager diff pkg/nodebootstrap/assets.go; exit 1)
@git diff --exit-code ./pkg/eks/mocks > /dev/null || (git --no-pager diff ./pkg/eks/mocks; exit 1)
@$(MAKE) unit-test
@test -z $(COVERALLS_TOKEN) || $(GOPATH)/bin/goveralls -coverprofile=coverage.out -service=circle-ci
@go test -tags integration ./integration/... -c && rm -f integration.test
@$(MAKE) build-integration-test

.PHONY: unit-test
unit-test: ## Run unit test only
@CGO_ENABLED=0 go test -covermode=count -coverprofile=coverage.out ./pkg/... ./cmd/... $(TEST_ARGS)
@CGO_ENABLED=0 go test -covermode=count -coverprofile=coverage.out ./pkg/... ./cmd/... $(UNIT_TEST_ARGS)

LINTER ?= gometalinter ./...
.PHONY: lint
lint: ## Run linter over the codebase
@$(GOPATH)/bin/$(LINTER)
.PHONY: build-integration-test
build-integration-test: ## Build integration test binary
@go test -tags integration ./integration/... -c -o ./eksctl-integration-test

.PHONY: ci
ci: test lint ## Target for CI system to invoke to run tests and linting
.PHONY: integration-test
integration-test: build build-integration-test ## Run the integration tests (with cluster creation and cleanup)
@./eksctl-integration-test -test.timeout 60m \
$(INTEGRATION_TEST_ARGS)

.PHONY: integration-test-container
integration-test-container: eksctl-image
@docker run \
--env=AWS_PROFILE \
--volume=$(HOME)/.aws:/root/.aws \
$(EKSCTL_IMAGE) \
eksctl-integration-test \
-eksctl.path=/usr/local/bin/eksctl \
-eksctl.kubeconfig=/tmp/kubeconfig \
$(INTEGRATION_TEST_ARGS)

TEST_CLUSTER ?= integration-test-dev
.PHONY: integration-test-dev
integration-test-dev: build ## Run the integration tests without cluster teardown. For use when developing integration tests.
integration-test-dev: build build-integration-test ## Run the integration tests without cluster teardown. For use when developing integration tests.
@./eksctl utils write-kubeconfig \
--auto-kubeconfig \
--name=$(TEST_CLUSTER)
@go test -tags integration -timeout 21m ./integration/... \
$(TEST_ARGS) \
@./eksctl-integration-test -test.timeout 21m \
$(INTEGRATION_TEST_ARGS) \
-args \
-eksctl.cluster=$(TEST_CLUSTER) \
-eksctl.create=false \
Expand All @@ -70,10 +87,6 @@ create-integration-test-dev-cluster: build ## Create a test cluster for use when
delete-integration-test-dev-cluster: build ## Delete the test cluster for use when developing integration tests
@./eksctl delete cluster --name=integration-test-dev --auto-kubeconfig

.PHONY: integration-test
integration-test: build ## Run the integration tests (with cluster creation and cleanup)
@go test -tags integration -timeout 60m ./integration/... $(TEST_ARGS) $(INTEGRATION_TEST_ARGS)

##@ Code Generation

.PHONY: generate
Expand Down

0 comments on commit 75ab151

Please sign in to comment.