Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
add controller test to coverage
Browse files Browse the repository at this point in the history
Signed-off-by: huabing zhao <[email protected]>
  • Loading branch information
zhaohuabing committed Feb 26, 2024
1 parent e6e10ac commit 7d54ba2
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BUILD_OPTS ?=
TEST_OPTS ?=
TEST_PKGS ?= $(shell go list ./... | grep -v /e2e)
OUTDIR ?= bin
ENVTEST ?= sigs.k8s.io/controller-runtime/tools/setup-envtest

include env.mk # Load common variables

Expand Down Expand Up @@ -92,11 +93,14 @@ COVERAGE_OPTS ?=
coverage: ## Creates coverage report for all projects
@echo "Running test coverage"
@mkdir -p $(OUTDIR)/$@
@go test $(COVERAGE_OPTS) \
-timeout 30s \
-coverprofile $(OUTDIR)/$@/coverage.out \
-covermode atomic \
$(TEST_PKGS)
@go get $(ENVTEST)
KUBEBUILDER_ASSETS="$(shell go run $(ENVTEST) use -p path)" \
go test $(COVERAGE_OPTS) \
--tags=integration \
-timeout 30s \
-coverprofile $(OUTDIR)/$@/coverage.out \
-covermode atomic \
$(TEST_PKGS)
@go tool cover -html="$(OUTDIR)/$@/coverage.out" -o "$(OUTDIR)/$@/coverage.html"

.PHONY: e2e
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ require (
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/yuin/gopher-lua v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand All @@ -91,6 +92,7 @@ require (
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240215124517-56159419231e // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
Loading

0 comments on commit 7d54ba2

Please sign in to comment.