Skip to content

Commit ceac9ec

Browse files
committed
Fix for new CRD and operator name parameterization
Signed-off-by: Sergio Arroutbi <[email protected]>
1 parent 6212cbb commit ceac9ec

File tree

102 files changed

+851
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+851
-13
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ COMMON_REPOSITORY_CLONE_DIR?=$(shell pwd)
2727

2828
.PHONY: prepare-library setup sanity clean
2929

30-
all: prepare-library setup sanity clean
30+
all: check-konflux prepare-library setup sanity clean
31+
32+
check-konflux:
33+
@echo "KONFLUX:${KONFLUX}"
34+
@pushd TestHelpers;\
35+
rm reg_test;\
36+
test -z "${KONFLUX}" && ln -s reg_test_ori reg_test || ln -s reg_test_openshift_konflux reg_test;\
37+
popd
3138

3239
prepare-library:
3340
@COMMON_REPOSITORY_CLONE_DIR=$(COMMON_REPOSITORY_CLONE_DIR) $(MAKE) -C Setup/prepare_library

Sanity/DAST_test/runtest.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,25 @@ rlJournalStart
5959

6060
# 3 - download configuration file template
6161
# WARNING: if tang-operator is changed to OpenShift organization, change this
62-
rlRun "curl -o tang_operator.yaml https://raw.githubusercontent.com/latchset/tang-operator/main/tools/scan_tools/tang_operator_template.yaml"
62+
if [ -z "${KONFLUX}" ];
63+
then
64+
rlRun "curl -o tang_operator.yaml https://raw.githubusercontent.com/latchset/tang-operator/main/tools/scan_tools/tang_operator_template.yaml"
65+
else
66+
rlRun "curl -o tang_operator.yaml https://raw.githubusercontent.com/openshift/nbde-tang-server/main/tools/scan_tools/tang_operator_template.yaml"
67+
fi
6368

6469
# 4 - adapt configuration file template (token, machine)
6570
if [ "${EXECUTION_MODE}" == "MINIKUBE" ];
6671
then
6772
API_HOST_PORT=$(minikube ip)
6873
DEFAULT_TOKEN="TEST_TOKEN_UNREQUIRED_IN_MINIKUBE"
6974
else
70-
API_HOST_PORT=$("${OC_CLIENT}" whoami --show-server | tr -d ' ')
75+
API_HOST_PORT=$("${OC_CLIENT}" whoami --show-server | tr -d ' ' | sed -e s@https://@@g)
7176
DEFAULT_TOKEN=$("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}" "$("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}"\
72-
| grep ^tang-operator | grep service-account | awk '{print $1}')" -o json | jq -Mr '.data.token' | base64 -d)
77+
| grep ^${OPERATOR_NAMESPACE} | grep service-account | awk '{print $1}')" -o json | jq -Mr '.data.token' | base64 -d)
7378
test -z "${DEFAULT_TOKEN}" &&\
7479
DEFAULT_TOKEN=$("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}" $("${OC_CLIENT}" get secret -n "${OPERATOR_NAMESPACE}"\
75-
| grep ^tang-operator | awk '{print $1}') -o json | jq -M '.data | .[]' | tr -d '"')
80+
| grep ^${OPERATOR_NAMESPACE} | awk '{print $1}') -o json | jq -M '.data | .[]' | tr -d '"')
7681
echo "API_HOST_PORT=${API_HOST_PORT}"
7782
echo "DEFAULT_TOKEN=${DEFAULT_TOKEN}"
7883
fi
@@ -88,9 +93,10 @@ rlJournalStart
8893
pushd rapidast || exit
8994
sed -i s@"kubectl --kubeconfig=./kubeconfig "@"${OC_CLIENT} "@g helm/results.sh
9095
sed -i s@"secContext: '{}'"@"secContext: '{\"privileged\": true}'"@ helm/chart/values.yaml
91-
sed -i s@'tag: "latest"'@'tag: "2.6.0"'@g helm/chart/values.yaml
96+
sed -i s@'tag: "latest"'@'tag: "2.8.0"'@g helm/chart/values.yaml
9297

9398
# 6 - run rapidast on adapted configuration file (via helm)
99+
helm uninstall rapidast
94100
rlRun -c "helm install rapidast ./helm/chart/ --set-file rapidastConfig=${tmpdir}/tang_operator.yaml 2>/dev/null" 0 "Installing rapidast helm chart"
95101
pod_name=$(ocpopGetPodNameWithPartialName "rapidast" "default" 5 1)
96102
rlRun "ocpopCheckPodState Completed ${TO_DAST_POD_COMPLETED} default ${pod_name}" 0 "Checking POD ${pod_name} in Completed state [Timeout=${TO_DAST_POD_COMPLETED} secs.]"

Sanity/key_management_test/runtest.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ rlJournalStart
3636
rlRun ". ../../TestHelpers/functions.sh" || rlDie "cannot import function script"
3737
TO_ACTIVE_KEYS=60 #seconds
3838
TO_HIDDEN_KEYS=60 #seconds
39-
39+
if [ -z "${OPERATOR_NAME}" ];
40+
then
41+
OPERATOR_NAME=tang-operator
42+
fi
4043
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"
4144
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"
4245
rlRun "ocpopCheckPodAmount 1 ${TO_POD_START} ${TEST_NAMESPACE}" 0 "Checking 1 POD is started [Timeout=${TO_POD_START} secs.]"
@@ -75,6 +78,7 @@ rlJournalStart
7578
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"
7679
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"
7780
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 -
81+
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 -
7882
rlRun "ocpopCheckPodAmount 3 ${TO_POD_START} ${TEST_NAMESPACE}" 0 "Checking 3 PODs are started [Timeout=${TO_POD_START} secs.]"
7983
pod1_name=$(ocpopGetPodNameWithPartialName "tang" "${TEST_NAMESPACE}" 5 1)
8084
pod2_name=$(ocpopGetPodNameWithPartialName "tang" "${TEST_NAMESPACE}" 5 2)
@@ -88,6 +92,7 @@ rlJournalStart
8892
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"
8993
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"
9094
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 -
95+
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 -
9196
rlRun "ocpopCheckPodAmount 0 ${TO_POD_STOP} ${TEST_NAMESPACE}" 0 "Checking no PODs continue running [Timeout=${TO_POD_STOP} secs.]"
9297
rlRun "ocpopCheckServiceAmount 0 ${TO_SERVICE_STOP} ${TEST_NAMESPACE}" 0 "Checking no Services continue running [Timeout=${TO_SERVICE_STOP} secs.]"
9398
rlPhaseEnd

Sanity/malware_detection_test/runtest.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ rlJournalStart
3333
############# MALWARE DETECTION TESTS ############
3434
### Only execute if podman and clamscan commands exist ...
3535
rlPhaseStartTest "Malware Detection Testing"
36+
if [ -z "${OPERATOR_NAME}" ];
37+
then
38+
OPERATOR_NAME=tang-operator
39+
fi
3640
rlRun 'rlImport "common-cloud-orchestration/ocpop-lib"' || rlDie "cannot import ocpop lib"
3741
rlRun ". ../../TestHelpers/functions.sh" || rlDie "cannot import function script"
3842
installed_version=$(ocpopGetVersion)
@@ -42,7 +46,7 @@ rlJournalStart
4246
### Bundle Image
4347
analyzeVersion "${installed_version}"
4448
### Container Image
45-
controller_name=$(ocpopGetPodNameWithPartialName "tang-operator-controller" "${OPERATOR_NAMESPACE}" 1)
49+
controller_name=$(ocpopGetPodNameWithPartialName "${OPERATOR_NAME}-controller" "${OPERATOR_NAMESPACE}" 1)
4650
rlAssertNotEquals "Checking controller_name is not empty" "${controller_name}" ""
4751
container_image=$("${OC_CLIENT}" -n "${OPERATOR_NAMESPACE}" describe pod "${controller_name}" | grep tang | tr -d ' ' | grep "^Image:" | awk -F "Image:" '{print $2}' | tail -1)
4852
if [[ $container_image == *"registry.redhat.io"* ]];then

Setup/clean_cluster/runtest.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ rlJournalStart
3636
TO_POD_CONTROLLER_TERMINATE=180 #seconds (for controller to end must wait longer)
3737

3838
rlRun "ocpopCheckClusterStatus" 0 "Checking cluster status"
39-
controller_name=$(ocpopGetPodNameWithPartialName "tang-operator-controller" "${OPERATOR_NAMESPACE}" 1)
39+
if [ -z "${OPERATOR_NAME}" ];
40+
then
41+
OPERATOR_NAME=tang-operator
42+
fi
43+
controller_name=$(ocpopGetPodNameWithPartialName "${OPERATOR_NAME}-controller" "${OPERATOR_NAMESPACE}" 1)
4044
ocpopLogVerbose "Controller name:[${controller_name}]"
4145
if [ -n "${DOWNSTREAM_IMAGE_VERSION}" ] && [ "${DISABLE_BUNDLE_INSTALL_TESTS}" != "1" ];
4246
then
4347
rlRun "uninstallDownstreamVersion" 0 "Uninstalling downstream version"
4448
fi
45-
rlRun "bundleStop" 0 "Cleaning installed tang-operator"
49+
rlRun "ocpopBundleStop" 0 "Cleaning installed operator"
4650
if [ "${DISABLE_BUNDLE_INSTALL_TESTS}" != "1" ] && [ "${DISABLE_BUNDLE_UNINSTALL_TESTS}" != "1" ];
4751
then
4852
test -z "${controller_name}" ||

Setup/creating_test_namespace/runtest.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ TIMEOUT_CONTROLLER_KEEPS_RUNNING=10
3333

3434
rlJournalStart
3535
rlPhaseStartSetup
36+
if [ -z "${OPERATOR_NAME}" ];
37+
then
38+
export OPERATOR_NAME=tang-operator
39+
fi
3640
rlRun 'rlImport "common-cloud-orchestration/ocpop-lib"' || rlDie "cannot import ocpop lib"
3741
rlRun ". ../../TestHelpers/functions.sh" || rlDie "cannot import function script"
3842
ocpopDumpDate
@@ -41,7 +45,7 @@ rlJournalStart
4145
rlRun "operator-sdk version > /dev/null" 0 "Checking operator-sdk installation"
4246
rlRun "ocpopCheckClusterStatus" 0 "Checking cluster status"
4347
# In case previous execution was abruptelly stopped:
44-
rlRun "bundleInitialStop" 0 "Cleaning already installed tang-operator (if any)"
48+
rlRun "ocpopBundleInitialStop" 0 "Cleaning already installed operator (if any)"
4549
rlRun "bundleStart" 0 "Installing tang-operator-bundle version:${VERSION}"
4650
rlRun "${OC_CLIENT} apply -f ${TEST_NAMESPACE_FILE}" 0 "Creating test namespace:${TEST_NAMESPACE}"
4751
rlRun "${OC_CLIENT} get namespace ${TEST_NAMESPACE}" 0 "Checking test namespace:${TEST_NAMESPACE}"
@@ -53,7 +57,7 @@ rlJournalStart
5357

5458
rlPhaseStartTest "Controller runs appropriately"
5559
########## CHECK CONTROLLER RUNS WITH NO ERRORS #########
56-
controller_name=$(ocpopGetPodNameWithPartialName "tang-operator-controller" "${OPERATOR_NAMESPACE}" "${TO_POD_START}")
60+
controller_name=$(ocpopGetPodNameWithPartialName "${OPERATOR_NAME}-controller" "${OPERATOR_NAMESPACE}" "${TO_POD_START}")
5761
rlRun "ocpopCheckPodState Running ${TO_POD_START} ${OPERATOR_NAMESPACE} ${controller_name} Error" 0 \
5862
"Checking controller POD in Running [Timeout=${TO_POD_START} secs.] and not in Error state"
5963
rlRun "ocpopCheckPodStateAndContinues Running ${TIMEOUT_CONTROLLER_KEEPS_RUNNING} ${OPERATOR_NAMESPACE} ${controller_name}" 0 \

TestHelpers/functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ analyzeVersion() {
290290
}
291291

292292
useUpstreamImages(){
293-
for yaml_file in `find ${TANG_FUNCTION_DIR}/reg_test \( -iname "*.yaml" -o -iname "*.sh" \) -type f -print`
293+
for yaml_file in `find ${TANG_FUNCTION_DIR}/reg_test* \( -iname "*.yaml" -o -iname "*.sh" \) -type f -print`
294294
do
295295
sed -i "s~\"registry.redhat.io/rhel9/tang\"~\"${TANG_IMAGE}\"~g" $yaml_file
296296
done

TestHelpers/reg_test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./reg_test_ori/

0 commit comments

Comments
 (0)