Skip to content

Commit

Permalink
Use kustomize for setting feature gates in E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Dec 23, 2023
1 parent 37f80c0 commit cec256f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 103 deletions.
36 changes: 23 additions & 13 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:

jobs:
e2e-tests:
name: End-to-end tests
name: End-to-end tests ${{ matrix.group }} on K8s ${{ matrix.kube-version }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand All @@ -21,17 +21,25 @@ jobs:
# All Kubernetes version in between expose the same APIs, hence the operator
# should be compatible with them.
kube-version:
- "1.23"
- "1.29"
group:
- e2e
- e2e-instrumentation
- e2e-upgrade
- e2e-prometheuscr
- e2e-autoscale
- e2e-multi-instrumentation
- e2e-pdb
- e2e-opampbridge
- "1.23"
- "1.29"
include:
- group: e2e
setup: prepare-e2e
- group: e2e-instrumentation
setup: prepare-e2e
- group: e2e-upgrade
setup: prepare-e2e
- group: e2e-autoscale
setup: prepare-e2e
- group: e2e-pdb
setup: prepare-e2e
- group: e2e-opampbridge
setup: prepare-e2e
- group: e2e-prometheuscr
setup: "prepare-e2e-with-featuregates FEATUREGATES=+operator.observability.prometheus"
- group: e2e-multi-instrumentation
setup: "prepare-e2e-with-featuregates FEATUREGATES=+operator.autoinstrumentation.multi-instrumentation"

steps:
- name: Check out code into the Go module directory
Expand All @@ -57,7 +65,9 @@ jobs:
- name: "run tests"
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: make prepare-e2e ${{ matrix.group }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
run: |
make ${{ matrix.setup }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
make ${{ matrix.group }}
- name: "log operator if failed"
if: ${{ failure() }}
Expand Down
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,22 @@ uninstall: manifests kustomize
set-image-controller: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}

.PHONY: add-operator-arg
add-operator-arg: PATCH = [{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"$(OPERATOR_ARG)"}]
add-operator-arg: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit add patch --kind Deployment --patch '$(PATCH)'

.PHONY: add-image-targetallocator
add-image-targetallocator: PATCH = [{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--target-allocator-image=$(TARGETALLOCATOR_IMG)"}]
add-image-targetallocator: manifests kustomize
cd $(KUSTOMIZATION_DIR) && $(KUSTOMIZE) edit add patch --kind Deployment --patch '$(PATCH)'
add-image-targetallocator:
@$(MAKE) add-operator-arg OPERATOR_ARG=--target-allocator-image=$(TARGETALLOCATOR_IMG)

.PHONY: add-image-opampbridge
add-image-opampbridge: PATCH = [{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--operator-opamp-bridge-image=$(OPERATOROPAMPBRIDGE_IMG)"}]
add-image-opampbridge: manifests kustomize
cd $(KUSTOMIZATION_DIR) && $(KUSTOMIZE) edit add patch --kind Deployment --patch '$(PATCH)'
add-image-opampbridge:
@$(MAKE) add-operator-arg OPERATOR_ARG=--operator-opamp-bridge-image=$(OPERATOROPAMPBRIDGE_IMG)

.PHONY: enable-operator-featuregates
enable-operator-featuregates: OPERATOR_ARG = --feature-gates=$(FEATUREGATES)
enable-operator-featuregates: add-operator-arg

# Deploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: deploy
Expand Down Expand Up @@ -245,12 +252,9 @@ e2e-opampbridge:

.PHONY: prepare-e2e
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
OPERATOR_IMG=$(IMG) SED_BIN="$(SED)" ./hack/modify-test-images.sh

.PHONY: enable-prometheus-feature-flag
enable-prometheus-feature-flag:
$(SED) -i "s#--feature-gates=+operator.autoinstrumentation.go#--feature-gates=+operator.autoinstrumentation.go,+operator.observability.prometheus#g" config/default/manager_auth_proxy_patch.yaml

.PHONY: prepare-e2e-with-featuregates
prepare-e2e-with-featuregates: kuttl enable-operator-featuregates prepare-e2e

.PHONY: scorecard-tests
scorecard-tests: operator-sdk
Expand Down Expand Up @@ -461,7 +465,6 @@ reset: kustomize operator-sdk manifests
$(OPERATOR_SDK) bundle validate ./bundle
./hack/ignore-createdAt-bundle.sh
git checkout config/manager/kustomization.yaml
OPERATOR_IMG=local/opentelemetry-operator:e2e DEFAULT_OPERATOR_IMG=$(IMG) SED_BIN="$(SED)" ./hack/modify-test-images.sh

# Build the bundle image, used only for local dev purposes
.PHONY: bundle-build
Expand Down
8 changes: 0 additions & 8 deletions hack/modify-test-images.sh

This file was deleted.

3 changes: 0 additions & 3 deletions kuttl-test-multi-instr.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
artifactsDir: ./tests/_build/artifacts/
commands:
- command: kubectl apply -f ./tests/e2e-multi-instrumentation/manager_deployment_feature_gate.yaml
- command: go run hack/check-operator-ready.go
testDirs:
- ./tests/e2e-multi-instrumentation/
timeout: 150
4 changes: 0 additions & 4 deletions kuttl-test-prometheuscr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
# create a new one when the selector changed.
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
commands:
- command: make undeploy
- command: make enable-prometheus-feature-flag deploy install-prometheus-operator
- command: go run hack/check-operator-ready.go
testDirs:
- ./tests/e2e-prometheuscr/
timeout: 300

This file was deleted.

0 comments on commit cec256f

Please sign in to comment.