Skip to content

Commit 2ddb50c

Browse files
kstrenkovaclaude
andcommitted
Add test-operator KUTTL integration
Add test-operator to install_yamls following the standard operator pattern (manila, horizon, cinder, etc). Provides: - Operator deployment: test_prep, test, test_cleanup - CR deployment: test_deploy_prep, test_deploy_cleanup - KUTTL tests: test_kuttl, test_kuttl_run Usage: make test_kuttl Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 438d8e6 commit 2ddb50c

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,14 @@ TELEMETRY_KUTTL_CONF ?= ${TELEMETRY_KUTTL_BASEDIR}/kuttl-test.yaml
499499
TELEMETRY_KUTTL_NAMESPACE ?= telemetry-kuttl-tests
500500
TELEMETRY_KUTTL_DIR ?= ${TELEMETRY_KUTTL_BASEDIR}/${TELEMETRY_KUTTL_RELPATH}
501501

502+
# Test Operator
503+
TEST_OPERATOR_IMG ?= quay.io/openstack-k8s-operators/test-operator-index:${OPENSTACK_K8S_TAG}
504+
TEST_OPERATOR_REPO ?= https://github.com/openstack-k8s-operators/test-operator.git
505+
TEST_OPERATOR_BRANCH ?= ${OPENSTACK_K8S_BRANCH}
506+
TEST_OPERATOR_KUTTL_CONF ?= ${OPERATOR_BASE_DIR}/test-operator/kuttl-test.yaml
507+
TEST_OPERATOR_KUTTL_DIR ?= ${OPERATOR_BASE_DIR}/test-operator/test/kuttl/tests
508+
TEST_OPERATOR_KUTTL_NAMESPACE ?= test-operator-kuttl-tests
509+
502510
# BMO
503511
BMO_REPO ?= https://github.com/metal3-io/baremetal-operator
504512
BMO_BRANCH ?= release-0.9
@@ -2743,6 +2751,55 @@ telemetry_kuttl: kuttl_common_prep ovn heat heat_deploy certmanager telemetry te
27432751
make kuttl_common_cleanup
27442752
bash scripts/restore-namespace.sh
27452753

2754+
##@ TEST OPERATOR
2755+
.PHONY: test_operator_prep
2756+
test_operator_prep: export IMAGE=${TEST_IMG}
2757+
test_operator_prep: ## creates the files to install the operator using olm
2758+
$(eval $(call vars,$@,test-operator))
2759+
bash scripts/gen-olm.sh
2760+
2761+
.PHONY: test_operator
2762+
test_operator: operator_namespace test_operator_prep ## installs the operator, also runs the prep step. Set TEST_IMG for custom image.
2763+
$(eval $(call vars,$@,test-operator))
2764+
oc apply -f ${OPERATOR_DIR}
2765+
2766+
.PHONY: test_operator_cleanup # This one is already correct
2767+
test_operator_cleanup: ## deletes the operator, but does not cleanup the service resources
2768+
$(eval $(call vars,$@,test-operator))
2769+
bash scripts/operator-cleanup.sh
2770+
${CLEANUP_DIR_CMD} ${OPERATOR_DIR}
2771+
2772+
.PHONY: test_operator_deploy_prep
2773+
test_operator_deploy_prep: export KIND=Tempest
2774+
test_operator_deploy_prep: export REPO=${TEST_REPO}
2775+
test_operator_deploy_prep: export BRANCH=${TEST_BRANCH}
2776+
test_operator_deploy_prep: test_operator_deploy_cleanup ## prepares CR for test-operator
2777+
$(eval $(call vars,$@,test-operator))
2778+
mkdir -p ${OPERATOR_BASE_DIR} ${OPERATOR_DIR} ${DEPLOY_DIR}
2779+
bash scripts/clone-operator-repo.sh
2780+
2781+
.PHONY: test_operator_deploy_cleanup # Already correct
2782+
test_operator_deploy_cleanup: ## cleans up the service instance, Does not affect the operator.
2783+
$(eval $(call vars,$@,test-operator))
2784+
oc kustomize ${DEPLOY_DIR} | oc delete --ignore-not-found=true -f -
2785+
${CLEANUP_DIR_CMD} ${DEPLOY_DIR}
2786+
2787+
.PHONY: test_operator_kuttl_run
2788+
test_operator_kuttl_run: ## runs kuttl tests for the test-operator, assumes that everything needed for running the test was deployed beforehand.
2789+
TEST_OPERATOR_KUTTL_DIR=${TEST_OPERATOR_KUTTL_DIR} kubectl-kuttl test --config ${TEST_OPERATOR_KUTTL_CONF} ${TEST_OPERATOR_KUTTL_DIR} --namespace ${NAMESPACE} $(KUTTL_ARGS)
2790+
2791+
.PHONY: test_operator_kuttl
2792+
test_operator_kuttl: export NAMESPACE = ${TEST_OPERATOR_KUTTL_NAMESPACE}
2793+
# Set the value of $TEST_OPERATOR_KUTTL_NAMESPACE if you want to run test-operator
2794+
# kuttl tests in a namespace different than the default (test-operator-kuttl-tests)
2795+
test_operator_kuttl: kuttl_common_prep test_operator test_operator_deploy_prep
2796+
$(eval $(call vars,$@,test-operator))
2797+
make wait
2798+
make test_operator_kuttl_run
2799+
make deploy_cleanup
2800+
make test_operator_cleanup
2801+
make kuttl_common_cleanup
2802+
27462803
##@ SWIFT
27472804
.PHONY: swift_prep
27482805
swift_prep: export IMAGE=${SWIFT_IMG}

0 commit comments

Comments
 (0)