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

Support operator name parameterization #108

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions Sanity/DAST_test/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ rlJournalStart
else
API_HOST_PORT=$("${OC_CLIENT}" whoami --show-server | tr -d ' ')
DEFAULT_TOKEN=$("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}" "$("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}"\
| grep ^tang-operator | grep service-account | awk '{print $1}')" -o json | jq -Mr '.data.token' | base64 -d)
| grep ^${OPERATOR_NAMESPACE} | grep service-account | awk '{print $1}')" -o json | jq -Mr '.data.token' | base64 -d)
test -z "${DEFAULT_TOKEN}" &&\
DEFAULT_TOKEN=$("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}" $("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}"\
| grep ^tang-operator | awk '{print $1}') -o json | jq -M '.data | .[]' | tr -d '"')
| grep ^${OPERATOR_NAMESPACE} | awk '{print $1}') -o json | jq -M '.data | .[]' | tr -d '"')
echo "API_HOST_PORT=${API_HOST_PORT}"
echo "DEFAULT_TOKEN=${DEFAULT_TOKEN}"
fi
Expand All @@ -88,9 +88,10 @@ rlJournalStart
pushd rapidast || exit
sed -i s@"kubectl --kubeconfig=./kubeconfig "@"${OC_CLIENT} "@g helm/results.sh
sed -i s@"secContext: '{}'"@"secContext: '{\"privileged\": true}'"@ helm/chart/values.yaml
sed -i s@'tag: "latest"'@'tag: "2.6.0"'@g helm/chart/values.yaml
sed -i s@'tag: "latest"'@'tag: "2.8.0"'@g helm/chart/values.yaml

# 6 - run rapidast on adapted configuration file (via helm)
helm uninstall rapidast
rlRun -c "helm install rapidast ./helm/chart/ --set-file rapidastConfig=${tmpdir}/tang_operator.yaml 2>/dev/null" 0 "Installing rapidast helm chart"
pod_name=$(ocpopGetPodNameWithPartialName "rapidast" "default" 5 1)
rlRun "ocpopCheckPodState Completed ${TO_DAST_POD_COMPLETED} default ${pod_name}" 0 "Checking POD ${pod_name} in Completed state [Timeout=${TO_DAST_POD_COMPLETED} secs.]"
Expand Down
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,6 @@ roleRef:
name: pod-reader-executor
subjects:
- kind: ServiceAccount
name: tang-operator-controller-manager
name: <
{{OPERATOR_NAME}}-controller-manager
namespace: {{OPERATOR_NAMESPACE}}