-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use setup-envtest to set up envtest for integration tests
Instead of doing downloads for correct os/arch in Makefile, use setup-envtest tool.
- Loading branch information
Showing
6 changed files
with
44 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
K8S_VERSION := 1.27.1 | ||
arch := amd64 | ||
os := $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
testbin_dir := ./.testbin/ | ||
tools_archive := kubebuilder-tools-${K8S_VERSION}-$(os)-$(arch).tar.gz | ||
SHELL := /bin/bash | ||
|
||
elector: | ||
go build -o bin/elector cmd/elector/*.go | ||
|
||
test: | ||
go test ./... -count=1 -coverprofile cover.out -short | ||
|
||
integration_test: kubebuilder | ||
.ONESHELL: | ||
integration_test: | ||
source <(go run sigs.k8s.io/controller-runtime/tools/setup-envtest use -p env $(K8S_VERSION)) | ||
go test ./pkg/election/... -tags=integration -v -count=1 | ||
|
||
kubebuilder: $(testbin_dir)/$(tools_archive) | ||
tar -xzf $(testbin_dir)/$(tools_archive) --strip-components=2 -C $(testbin_dir) | ||
chmod -R +x $(testbin_dir) | ||
|
||
$(testbin_dir)/$(tools_archive): | ||
mkdir -p $(testbin_dir) | ||
curl -L -O --output-dir $(testbin_dir) "https://storage.googleapis.com/kubebuilder-tools/$(tools_archive)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build tools | ||
// +build tools | ||
|
||
package tools | ||
|
||
import ( | ||
_ "sigs.k8s.io/controller-runtime/tools/setup-envtest" | ||
) |