Skip to content

Commit

Permalink
Support operator name parameterization
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Arroutbi <[email protected]>
  • Loading branch information
sarroutbi committed Oct 16, 2024
1 parent 6212cbb commit 138d042
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Sanity/key_management_test/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ rlJournalStart
rlRun ". ../../TestHelpers/functions.sh" || rlDie "cannot import function script"
TO_ACTIVE_KEYS=60 #seconds
TO_HIDDEN_KEYS=60 #seconds

if [ -z "${OPERATOR_NAME}" ];
then
OPERATOR_NAME=tang-operator
fi
rlRun "${OC_CLIENT} apply -f ${TANG_FUNCTION_DIR}/reg_test/key_management_test/minimal-keyretrieve/daemons_v1alpha1_pv.yaml" 0 "Creating key management test pv"
rlRun "${OC_CLIENT} apply -f ${TANG_FUNCTION_DIR}/reg_test/key_management_test/minimal-keyretrieve/daemons_v1alpha1_tangserver.yaml" 0 "Creating key management test tangserver"
rlRun "ocpopCheckPodAmount 1 ${TO_POD_START} ${TEST_NAMESPACE}" 0 "Checking 1 POD is started [Timeout=${TO_POD_START} secs.]"
Expand Down Expand Up @@ -75,6 +78,7 @@ rlJournalStart
rlRun "${OC_CLIENT} apply -f ${TANG_FUNCTION_DIR}/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_pv.yaml" 0 "Creating multiple key management test pv"
rlRun "${OC_CLIENT} apply -f ${TANG_FUNCTION_DIR}/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_tangserver.yaml" 0 "Creating multiple key management test tangserver"
sed "s/{{OPERATOR_NAMESPACE}}/${OPERATOR_NAMESPACE}/g" < $TANG_FUNCTION_DIR/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_clusterrolebinding.yaml | ${OC_CLIENT} apply -f -
sed "s/{{OPERATOR_NAME}}/${OPERATOR_NAME}/g" < $TANG_FUNCTION_DIR/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_clusterrolebinding.yaml | ${OC_CLIENT} apply -f -
rlRun "ocpopCheckPodAmount 3 ${TO_POD_START} ${TEST_NAMESPACE}" 0 "Checking 3 PODs are started [Timeout=${TO_POD_START} secs.]"
pod1_name=$(ocpopGetPodNameWithPartialName "tang" "${TEST_NAMESPACE}" 5 1)
pod2_name=$(ocpopGetPodNameWithPartialName "tang" "${TEST_NAMESPACE}" 5 2)
Expand All @@ -88,6 +92,7 @@ rlJournalStart
rlRun "${OC_CLIENT} delete -f ${TANG_FUNCTION_DIR}/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_tangserver.yaml" 0 "Deleting key management test tangserver"
rlRun "${OC_CLIENT} delete -f ${TANG_FUNCTION_DIR}/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_pv.yaml" 0 "Deleting key management test pv"
sed "s/{{OPERATOR_NAMESPACE}}/${OPERATOR_NAMESPACE}/g" < $TANG_FUNCTION_DIR/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_clusterrolebinding.yaml | ${OC_CLIENT} delete -f -
sed "s/{{OPERATOR_NAME}}/${OPERATOR_NAME}/g" < $TANG_FUNCTION_DIR/reg_test/key_management_test/multiple-keyretrieve/daemons_v1alpha1_clusterrolebinding.yaml | ${OC_CLIENT} delete -f -
rlRun "ocpopCheckPodAmount 0 ${TO_POD_STOP} ${TEST_NAMESPACE}" 0 "Checking no PODs continue running [Timeout=${TO_POD_STOP} secs.]"
rlRun "ocpopCheckServiceAmount 0 ${TO_SERVICE_STOP} ${TEST_NAMESPACE}" 0 "Checking no Services continue running [Timeout=${TO_SERVICE_STOP} secs.]"
rlPhaseEnd
Expand Down
6 changes: 5 additions & 1 deletion Sanity/malware_detection_test/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ rlJournalStart
### Bundle Image
analyzeVersion "${installed_version}"
### Container Image
controller_name=$(ocpopGetPodNameWithPartialName "tang-operator-controller" "${OPERATOR_NAMESPACE}" 1)
if [ -z "${OPERATOR_NAME}" ];
then
OPERATOR_NAME=tang-operator
fi
controller_name=$(ocpopGetPodNameWithPartialName "${OPERATOR_NAME}-controller" "${OPERATOR_NAMESPACE}" 1)
rlAssertNotEquals "Checking controller_name is not empty" "${controller_name}" ""
container_image=$("${OC_CLIENT}" -n "${OPERATOR_NAMESPACE}" describe pod "${controller_name}" | grep tang | tr -d ' ' | grep "^Image:" | awk -F "Image:" '{print $2}' | tail -1)
if [[ $container_image == *"registry.redhat.io"* ]];then
Expand Down
8 changes: 6 additions & 2 deletions Setup/clean_cluster/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ rlJournalStart
TO_POD_CONTROLLER_TERMINATE=180 #seconds (for controller to end must wait longer)

rlRun "ocpopCheckClusterStatus" 0 "Checking cluster status"
controller_name=$(ocpopGetPodNameWithPartialName "tang-operator-controller" "${OPERATOR_NAMESPACE}" 1)
if [ -z "${OPERATOR_NAME}" ];
then
OPERATOR_NAME=tang-operator
fi
controller_name=$(ocpopGetPodNameWithPartialName "${OPERATOR_NAME}-controller" "${OPERATOR_NAMESPACE}" 1)
ocpopLogVerbose "Controller name:[${controller_name}]"
if [ -n "${DOWNSTREAM_IMAGE_VERSION}" ] && [ "${DISABLE_BUNDLE_INSTALL_TESTS}" != "1" ];
then
rlRun "uninstallDownstreamVersion" 0 "Uninstalling downstream version"
fi
rlRun "bundleStop" 0 "Cleaning installed tang-operator"
rlRun "ocpopBundleStop" 0 "Cleaning installed operator"
if [ "${DISABLE_BUNDLE_INSTALL_TESTS}" != "1" ] && [ "${DISABLE_BUNDLE_UNINSTALL_TESTS}" != "1" ];
then
test -z "${controller_name}" ||
Expand Down
8 changes: 6 additions & 2 deletions Setup/creating_test_namespace/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ rlJournalStart
rlRun ". ../../TestHelpers/functions.sh" || rlDie "cannot import function script"
ocpopDumpDate
ocpopDumpInfo
if [ -z "${OPERATOR_NAME}" ];
then
OPERATOR_NAME=tang-operator
fi
rlRun "ocpopDumpOpenShiftClientStatus" 0 "Checking OpenshiftClient installation"
rlRun "operator-sdk version > /dev/null" 0 "Checking operator-sdk installation"
rlRun "ocpopCheckClusterStatus" 0 "Checking cluster status"
# In case previous execution was abruptelly stopped:
rlRun "bundleInitialStop" 0 "Cleaning already installed tang-operator (if any)"
rlRun "ocpopBundleInitialStop" 0 "Cleaning already installed operator (if any)"
rlRun "bundleStart" 0 "Installing tang-operator-bundle version:${VERSION}"
rlRun "${OC_CLIENT} apply -f ${TEST_NAMESPACE_FILE}" 0 "Creating test namespace:${TEST_NAMESPACE}"
rlRun "${OC_CLIENT} get namespace ${TEST_NAMESPACE}" 0 "Checking test namespace:${TEST_NAMESPACE}"
Expand All @@ -53,7 +57,7 @@ rlJournalStart

rlPhaseStartTest "Controller runs appropriately"
########## CHECK CONTROLLER RUNS WITH NO ERRORS #########
controller_name=$(ocpopGetPodNameWithPartialName "tang-operator-controller" "${OPERATOR_NAMESPACE}" "${TO_POD_START}")
controller_name=$(ocpopGetPodNameWithPartialName "${OPERATOR_NAME}-controller" "${OPERATOR_NAMESPACE}" "${TO_POD_START}")
rlRun "ocpopCheckPodState Running ${TO_POD_START} ${OPERATOR_NAMESPACE} ${controller_name} Error" 0 \
"Checking controller POD in Running [Timeout=${TO_POD_START} secs.] and not in Error state"
rlRun "ocpopCheckPodStateAndContinues Running ${TIMEOUT_CONTROLLER_KEEPS_RUNNING} ${OPERATOR_NAMESPACE} ${controller_name}" 0 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ roleRef:
name: pod-reader-executor
subjects:
- kind: ServiceAccount
name: tang-operator-controller-manager
name: {{OPERATOR_NAME}}-controller-manager

Check failure on line 12 in TestHelpers/reg_test/key_management_test/minimal-keyretrieve-deletehiddenkeys/daemons_v1alpha1_clusterrolebinding.yaml

View workflow job for this annotation

GitHub Actions / Yamllint

12:28 syntax error: expected <block end>, but found '<scalar>' (syntax)
namespace: {{OPERATOR_NAMESPACE}}

0 comments on commit 138d042

Please sign in to comment.