diff --git a/.github/workflows/canary-integration-test.yml b/.github/workflows/canary-integration-test.yml index c2e416795..de4839000 100644 --- a/.github/workflows/canary-integration-test.yml +++ b/.github/workflows/canary-integration-test.yml @@ -53,6 +53,9 @@ jobs: - name: deploy cluster run: tests/scripts/github-action-helper.sh deploy_cluster + - name: setup csi-addons + run: tests/scripts/csiaddons.sh setup_csiaddons + - name: wait for prepare pod run: tests/scripts/github-action-helper.sh wait_for_prepare_pod @@ -234,6 +237,11 @@ jobs: - name: check-ownerreferences run: tests/scripts/github-action-helper.sh check_ownerreferences + - name: validate csi-addons + run: | + tests/scripts/csiaddons.sh verify_crd_created + tests/scripts/csiaddons.sh verify_container_is_running + - name: test osd removal jobs run: | kubectl -n rook-ceph delete deploy/rook-ceph-operator diff --git a/tests/scripts/csiaddons.sh b/tests/scripts/csiaddons.sh new file mode 100755 index 000000000..67845c6d8 --- /dev/null +++ b/tests/scripts/csiaddons.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +# Copyright 2024 The Rook Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -xEo pipefail + +CSIADDONS_VERSION="v0.8.0" +CSIADDONS_CRD_NAME="csiaddonsnodes.csiaddons.openshift.io" +CSIADDONS_CONTAINER_NAME="csi-addons" + +function setup_csiaddons() { + echo "setting up csi-addons" + + echo "deploying controller" + kubectl create -f https://raw.githubusercontent.com/csi-addons/kubernetes-csi-addons/$CSIADDONS_VERSION/deploy/controller/crds.yaml + kubectl create -f https://raw.githubusercontent.com/csi-addons/kubernetes-csi-addons/$CSIADDONS_VERSION/deploy/controller/rbac.yaml + kubectl create -f https://raw.githubusercontent.com/csi-addons/kubernetes-csi-addons/$CSIADDONS_VERSION/deploy/controller/setup-controller.yaml + + echo "enabling csi-addons" + kubectl patch cm rook-ceph-operator-config -n rook-ceph --type merge -p '{"data":{"CSI_ENABLE_CSIADDONS":"true"}}' + + echo "Successfully created CSI-Addons" +} + +function verify_crd_created() { + + crds=$(kubectl get crd "$CSIADDONS_CRD_NAME" -o=jsonpath="{.metadata.name}" 2>/dev/null) + + if [ -n "$crds" ]; then + echo "CRD '$CSIADDONS_CRD_NAME' exists." + else + echo "CRD '$CSIADDONS_CRD_NAME' does not exist!" + exit 1 + fi +} + +function verify_container_in_pod_by_label() { + label=$1 + pod=$(kubectl get pods -n rook-ceph -l "$label" -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null) + if ! [ -n "$pod" ]; then + echo "pod with label $label not found!" + exit 1 + fi + + container_status=$(kubectl get pod -n rook-ceph "$pod" -o=jsonpath="{.status.containerStatuses[?(@.name=='$CSIADDONS_CONTAINER_NAME')].ready}" 2>/dev/null) + if [ "$container_status" != "true" ]; then + echo "csi-addons container not found in $pod pod!" + exit 1 + fi + echo "$CSIADDONS_CONTAINER_NAME container is running in $pod" +} + +function verify_container_is_running() { + verify_container_in_pod_by_label app=csi-rbdplugin + verify_container_in_pod_by_label app=csi-rbdplugin-provisioner + verify_container_in_pod_by_label app=csi-cephfsplugin-provisioner +} + +FUNCTION="$1" +shift # remove function arg now that we've recorded it +# call the function with the remainder of the user-provided args +# -e, -E, and -o=pipefail will ensure this script returns a failure if a part of the function fails +$FUNCTION "$@"