Skip to content

Commit 0e60da4

Browse files
authored
Use kustomize for e2e test setup (open-telemetry#2479)
* Use kustomize for setting target allocator image in E2E tests * Use kustomize for setting opamp bridge image in E2E tests * Use kustomize for setting feature gates in E2E tests * Move operator flags to manager manifest
1 parent d0e9896 commit 0e60da4

File tree

18 files changed

+41
-121
lines changed

18 files changed

+41
-121
lines changed

.github/workflows/e2e.yaml

+13-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212

1313
jobs:
1414
e2e-tests:
15-
name: End-to-end tests
15+
name: End-to-end tests ${{ matrix.group }} on K8s ${{ matrix.kube-version }}
1616
runs-on: ubuntu-22.04
1717
strategy:
1818
fail-fast: false
@@ -21,17 +21,22 @@ jobs:
2121
# All Kubernetes version in between expose the same APIs, hence the operator
2222
# should be compatible with them.
2323
kube-version:
24-
- "1.23"
25-
- "1.29"
24+
- "1.23"
25+
- "1.29"
2626
group:
2727
- e2e
2828
- e2e-instrumentation
2929
- e2e-upgrade
30-
- e2e-prometheuscr
3130
- e2e-autoscale
32-
- e2e-multi-instrumentation
3331
- e2e-pdb
3432
- e2e-opampbridge
33+
- e2e-prometheuscr
34+
- e2e-multi-instrumentation
35+
include:
36+
- group: e2e-prometheuscr
37+
setup: "prepare-e2e-with-featuregates FEATUREGATES=+operator.observability.prometheus"
38+
- group: e2e-multi-instrumentation
39+
setup: "prepare-e2e-with-featuregates FEATUREGATES=+operator.autoinstrumentation.multi-instrumentation"
3540

3641
steps:
3742
- name: Check out code into the Go module directory
@@ -57,7 +62,9 @@ jobs:
5762
- name: "run tests"
5863
env:
5964
KUBE_VERSION: ${{ matrix.kube-version }}
60-
run: make prepare-e2e ${{ matrix.group }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
65+
run: |
66+
make ${{ matrix.setup != '' && matrix.setup || 'prepare-e2e' }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
67+
make ${{ matrix.group }}
6168
6269
- name: "log operator if failed"
6370
if: ${{ failure() }}

Makefile

+23-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Current Operator version
2-
VERSION ?= "$(shell git describe --tags | sed 's/^v//')"
2+
VERSION ?= $(shell git describe --tags | sed 's/^v//')
33
VERSION_DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
44
VERSION_PKG ?= "github.com/open-telemetry/opentelemetry-operator/internal/version"
55
OTELCOL_VERSION ?= "$(shell grep -v '\#' versions.txt | grep opentelemetry-collector | awk -F= '{print $$2}')"
66
OPERATOR_VERSION ?= "$(shell grep -v '\#' versions.txt | grep operator= | awk -F= '{print $$2}')"
7-
TARGETALLOCATOR_VERSION ?= "$(shell grep -v '\#' versions.txt | grep targetallocator | awk -F= '{print $$2}')"
7+
TARGETALLOCATOR_VERSION ?= $(shell grep -v '\#' versions.txt | grep targetallocator | awk -F= '{print $$2}')
88
OPERATOR_OPAMP_BRIDGE_VERSION ?= "$(shell grep -v '\#' versions.txt | grep operator-opamp-bridge | awk -F= '{print $$2}')"
99
AUTO_INSTRUMENTATION_JAVA_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-java | awk -F= '{print $$2}')"
1010
AUTO_INSTRUMENTATION_NODEJS_VERSION ?= "$(shell grep -v '\#' versions.txt | grep autoinstrumentation-nodejs | awk -F= '{print $$2}')"
@@ -143,6 +143,23 @@ uninstall: manifests kustomize
143143
set-image-controller: manifests kustomize
144144
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
145145

146+
.PHONY: add-operator-arg
147+
add-operator-arg: PATCH = [{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"$(OPERATOR_ARG)"}]
148+
add-operator-arg: manifests kustomize
149+
cd config/manager && $(KUSTOMIZE) edit add patch --kind Deployment --patch '$(PATCH)'
150+
151+
.PHONY: add-image-targetallocator
152+
add-image-targetallocator:
153+
@$(MAKE) add-operator-arg OPERATOR_ARG=--target-allocator-image=$(TARGETALLOCATOR_IMG)
154+
155+
.PHONY: add-image-opampbridge
156+
add-image-opampbridge:
157+
@$(MAKE) add-operator-arg OPERATOR_ARG=--operator-opamp-bridge-image=$(OPERATOROPAMPBRIDGE_IMG)
158+
159+
.PHONY: enable-operator-featuregates
160+
enable-operator-featuregates: OPERATOR_ARG = --feature-gates=$(FEATUREGATES)
161+
enable-operator-featuregates: add-operator-arg
162+
146163
# Deploy controller in the current Kubernetes context, configured in ~/.kube/config
147164
.PHONY: deploy
148165
deploy: set-image-controller
@@ -239,13 +256,10 @@ e2e-opampbridge:
239256
$(KUTTL) test --config kuttl-test-opampbridge.yaml
240257

241258
.PHONY: prepare-e2e
242-
prepare-e2e: kuttl set-image-controller container container-target-allocator container-operator-opamp-bridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
243-
TARGETALLOCATOR_IMG=$(TARGETALLOCATOR_IMG) OPERATOROPAMPBRIDGE_IMG=$(OPERATOROPAMPBRIDGE_IMG) OPERATOR_IMG=$(IMG) SED_BIN="$(SED)" ./hack/modify-test-images.sh
244-
245-
.PHONY: enable-prometheus-feature-flag
246-
enable-prometheus-feature-flag:
247-
$(SED) -i "s#--feature-gates=+operator.autoinstrumentation.go#--feature-gates=+operator.autoinstrumentation.go,+operator.observability.prometheus#g" config/default/manager_auth_proxy_patch.yaml
259+
prepare-e2e: kuttl set-image-controller add-image-targetallocator add-image-opampbridge container container-target-allocator container-operator-opamp-bridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
248260

261+
.PHONY: prepare-e2e-with-featuregates
262+
prepare-e2e-with-featuregates: kuttl enable-operator-featuregates prepare-e2e
249263

250264
.PHONY: scorecard-tests
251265
scorecard-tests: operator-sdk
@@ -281,7 +295,7 @@ container-operator-opamp-bridge: operator-opamp-bridge
281295
.PHONY: start-kind
282296
start-kind:
283297
ifeq (true,$(START_KIND_CLUSTER))
284-
kind create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG)
298+
kind create cluster --name $(KIND_CLUSTER_NAME) --config $(KIND_CONFIG) || true
285299
endif
286300

287301
.PHONY: install-metrics-server
@@ -456,7 +470,6 @@ reset: kustomize operator-sdk manifests
456470
$(OPERATOR_SDK) bundle validate ./bundle
457471
./hack/ignore-createdAt-bundle.sh
458472
git checkout config/manager/kustomization.yaml
459-
OPERATOR_IMG=local/opentelemetry-operator:e2e TARGETALLOCATOR_IMG=local/opentelemetry-operator-targetallocator:e2e OPERATOROPAMPBRIDGE_IMG=local/opentelemetry-operator-opamp-bridge:e2e DEFAULT_OPERATOR_IMG=$(IMG) DEFAULT_TARGETALLOCATOR_IMG=$(TARGETALLOCATOR_IMG) DEFAULT_OPERATOROPAMPBRIDGE_IMG=$(OPERATOROPAMPBRIDGE_IMG) SED_BIN="$(SED)" ./hack/modify-test-images.sh
460473

461474
# Build the bundle image, used only for local dev purposes
462475
.PHONY: bundle-build

config/default/manager_auth_proxy_patch.yaml

-7
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,3 @@ spec:
2727
requests:
2828
cpu: 5m
2929
memory: 64Mi
30-
- name: manager
31-
args:
32-
- "--metrics-addr=127.0.0.1:8080"
33-
- "--enable-leader-election"
34-
- "--zap-log-level=info"
35-
- "--zap-time-encoding=rfc3339nano"
36-
- "--feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx"

config/manager/manager.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ spec:
2828
spec:
2929
containers:
3030
- args:
31-
- --enable-leader-election
31+
- "--metrics-addr=127.0.0.1:8080"
32+
- "--enable-leader-election"
33+
- "--zap-log-level=info"
34+
- "--zap-time-encoding=rfc3339nano"
35+
- "--feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx"
3236
image: controller
3337
name: manager
3438
livenessProbe:

hack/modify-test-images.sh

-17
This file was deleted.

kuttl-test-multi-instr.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
apiVersion: kuttl.dev/v1beta1
22
kind: TestSuite
33
artifactsDir: ./tests/_build/artifacts/
4-
commands:
5-
- command: kubectl apply -f ./tests/e2e-multi-instrumentation/manager_deployment_feature_gate.yaml
6-
- command: go run hack/check-operator-ready.go
74
testDirs:
85
- ./tests/e2e-multi-instrumentation/
96
timeout: 150

kuttl-test-prometheuscr.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
# create a new one when the selector changed.
1212
apiVersion: kuttl.dev/v1beta1
1313
kind: TestSuite
14-
commands:
15-
- command: make undeploy
16-
- command: make enable-prometheus-feature-flag deploy install-prometheus-operator
17-
- command: go run hack/check-operator-ready.go
1814
testDirs:
1915
- ./tests/e2e-prometheuscr/
2016
timeout: 300

tests/e2e-multi-instrumentation/manager_deployment_feature_gate.yaml

-63
This file was deleted.

tests/e2e-opampbridge/opampbridge/00-install.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ kind: OpAMPBridge
2626
metadata:
2727
name: test
2828
spec:
29-
image: "local/opentelemetry-operator-opamp-bridge:e2e"
3029
endpoint: ws://opamp-server:4320/v1/opamp
3130
capabilities:
3231
AcceptsOpAMPConnectionSettings: true

tests/e2e-prometheuscr/create-sm-prometheus-exporters/08-install.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ spec:
7272
targetAllocator:
7373
serviceAccount: ta
7474
enabled: true
75-
image: "local/opentelemetry-operator-targetallocator:e2e"
7675
prometheusCR:
7776
enabled: true
7877
observability:

tests/e2e/prometheus-config-validation/00-promreceiver-allocatorconfig.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ spec:
2626
mode: statefulset
2727
targetAllocator:
2828
enabled: true
29-
image: "local/opentelemetry-operator-targetallocator:e2e"
3029
serviceAccount: ta
3130
prometheusCR:
3231
enabled: true

tests/e2e/prometheus-config-validation/01-promreceiver-labeldrop.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ spec:
99
mode: statefulset
1010
targetAllocator:
1111
enabled: true
12-
image: "local/opentelemetry-operator-targetallocator:e2e"
1312
serviceAccount: ta
1413
prometheusCR:
1514
enabled: true

tests/e2e/prometheus-config-validation/02-promreceiver-allocatorconfig-extra.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ spec:
77
mode: statefulset
88
targetAllocator:
99
enabled: true
10-
image: "local/opentelemetry-operator-targetallocator:e2e"
1110
serviceAccount: ta
1211
prometheusCR:
1312
enabled: true

tests/e2e/prometheus-config-validation/03-promreceiver-nopromconfig.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ spec:
77
mode: statefulset
88
targetAllocator:
99
enabled: true
10-
image: "local/opentelemetry-operator-targetallocator:e2e"
1110
serviceAccount: ta
1211
prometheusCR:
1312
enabled: true

tests/e2e/smoke-targetallocator/00-install.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ spec:
2727
targetAllocator:
2828
enabled: true
2929
serviceAccount: ta
30-
image: "local/opentelemetry-operator-targetallocator:e2e"
3130
prometheusCR:
3231
enabled: true
3332
config: |

tests/e2e/smoke-targetallocator/01-change-ta-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ spec:
77
targetAllocator:
88
enabled: true
99
serviceAccount: ta
10-
image: "local/opentelemetry-operator-targetallocator:e2e"
1110
prometheusCR:
1211
enabled: true
1312
serviceMonitorSelector:

tests/e2e/targetallocator-features/00-install.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ spec:
4747
storage: 1Gi
4848
targetAllocator:
4949
enabled: true
50-
image: "local/opentelemetry-operator-targetallocator:e2e"
5150
serviceAccount: ta
5251
securityContext:
5352
runAsUser: 1000

tests/e2e/targetallocator-prometheuscr/00-install.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ spec:
104104
targetAllocator:
105105
enabled: true
106106
serviceAccount: ta
107-
image: "local/opentelemetry-operator-targetallocator:e2e"
108107
prometheusCR:
109108
enabled: true
110109
config: |

0 commit comments

Comments
 (0)