diff --git a/Makefile b/Makefile index 5646943b64ef..c9205b5b6d24 100644 --- a/Makefile +++ b/Makefile @@ -908,7 +908,7 @@ setup-envtest: $(SETUP_ENVTEST) ## Set up envtest (download kubebuilder assets) .PHONY: test test: $(SETUP_ENVTEST) ## Run unit and integration tests - KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS) + KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -race ./... $(TEST_ARGS) .PHONY: test-verbose test-verbose: ## Run unit and integration tests with verbose flag @@ -916,7 +916,7 @@ test-verbose: ## Run unit and integration tests with verbose flag .PHONY: test-junit test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integration tests and generate a junit report - set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout + set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -race -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout $(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.xml --raw-command cat $(ARTIFACTS)/junit.stdout exit $$(cat $(ARTIFACTS)/junit.exitcode) diff --git a/internal/test/envtest/environment.go b/internal/test/envtest/environment.go index 0151e1ecad1a..9102e3a912bf 100644 --- a/internal/test/envtest/environment.go +++ b/internal/test/envtest/environment.go @@ -41,6 +41,8 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" + "k8s.io/component-base/logs" + logsv1 "k8s.io/component-base/logs/api/v1" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -71,6 +73,11 @@ import ( ) func init() { + if err := logsv1.ValidateAndApply(logs.NewOptions(), nil); err != nil { + klog.ErrorS(err, "Unable to validate and apply log options") + os.Exit(1) + } + logger := klog.Background() // Use klog as the internal logger for this envtest environment. log.SetLogger(logger)