Skip to content

Commit ecee780

Browse files
committed
enable e2e tests with server-side apply feature
Signed-off-by: Erhan Cagirici <[email protected]>
1 parent c5b4b82 commit ecee780

File tree

6 files changed

+32
-23
lines changed

6 files changed

+32
-23
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ GOLANGCILINT_VERSION = 1.55.2
3636
# ====================================================================================
3737
# Setup Kubernetes tools
3838
KIND_VERSION = v0.22.0
39+
KUBECTL_VERSION = v1.29.8
3940
UP_VERSION = v0.28.0
4041
UP_CHANNEL = stable
4142
USE_HELM3 = true
@@ -89,13 +90,15 @@ CROSSPLANE_NAMESPACE = crossplane-system
8990
-include build/makelib/local.xpkg.mk
9091
-include build/makelib/controlplane.mk
9192

92-
# TODO(turkenh): Add "examples/object/object-ssa-owner.yaml" to the list to test the SSA functionality as part of the e2e tests.
93-
# The test is disabled for now because uptest clears the package cache when the provider restarted with the SSA flag.
94-
# Enable after https://github.com/crossplane/uptest/issues/17 is fixed.
93+
UPTEST_VERSION = v1.1.2
9594
UPTEST_EXAMPLE_LIST ?= "examples/object/object.yaml,examples/object/object-watching.yaml"
96-
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
95+
UPTEST_SSA_EXAMPLE_LIST ?= "examples/object/object-ssa-owner.yaml"
96+
uptest: $(UPTEST) $(KUBECTL) $(CHAINSAW) $(CROSSPLANE_CLI)
9797
@$(INFO) running automated tests
98-
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=${CROSSPLANE_NAMESPACE} $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
98+
@E2E_SSA_ENABLED="false" KUBECTL=$(KUBECTL) CHAINSAW=$(CHAINSAW) CROSSPLANE_CLI=$(CROSSPLANE_CLI) CROSSPLANE_NAMESPACE=${CROSSPLANE_NAMESPACE} $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
99+
@$(INFO) running SSA-enabled tests
100+
@E2E_SSA_ENABLED="true" KUBECTL=$(KUBECTL) CHAINSAW=$(CHAINSAW) CROSSPLANE_CLI=$(CROSSPLANE_CLI) CROSSPLANE_NAMESPACE=${CROSSPLANE_NAMESPACE} $(UPTEST) e2e "$(UPTEST_SSA_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
101+
@$(OK) running SSA-enabled tests
99102
@$(OK) running automated tests
100103

101104
local-dev: controlplane.up

cluster/test/setup.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ metadata:
1515
spec:
1616
credentials:
1717
source: InjectedIdentity
18-
EOF
18+
EOF
19+
20+
if [ "${E2E_SSA_ENABLED:-false}" == "true" ]; then
21+
echo "Enabling ssa feature for the provider"
22+
${KUBECTL} patch deploymentruntimeconfig runtimeconfig-provider-kubernetes --type='json' \
23+
-p='[{"op":"replace","path":"/spec/deploymentTemplate/spec/template/spec/containers/0/args", "value":["--debug", "--enable-server-side-apply"]}]'
24+
PROVIDER_DEPLOYMENT_NAME="$(${KUBECTL} -n crossplane-system get deployment -o name | grep provider-kubernetes)"
25+
${KUBECTL} -n crossplane-system wait --for=jsonpath='{.spec.template.spec.containers[0].args[?(@=="--enable-server-side-apply")]}' "$PROVIDER_DEPLOYMENT_NAME"
26+
${KUBECTL} -n crossplane-system rollout status "$PROVIDER_DEPLOYMENT_NAME"
27+
${KUBECTL} -n crossplane-system wait --for=jsonpath='{.status.replicas}'="1" "$PROVIDER_DEPLOYMENT_NAME"
28+
${KUBECTL} -n crossplane-system get pods
29+
fi

examples/object/object-ssa-owner.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ kind: Object
55
metadata:
66
name: sample-service-owner
77
annotations:
8-
uptest.upbound.io/pre-assert-hook: testhooks/enable-ssa.sh
98
uptest.upbound.io/post-assert-hook: testhooks/validate-ssa.sh
109
uptest.upbound.io/timeout: "60"
1110
spec:

examples/object/testhooks/enable-ssa.sh

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

examples/object/testhooks/validate-ssa.sh

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ set -aeuo pipefail
44
# This script is used to validate the ssa feature, triggered by the
55
# uptest framework via `uptest.upbound.io/post-assert-hook`: https://github.com/crossplane/uptest/tree/e64457e2cce153ada54da686c8bf96143f3f6329?tab=readme-ov-file#hooks
66

7-
LABELER_OBJECT="examples/object/object-ssa-labeler.yaml"
8-
${KUBECTL} apply -f ${LABELER_OBJECT}
9-
${KUBECTL} wait -f ${LABELER_OBJECT} --for condition=ready --timeout=1m
7+
# gets the directory of the this test hook script (POSIX-compliant)
8+
# workaround for determining the filepath of the LABELER_OBJECT
9+
# in chainsaw-based uptest v1.x versions
10+
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
1011

11-
if ! ${KUBECTL} get service sample-service -o jsonpath='{.metadata.annotations}' | grep -v "last-applied-configuration"; then # This annotation should not be present when SSA is enabled
12+
LABELER_OBJECT="$script_dir/object-ssa-labeler.yaml"
13+
${KUBECTL} apply -f "${LABELER_OBJECT}"
14+
${KUBECTL} wait -f "${LABELER_OBJECT}" --for condition=ready --timeout=1m
15+
16+
if ${KUBECTL} get service sample-service -o jsonpath='{.metadata.annotations}' | grep "last-applied-configuration"; then # This annotation should not be present when SSA is enabled
1217
echo "SSA validation failed! Annotation 'last-applied-configuration' should not exist when SSA is enabled!"
13-
#exit 1
18+
exit 1
1419
fi
1520
if ! (${KUBECTL} get service sample-service -o jsonpath='{.metadata.labels.some-key}' | grep -q "some-value" && ${KUBECTL} get service sample-service -o jsonpath='{.metadata.labels.another-key}' | grep -q "another-value"); then
1621
echo "SSA validation failed! Labels 'some-key' and 'another-key' from both Objects should exist with values 'some-value' and 'another-value' respectively!"
17-
#exit 1
22+
exit 1
1823
fi
1924
echo "Successfully validated the SSA feature!"
2025

21-
${KUBECTL} delete -f ${LABELER_OBJECT}
22-
23-
echo "Disabling SSA feature for the provider"
24-
${KUBECTL} patch deploymentruntimeconfig runtimeconfig-provider-kubernetes --type='json' -p='[{"op":"replace","path":"/spec/deploymentTemplate/spec/template/spec/containers/0/args", "value":["--debug"]}]'
25-
26+
${KUBECTL} delete -f "${LABELER_OBJECT}"

0 commit comments

Comments
 (0)