-
Notifications
You must be signed in to change notification settings - Fork 566
CNTRLPLANE-3037,OCPBUGS-78837: Introduce envtest for integration tests #8016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,13 @@ GITLINT := $(TOOLS_BIN_DIR)/$(GITLINT_DIST_DIR)/$(GITLINT_BIN)-bin | |
|
|
||
| PROMTOOL=$(abspath $(TOOLS_BIN_DIR)/promtool) | ||
|
|
||
| # Setup envtest for running tests that require a Kubernetes API server | ||
| # SETUP_ENVTEST_VER is the version of setup-envtest to use, matching the version in hack/tools/go.mod | ||
| KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.34.0 | ||
| SETUP_ENVTEST_VER := release-0.22 | ||
| SETUP_ENVTEST := $(abspath $(TOOLS_BIN_DIR)/setup-envtest) | ||
| ENVTEST_ASSETS_DIR ?= $(abspath $(TOOLS_BIN_DIR)/envtest) | ||
|
|
||
| GO_GCFLAGS ?= -gcflags=all='-N -l' | ||
| GO=GO111MODULE=on GOWORK=off GOFLAGS=-mod=vendor go | ||
| GOWS=GO111MODULE=on GOWORK=$(shell pwd)/hack/workspace/go.work GOFLAGS=-mod=vendor go | ||
|
|
@@ -288,15 +295,25 @@ delegating_client: | |
| mv ./cmd/infra/aws/delegating_client.txt ./cmd/infra/aws/delegating_client.go | ||
| $(GO) fmt ./cmd/infra/aws/delegating_client.go | ||
|
|
||
| # Build setup-envtest from tools folder | ||
| $(SETUP_ENVTEST): $(TOOLS_DIR)/go.mod | ||
| cd $(TOOLS_DIR); $(GO) build -tags=tools -o $(SETUP_ENVTEST) sigs.k8s.io/controller-runtime/tools/setup-envtest | ||
|
|
||
| .PHONY: setup-envtest | ||
| setup-envtest: $(SETUP_ENVTEST) ## Setup envtest binaries (etcd, kube-apiserver) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we'll want to make this plumbing more flexible so we can test with different kas API versions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 Alberto I don't care too much about running individual validation tests on older API servers, but I do think we need to at least take all CRDs and install them on the oldest OCP KAS that managed services are currently using (4.15 to my knowledge) and then as we start to enforce a skew policy and they upgrade to newer releases, we can bump that and hopefully get to a point where it is N-3 consistently going forward
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need ability to test against oldest ocp (4.15) and oldest vanilla kube (to be confirmed).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We currently have 4.17+ OCP KAS in the index, shouldn't be too hard to push 4.15 and 4.16 Upstream goes back to 1.28 (which is equiv to 4.15) so hopefully the minimum vanilla is at least that |
||
| $(eval KUBEBUILDER_ASSETS := $(shell $(SETUP_ENVTEST) use --use-env --bin-dir $(ENVTEST_ASSETS_DIR) -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))) | ||
| @if [ -z "$(KUBEBUILDER_ASSETS)" ]; then echo "Failed to find kubebuilder assets, see errors above"; exit 1; fi | ||
| @echo "KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)" | ||
|
|
||
| # Run tests | ||
| .PHONY: test | ||
|
|
||
| # Determine the number of CPU cores | ||
| NUM_CORES := $(shell getconf _NPROCESSORS_ONLN || echo 1) | ||
|
|
||
| test: generate | ||
| echo "Running tests with $(NUM_CORES) parallel jobs..." | ||
| $(GO) test -race -parallel=$(NUM_CORES) -count=1 -timeout=30m ./... -coverprofile cover.out | ||
| test: generate setup-envtest | ||
| @echo "Running tests with $(NUM_CORES) parallel jobs..." | ||
| KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use --use-env --bin-dir $(ENVTEST_ASSETS_DIR) -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))" $(GO) test -race -parallel=$(NUM_CORES) -count=1 -timeout=30m ./... -coverprofile cover.out | ||
|
|
||
| .PHONY: e2e | ||
| e2e: reqserving-e2e e2ev2 backuprestore-e2e | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4.22 is 1.35, pretty sure we have 1.35 binaries published that you can use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did take 1.34 because that is what hypershift is currently built with. If I should follow OCP k8s version instead I will look into this as part of the above effort to make the setup parametric.