@@ -10,7 +10,14 @@ setup_env() {
1010 # Install kubectl and oc
1111 curl -L https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OC_CLIENT_VERSION} /openshift-client-linux.tar.gz | tar xvz
1212 sudo mv oc kubectl /usr/local/bin/
13-
13+ if [[ " $ARCHITECTURE " == " Z" ]]; then
14+ {
15+ echo " ****** Installing kubectl-kuttl..."
16+ curl -L -o kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64
17+ chmod +x kubectl-kuttl
18+ sudo mv kubectl-kuttl /usr/local/bin
19+ }
20+ fi
1421 # Start a cluster and login
1522 echo " ****** Logging into remote cluster..."
1623 oc login " ${CLUSTER_URL} " -u " ${CLUSTER_USER:- kubeadmin} " -p " ${CLUSTER_TOKEN} " --insecure-skip-tls-verify=true
@@ -159,9 +166,20 @@ main() {
159166 exit 1
160167 fi
161168
169+ if [[ -z " ${ARCHITECTURE} " ]]; then
170+ echo " ****** Missing architecture, see usage"
171+ echo " ${usage} "
172+ exit 1
173+ fi
174+
162175 echo " ****** Setting up test environment..."
163176 setup_env
164177
178+ if [[ " ${ARCHITECTURE} " != " X" ]]; then
179+ echo " ****** Setting up tests for ${ARCHITECTURE} architecture"
180+ setup_tests
181+ fi
182+
165183 if [[ -z " ${DEBUG_FAILURE} " ]]; then
166184 trap trap_cleanup EXIT
167185 else
@@ -190,12 +208,15 @@ main() {
190208 if [[ " $rc_kn " == 0 ]]; then
191209 echo " knative up"
192210 fi
193- echo " monitoring rook-ceph"
194- ./wait.sh deployment rook-ceph
195- rc_rk=$?
196- echo " rc_rk=$rc_rk "
197- if [[ " $rc_rk " == 0 ]]; then
198- echo " rook-ceph up"
211+
212+ if [[ " ${ARCHITECTURE} " == " X" ]]; then
213+ echo " monitoring rook-ceph if architecture is ${ARCHITECTURE} "
214+ ./wait.sh deployment rook-ceph
215+ rc_rk=$?
216+ echo " rc_rk=$rc_rk "
217+ if [[ " $rc_rk " == 0 ]]; then
218+ echo " rook-ceph up"
219+ fi
199220 fi
200221 echo " ****** Installing operator from catalog: ${CATALOG_IMAGE} using install mode of ${INSTALL_MODE} "
201222 echo " ****** Install namespace is ${INSTALL_NAMESPACE} . Test namespace is ${TEST_NAMESPACE} "
@@ -208,15 +229,25 @@ main() {
208229 done
209230
210231 echo " ****** ${CONTROLLER_MANAGER_NAME} deployment is ready..."
211-
212- echo " ****** Starting scorecard tests..."
232+ if [[ " $ARCHITECTURE " != " Z " ]] ; then
233+ echo " ****** Testing on ${ARCHITECTURE} so starting scorecard tests..."
213234 operator-sdk scorecard --verbose --kubeconfig ${HOME} /.kube/config --selector=suite=kuttlsuite --namespace=" ${TEST_NAMESPACE} " --service-account=" scorecard-kuttl" --wait-time 45m ./bundle || {
214235 echo " ****** Scorecard tests failed..."
215236 exit 1
216237 }
238+ else
239+ echo " ****** Testing on ${ARCHITECTURE} so running kubectl-kuttl tests..."
240+ kubectl-kuttl test ./bundle/tests/scorecard/kuttl --namespace " ${TEST_NAMESPACE} " --timeout 200 --suppress-log=events --parallel 1 || {
241+ echo " ****** kubectl kuttl tests failed..."
242+ exit 1
243+ }
244+ fi
217245 result=$?
218246
219247 echo " ****** Cleaning up test environment..."
248+ if [[ " ${ARCHITECTURE} " != " X" ]]; then
249+ revert_tests
250+ fi
220251 cleanup_env
221252
222253 return $result
@@ -268,6 +299,39 @@ spec:
268299EOF
269300}
270301
302+ # Substitutions to kuttl test files so that they will run on various architectures
303+ setup_tests () {
304+ echo " As the architecture is ${ARCHITECTURE} ..."
305+ if [[ " $ARCHITECTURE " == " P" ]]; then
306+ echo " Change affinity tests to look for ppc64le nodes"
307+ sed -i.bak " s,amd64,ppc64le," $( find ./bundle/tests/scorecard/kuttl/affinity -type f)
308+ echo " Change storage test to set storageclass to managed-nfs-storage"
309+ sed -i.bak " s,rook-cephfs,managed-nfs-storage," $( find ./bundle/tests/scorecard/kuttl/storage -type f)
310+ # These will need changing if a different image is used
311+ echo " Change image-stream tests to the correct digest for correct architecture"
312+ sed -i.bak " s,sha256:0796d9d800932a0da80d91fea720c12977bab871f8bf33b6e353b2c58aff23f1,sha256:5325d35a0c219ff545c6f906aa35b5d84a953493166c43aecd37ecc0d5e64fa6," $( find ./bundle/tests/scorecard/kuttl/image-stream -type f)
313+ sed -i.bak " s,sha256:5db4910bb5d5f479c55cba3ed0d9572676d50e30bf61b4a00d086f79016b8d53,sha256:f8a554c41d74dec15aab6c6f71aec741c8cb33eb2f587449e5bd7b8c46dd25b5," $( find ./bundle/tests/scorecard/kuttl/image-stream -type f)
314+ elif [[ " $ARCHITECTURE " == " Z" ]]; then
315+ echo " Change affinity tests to look for s390x nodes"
316+ sed -i.bak " s,amd64,s390x," $( find ./bundle/tests/scorecard/kuttl/affinity -type f)
317+ echo " Change storage test to set storageclass to managed-nfs-storage"
318+ sed -i.bak " s,rook-cephfs,managed-nfs-storage," $( find ./bundle/tests/scorecard/kuttl/storage -type f)
319+ # These will need changing if a different image is used
320+ echo " Change image-stream tests to the correct digest for correct architecture"
321+ sed -i.bak " s,sha256:0796d9d800932a0da80d91fea720c12977bab871f8bf33b6e353b2c58aff23f1,sha256:d622c05f4d62fc1f3cccc674c9f68cf57822c022fdd37af17bb1a7303f998ff5," $( find ./bundle/tests/scorecard/kuttl/image-stream -type f)
322+ sed -i.bak " s,sha256:5db4910bb5d5f479c55cba3ed0d9572676d50e30bf61b4a00d086f79016b8d53,sha256:fae90792e698d6e687c0c3b44db56f062f6374eb5fef039882308c048c9e0cbe," $( find ./bundle/tests/scorecard/kuttl/image-stream -type f)
323+ else
324+ echo " ${ARCHITECTURE} is an invalid architecture type"
325+ exit 1
326+ fi
327+ }
328+
329+ # As there maybe multiple runs over various architectures revert the substitutions back to amd64 defaults
330+ revert_tests () {
331+ echo " Reverting test changes back to amd64"
332+ find ./bundle/tests/scorecard/kuttl/* -name " *.bak" -exec sh -c ' mv -f $0 ${0%.bak}' {} \;
333+ }
334+
271335parse_args () {
272336 while [ $# -gt 0 ]; do
273337 case " $1 " in
@@ -330,6 +394,10 @@ parse_args() {
330394 shift
331395 readonly INSTALL_MODE=" ${1} "
332396 ;;
397+ --architecture)
398+ shift
399+ readonly ARCHITECTURE=" ${1} "
400+ ;;
333401 * )
334402 echo " Error: Invalid argument - $1 "
335403 echo " $usage "
@@ -340,4 +408,4 @@ parse_args() {
340408 done
341409}
342410
343- main " $@ "
411+ main " $@ "
0 commit comments