Skip to content

Commit 9fc2d6b

Browse files
committed
Remove gNMI functionality from e2e tests
e2e tests should only evaluate the correct deployment of the operator as defined by the kubebuilder markers. Hence, in this commit we remove all the gNMI related infrastructure from the e2e tests. The current integration tests with the gNMI test server will be later moved into its own space within the project. The tests will use an `envtest` environment, removing the need to deploy a cluster to evaluate that the workflow from k8s resource to provider payload is correctly implemented. Hence, no need to have it as a module.The standalone main.go and Dockerfile are removed. We relocate the txtar test fixtures from test/e2e/testdata/ to test/gnmi/testdata/, where the gNMI integration tests will live. The default profile in kustomize now has prometheus enabled by default. With this change we can eliminate some code and remove the Makefile targets that modify the profile when running the e2e tests. Allow overriding the Prometheus Operator and cert-manager installation URLs via environment variables PROMETHEUS_OPERATOR_URL and CERT_MANAGER_URL. Signed-off-by: Pujol <enric.pujol@sap.com>
1 parent 046350c commit 9fc2d6b

23 files changed

Lines changed: 234 additions & 527 deletions

‎Makefile‎

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ default: build-all
3636
# Image to use all building/pushing image targets
3737
IMG ?= controller:latest
3838

39+
# E2E test dependency versions
40+
E2E_PROMETHEUS_OPERATOR_VERSION ?= v0.82.2
41+
E2E_CERTMANAGER_VERSION ?= v1.17.2
42+
3943
# CONTAINER_TOOL defines the container tool to be used for building images.
4044
# The default is docker, but it can be overridden to use other tools (i.e. podman or nerdctl).
4145
CONTAINER_TOOL ?= docker
@@ -73,7 +77,7 @@ fmt: FORCE install-gofumpt
7377
@gofumpt -l -w $(shell git ls-files '*.go' | grep -v '^internal/provider/openconfig')
7478

7579
# Run the e2e tests against a k8s cluster.
76-
test-e2e: FORCE
80+
test-e2e: FORCE docker-build
7781
@command -v kind >/dev/null 2>&1 || { \
7882
echo "Kind is not installed. Please install Kind manually."; \
7983
exit 1; \
@@ -82,8 +86,22 @@ test-e2e: FORCE
8286
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
8387
exit 1; \
8488
}
89+
@printf "\e[1;36m>> kind load docker-image $(IMG) --name=$(KIND_CLUSTER)\e[0m\n"
90+
@kind load docker-image $(IMG) --name=$(KIND_CLUSTER)
8591
@printf "\e[1;36m>> go test ./test/e2e/ -v -ginkgo.v\e[0m\n"
86-
@KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
92+
@KIND_CLUSTER=$(KIND_CLUSTER) \
93+
E2E_PROMETHEUS_OPERATOR_VERSION=$(E2E_PROMETHEUS_OPERATOR_VERSION) \
94+
E2E_CERTMANAGER_VERSION=$(E2E_CERTMANAGER_VERSION) \
95+
go test ./test/e2e/ -v -ginkgo.v
96+
97+
# Run gNMI server unit tests
98+
test-gnmi-unit: FORCE
99+
@printf "\e[1;36m>> go test ./test/gnmi/testserver/...\e[0m\n"
100+
@go test ./test/gnmi/testserver/...
101+
102+
# Run gNMI integration tests (envtest-based)
103+
test-gnmi: FORCE test-gnmi-unit
104+
@printf "\e[1;33m>> gNMI integration tests not yet implemented\e[0m\n"
87105

88106
docker-build: FORCE
89107
@printf "\e[1;36m>> $(CONTAINER_TOOL) build --tag=$(IMG) .\e[0m\n"
@@ -108,6 +126,16 @@ undeploy: FORCE install-kustomize
108126
@printf "\e[1;36m>> kustomize build config/default | kubectl delete -f -\e[0m\n"
109127
@kustomize build config/default | kubectl delete --ignore-not-found=true -f -
110128

129+
# Deploy controller for e2e tests
130+
deploy-e2e: FORCE generate install-kustomize
131+
@printf "\e[1;36m>> kustomize build config/default | kubectl apply -f -\e[0m\n"
132+
@kustomize build config/default | kubectl apply -f -
133+
134+
# Undeploy controller for e2e tests
135+
undeploy-e2e: FORCE generate install-kustomize
136+
@printf "\e[1;36m>> kustomize build config/default | kubectl delete -f -\e[0m\n"
137+
@kustomize build config/default | kubectl delete --ignore-not-found=true -f -
138+
111139
# Install CRDs into the k8s cluster
112140
deploy-crds: FORCE generate install-kustomize
113141
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"
@@ -159,16 +187,6 @@ netop-provider:
159187
@printf "\e[1;36m>> ./build/netop-provider --help\e[0m\n"
160188
@./build/netop-provider --help
161189

162-
TEST_SERVER_IMG ?= ghcr.io/ironcore-dev/gnmi-test-server:latest
163-
164-
docker-build-test-gnmi-server: FORCE
165-
@printf "\e[1;36m>> $(CONTAINER_TOOL) build --tag=$(TEST_SERVER_IMG) ./test/gnmi\e[0m\n"
166-
@$(CONTAINER_TOOL) build --tag=$(TEST_SERVER_IMG) ./test/gnmi
167-
168-
docker-run-test-gnmi-server: FORCE docker-build-test-gnmi-server
169-
@printf "\e[1;36m>> $(CONTAINER_TOOL) run -p 8000:8000 -p 9339:9339 $(TEST_SERVER_IMG)\e[0m\n"
170-
@$(CONTAINER_TOOL) run --rm -p 8000:8000 -p 9339:9339 $(TEST_SERVER_IMG)
171-
172190
# TEST_LAB_IMG defines the image to used for packaging the lab tests.
173191
TEST_LAB_IMG ?= ghcr.io/ironcore-dev/network-operator-lab-test:latest
174192

@@ -274,9 +292,9 @@ check: FORCE static-check build/cover.html build-all
274292

275293
generate: install-controller-gen
276294
@printf "\e[1;36m>> controller-gen\e[0m\n"
277-
@controller-gen crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases output:rbac:artifacts:config=config/rbac
278-
@controller-gen object:headerFile="hack/boilerplate.go.txt",year=$(YEAR) paths="./..."
279-
@controller-gen applyconfiguration:headerFile="hack/boilerplate.go.txt" paths="./..."
295+
@controller-gen crd rbac:roleName=manager-role webhook paths="{./api/...,./internal/...,./cmd/...}" output:crd:artifacts:config=config/crd/bases output:rbac:artifacts:config=config/rbac
296+
@controller-gen object:headerFile="hack/boilerplate.go.txt",year=$(YEAR) paths="{./api/...,./internal/...,./cmd/...}"
297+
@controller-gen applyconfiguration:headerFile="hack/boilerplate.go.txt" paths="{./api/...,./internal/...,./cmd/...}"
280298

281299
run-golangci-lint: FORCE install-golangci-lint
282300
@printf "\e[1;36m>> golangci-lint\e[0m\n"

‎Makefile.maker.yaml‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ golangciLint:
3030

3131
shellCheck:
3232
ignorePaths:
33-
- 'docs/node_modules/*'
33+
- "docs/node_modules/*"
3434

3535
goReleaser:
3636
createConfig: true
3737

3838
license:
3939
addHeaders: true
4040
checkDependencies: true
41-
copyright: 'SAP SE or an SAP affiliate company and IronCore contributors'
41+
copyright: "SAP SE or an SAP affiliate company and IronCore contributors"
4242
spdx: Apache-2.0
4343

4444
nix:
@@ -54,7 +54,7 @@ renovate:
5454
- felix-kaestner
5555

5656
testPackages:
57-
except: '/test'
57+
except: "/test"
5858

5959
githubWorkflow:
6060
ci:
@@ -69,12 +69,16 @@ githubWorkflow:
6969
enabled: false
7070

7171
variables:
72-
GO_BUILDENV: 'CGO_ENABLED=0'
72+
GO_BUILDENV: "CGO_ENABLED=0"
7373

7474
verbatim: |
7575
# Image to use all building/pushing image targets
7676
IMG ?= controller:latest
7777
78+
# E2E test dependency versions
79+
E2E_PROMETHEUS_OPERATOR_VERSION ?= v0.82.2
80+
E2ECERTMANAGER_VERSION ?= v1.17.2
81+
7882
# CONTAINER_TOOL defines the container tool to be used for building images.
7983
# The default is docker, but it can be overridden to use other tools (i.e. podman or nerdctl).
8084
CONTAINER_TOOL ?= docker
@@ -124,6 +128,15 @@ verbatim: |
124128
@printf "\e[1;36m>> go test ./test/e2e/ -v -ginkgo.v\e[0m\n"
125129
@KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
126130
131+
# Run gNMI server unit tests
132+
test-gnmi-unit: FORCE
133+
@printf "\e[1;36m>> go test ./test/gnmi/testserver/...\e[0m\n"
134+
@go test ./test/gnmi/testserver/...
135+
136+
# Run gNMI integration tests (envtest-based)
137+
test-gnmi: FORCE test-gnmi-unit
138+
@printf "\e[1;33m>> gNMI integration tests not yet implemented\e[0m\n"
139+
127140
docker-build: FORCE
128141
@printf "\e[1;36m>> $(CONTAINER_TOOL) build --tag=$(IMG) .\e[0m\n"
129142
@$(CONTAINER_TOOL) build --build-arg=BININFO_BUILD_DATE=$(BININFO_BUILD_DATE) --build-arg=BININFO_COMMIT_HASH=$(BININFO_COMMIT_HASH) --build-arg=BININFO_VERSION=$(BININFO_VERSION) --tag=$(IMG) .
@@ -147,6 +160,16 @@ verbatim: |
147160
@printf "\e[1;36m>> kustomize build config/default | kubectl delete -f -\e[0m\n"
148161
@kustomize build config/default | kubectl delete --ignore-not-found=true -f -
149162
163+
# Deploy controller for e2e tests (includes Prometheus)
164+
deploy-e2e: FORCE generate install-kustomize
165+
@printf "\e[1;36m>> kustomize build config/test-e2e | kubectl apply -f -\e[0m\n"
166+
@kustomize build config/test-e2e | kubectl apply -f -
167+
168+
# Deploy controller for e2e tests (includes Prometheus)
169+
undeploy-e2e: FORCE generate install-kustomize
170+
@printf "\e[1;36m>> kustomize build config/test-e2e | kubectl delete -f -\e[0m\n"
171+
@kustomize build config/test-e2e | kubectl delete --ignore-not-found=true -f
172+
150173
# Install CRDs into the k8s cluster
151174
deploy-crds: FORCE generate install-kustomize
152175
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"

‎config/develop/gnmi-test-server.yaml‎

Lines changed: 0 additions & 83 deletions
This file was deleted.

‎config/develop/kustomization.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
resources:
22
- ../default
3-
- gnmi-test-server.yaml
43

54
patches:
65
- path: manager_patch.yaml

‎go.mod‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ require (
1616
github.com/sapcc/go-api-declarations v1.24.0
1717
github.com/stretchr/testify v1.11.1
1818
github.com/tidwall/gjson v1.19.0
19+
github.com/tidwall/sjson v1.2.5
1920
go.uber.org/automaxprocs v1.6.0
2021
go.uber.org/zap v1.28.0
2122
golang.org/x/crypto v0.53.0
22-
golang.org/x/tools v0.47.0
2323
google.golang.org/grpc v1.82.0
2424
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af
2525
k8s.io/api v0.36.0
@@ -109,6 +109,7 @@ require (
109109
golang.org/x/term v0.44.0 // indirect
110110
golang.org/x/text v0.38.0 // indirect
111111
golang.org/x/time v0.15.0 // indirect
112+
golang.org/x/tools v0.47.0 // indirect
112113
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
113114
google.golang.org/genproto/googleapis/api v0.0.0-20260414002931-afd174a4e478 // indirect
114115
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect

‎go.sum‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/e2e/e2e_suite_test.go‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ var (
3030
// with the code source changes to be tested.
3131
const image = "ghcr.io/ironcore-dev/network-operator:latest"
3232

33-
// serverImage is the name of the image which will be built and loaded
34-
// with the gNMI test server.
35-
const serverImage = "ghcr.io/ironcore-dev/gnmi-test-server:latest"
36-
3733
// TestE2E runs the end-to-end (e2e) test suite for the project. These tests execute in an isolated,
3834
// temporary environment to validate project changes with the purposed to be used in CI jobs.
3935
// The default setup requires Kind, builds/loads the Manager Docker image locally, and installs
@@ -45,31 +41,15 @@ func TestE2E(t *testing.T) {
4541
}
4642

4743
var _ = BeforeSuite(func(ctx SpecContext) {
48-
By("Ensure that Prometheus is enabled")
49-
cwd, err := GetProjectDir()
50-
Expect(err).NotTo(HaveOccurred(), "Failed to get project directory")
51-
52-
err = UncommentCode(cwd+"/config/default/kustomization.yaml", "#- ../prometheus", "#")
53-
Expect(err).NotTo(HaveOccurred(), "Failed to enable Prometheus")
54-
5544
By("building the manager(Operator) image")
5645
cmd := exec.CommandContext(ctx, "make", "docker-build", "IMG="+image)
57-
_, err = Run(cmd)
46+
_, err := Run(cmd)
5847
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the manager(Operator) image")
5948

6049
By("loading the manager(Operator) image on Kind")
6150
err = LoadImageToKindClusterWithName(ctx, image)
6251
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the manager(Operator) image into Kind")
6352

64-
By("building the gnmi-test-server image")
65-
cmd = exec.CommandContext(ctx, "make", "docker-build-test-gnmi-server", "TEST_SERVER_IMG="+serverImage)
66-
_, err = Run(cmd)
67-
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the gnmi-test-server image")
68-
69-
By("loading the gnmi-test-server image on Kind")
70-
err = LoadImageToKindClusterWithName(ctx, serverImage)
71-
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to load the gnmi-test-server image into Kind")
72-
7353
// The tests-e2e are intended to run on a temporary cluster that is created and destroyed for testing.
7454
// To prevent errors when tests run in environments with Prometheus or CertManager already installed,
7555
// we check for their presence before execution.

0 commit comments

Comments
 (0)