Skip to content
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

[chore] Change the E2E automation to run the tests in OpenShift #1254

Merged
merged 29 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
72af183
Run the E2E tests in OpenShift
iblancasa Nov 29, 2022
72902e5
Set version for GitHub Actions workflow
iblancasa Nov 29, 2022
9d14c78
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
iblancasa Nov 29, 2022
3718df0
Fix CI
iblancasa Nov 30, 2022
622bb57
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
iblancasa Nov 30, 2022
63e0587
Merge branch 'main' into run-tests-openshift
iblancasa Dec 1, 2022
c14e92d
Apply some changes to simplify the upgrade E2E test
iblancasa Dec 1, 2022
8d7161c
Merge branch 'run-tests-openshift' of github.com:iblancasa/openteleme…
iblancasa Dec 1, 2022
232d84b
Fix CI
iblancasa Dec 1, 2022
319adff
Fix CI
iblancasa Dec 1, 2022
321904f
Merge branch 'main' into run-tests-openshift
iblancasa Dec 1, 2022
147746f
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
iblancasa Dec 1, 2022
f41aab5
Merge branch 'run-tests-openshift' of github.com:iblancasa/openteleme…
iblancasa Dec 12, 2022
2c237e4
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
iblancasa Dec 12, 2022
22ddf82
Install OpenShift routes only if needed
iblancasa Dec 12, 2022
6235504
Trigger Build
iblancasa Dec 14, 2022
a491faf
Remove cert-manager installation from deployment step
iblancasa Dec 14, 2022
9e622a0
Trigger Build
iblancasa Dec 14, 2022
fcee7b6
Ensure the webhook don't fail when kubectl apply
iblancasa Dec 16, 2022
27006d6
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
iblancasa Dec 16, 2022
9a6f905
Fix coding standard issues
iblancasa Dec 16, 2022
f157f61
Fix coding standard issues
iblancasa Dec 16, 2022
273a43d
Increase timeout for golangci
iblancasa Dec 16, 2022
1c20c09
Apply changes requested in CR
iblancasa Dec 19, 2022
1798cf0
Change timeout to 500ms
iblancasa Dec 19, 2022
ab0c2b5
Merge branch 'main' of github.com:open-telemetry/opentelemetry-operat…
iblancasa Dec 20, 2022
fc08b29
Change program file name
iblancasa Dec 20, 2022
430c16b
Do the check without depending on a manifest file
iblancasa Dec 20, 2022
3f67ecb
Change program file name
iblancasa Dec 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: "run tests"
env:
KUBE_VERSION: ${{ matrix.kube-version }}
run: make prepare-e2e e2e e2e-upgrade KUBE_VERSION=$KUBE_VERSION
run: make prepare-e2e e2e e2e-upgrade KUBE_VERSION=$KUBE_VERSION VERSION=e2e

- name: "log operator if failed"
if: ${{ failure() }}
Expand Down
45 changes: 29 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ else
GOTEST_OPTS=-race -v
endif

START_KIND_CLUSTER ?= true

KUBE_VERSION ?= 1.24
KIND_CONFIG ?= kind-$(KUBE_VERSION).yaml

Expand Down Expand Up @@ -115,8 +117,9 @@ set-image-controller: manifests kustomize

# Deploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: deploy
deploy: set-image-controller
deploy: set-image-controller cert-manager
iblancasa marked this conversation as resolved.
Show resolved Hide resolved
$(KUSTOMIZE) build config/default | kubectl apply -f -
kubectl wait --timeout=5m --for=condition=available deployment opentelemetry-operator-controller-manager -n opentelemetry-operator-system

# Undeploy controller in the current Kubernetes context, configured in ~/.kube/config
.PHONY: undeploy
Expand Down Expand Up @@ -162,7 +165,7 @@ e2e:

# end-to-end-test for testing upgrading
.PHONY: e2e-upgrade
e2e-upgrade:
e2e-upgrade: undeploy
iblancasa marked this conversation as resolved.
Show resolved Hide resolved
$(KUTTL) test --config kuttl-test-upgrade.yaml

.PHONY: e2e-log-operator
Expand All @@ -171,38 +174,38 @@ e2e-log-operator:
kubectl get deploy -A

.PHONY: prepare-e2e
prepare-e2e: kuttl set-test-image-vars set-image-controller container container-target-allocator start-kind install-metrics-server load-image-all
mkdir -p tests/_build/crds tests/_build/manifests
$(KUSTOMIZE) build config/default -o tests/_build/manifests/01-opentelemetry-operator.yaml
$(KUSTOMIZE) build config/crd -o tests/_build/crds/
prepare-e2e: kuttl set-image-controller container container-target-allocator start-kind install-metrics-server load-image-all deploy
TARGETALLOCATOR_IMG=$(TARGETALLOCATOR_IMG) ./hack/modify-test-images.sh

.PHONY: scorecard-tests
scorecard-tests: operator-sdk
$(OPERATOR_SDK) scorecard -w=5m bundle || (echo "scorecard test failed" && exit 1)

.PHONY: set-test-image-vars
set-test-image-vars:
$(eval IMG=local/opentelemetry-operator:e2e)
$(eval TARGETALLOCATOR_IMG=local/opentelemetry-operator-targetallocator:e2e)

# Build the container image, used only for local dev purposes
# buildx is used to ensure same results for arm based systems (m1/2 chips)
.PHONY: container
container:
docker buildx build --platform linux/${ARCH} -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_DOTNET_VERSION=${AUTO_INSTRUMENTATION_DOTNET_VERSION} .
docker buildx build --load --platform linux/${ARCH} -t ${IMG} --build-arg VERSION_PKG=${VERSION_PKG} --build-arg VERSION=${VERSION} --build-arg VERSION_DATE=${VERSION_DATE} --build-arg OTELCOL_VERSION=${OTELCOL_VERSION} --build-arg TARGETALLOCATOR_VERSION=${TARGETALLOCATOR_VERSION} --build-arg AUTO_INSTRUMENTATION_JAVA_VERSION=${AUTO_INSTRUMENTATION_JAVA_VERSION} --build-arg AUTO_INSTRUMENTATION_NODEJS_VERSION=${AUTO_INSTRUMENTATION_NODEJS_VERSION} --build-arg AUTO_INSTRUMENTATION_PYTHON_VERSION=${AUTO_INSTRUMENTATION_PYTHON_VERSION} --build-arg AUTO_INSTRUMENTATION_DOTNET_VERSION=${AUTO_INSTRUMENTATION_DOTNET_VERSION} .

# Push the container image, used only for local dev purposes
.PHONY: container-push
container-push:
docker push ${IMG}

.PHONY: container-target-allocator-push
container-target-allocator-push:
docker push ${TARGETALLOCATOR_IMG}

.PHONY: container-target-allocator
container-target-allocator:
docker buildx build --platform linux/${ARCH} -t ${TARGETALLOCATOR_IMG} cmd/otel-allocator
docker buildx build --load --platform linux/${ARCH} -t ${TARGETALLOCATOR_IMG} cmd/otel-allocator

.PHONY: start-kind
start-kind:
ifeq (true,$(START_KIND_CLUSTER))
kind create cluster --config $(KIND_CONFIG)
endif

.PHONY: install-metrics-server
install-metrics-server:
Expand All @@ -212,12 +215,22 @@ install-metrics-server:
load-image-all: load-image-operator load-image-target-allocator

.PHONY: load-image-operator
load-image-operator:
kind load docker-image local/opentelemetry-operator:e2e
load-image-operator: container
ifeq (true,$(START_KIND_CLUSTER))
kind load docker-image $(IMG)
else
$(MAKE) container-push
endif


.PHONY: load-image-target-allocator
load-image-target-allocator:
kind load docker-image ${TARGETALLOCATOR_IMG}
load-image-target-allocator: container-target-allocator
ifeq (true,$(START_KIND_CLUSTER))
kind load docker-image $(TARGETALLOCATOR_IMG)
else
$(MAKE) container-target-allocator-push
endif


.PHONY: cert-manager
cert-manager: cmctl
Expand Down
17 changes: 13 additions & 4 deletions hack/install-metrics-server.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/bash

# Install metrics-server on kind clusters for autoscale tests. Note: This is not needed for minikube,
# Install metrics-server on kind clusters for autoscale tests.
# Note: This is not needed for minikube,
# you can just add --addons "metrics-server" to the start command.
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl patch deployment -n kube-system metrics-server --type "json" -p '[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": --kubelet-insecure-tls}]'
kubectl wait --for=condition=available deployment/metrics-server -n kube-system --timeout=5m


if [[ "$(kubectl api-resources)" =~ "openshift" ]]; then
echo "Connected to an OpenShift cluster. metrics-server installation is not needed"
elif [[ "$(kubectl get deployment metrics-server -n kube-system 2>&1 )" =~ "NotFound" ]]; then
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
kubectl patch deployment -n kube-system metrics-server --type "json" -p '[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": --kubelet-insecure-tls}]'
kubectl wait --for=condition=available deployment/metrics-server -n kube-system --timeout=5m
else
echo "metrics-server is installed. Skipping installation"
fi
4 changes: 4 additions & 0 deletions hack/modify-test-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sed -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/smoke-targetallocator/00-install.yaml
sed -i "s#local/opentelemetry-operator-targetallocator:e2e#${TARGETALLOCATOR_IMG}#g" tests/e2e/targetallocator-features/00-install.yaml
7 changes: 2 additions & 5 deletions kuttl-test-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@
# create a new one when the selector changed.
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
crdDir: ./tests/_build/crds/
artifactsDir: ./tests/_build/artifacts/
kindContainers:
- local/opentelemetry-operator:e2e
- ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:v0.49.0
commands:
- command: make cert-manager
iblancasa marked this conversation as resolved.
Show resolved Hide resolved
- command: kubectl apply -f ./tests/e2e-upgrade/upgrade-test/opentelemetry-operator-v0.49.0.yaml
- command: kubectl rollout status -w deployment/opentelemetry-operator-controller-manager -n opentelemetry-operator-system
- command: sleep 60s
- command: kubectl wait --timeout=5m --for=condition=available deployment opentelemetry-operator-controller-manager -n opentelemetry-operator-system
- command: sleep 10
iblancasa marked this conversation as resolved.
Show resolved Hide resolved
testDirs:
- ./tests/e2e-upgrade/
timeout: 300
8 changes: 0 additions & 8 deletions kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
crdDir: ./tests/_build/crds/
artifactsDir: ./tests/_build/artifacts/
kindContainers:
- local/opentelemetry-operator:e2e
commands:
- command: make cert-manager
- command: kubectl apply -f ./tests/_build/manifests/01-opentelemetry-operator.yaml
- command: kubectl wait --timeout=5m --for=condition=available deployment opentelemetry-operator-controller-manager -n opentelemetry-operator-system
- command: sleep 5s
testDirs:
- ./tests/e2e/
timeout: 150
5 changes: 2 additions & 3 deletions tests/e2e-upgrade/upgrade-test/01-upgrade-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- command: kubectl apply -f ../../_build/manifests/01-opentelemetry-operator.yaml
- command: kubectl rollout status -w deployment/opentelemetry-operator-controller-manager -n opentelemetry-operator-system
- command: sleep 60s
- script: cd ../../../ && make deploy VERSION=e2e
- command: sleep 10
iblancasa marked this conversation as resolved.
Show resolved Hide resolved