Skip to content

Commit 1268531

Browse files
authored
Merge pull request #428 from WASdev/auto-multi-arch-test
Changes to allow multi-arch automated kuttl tests
2 parents e14ab3c + ae79688 commit 1268531

File tree

6 files changed

+95
-19
lines changed

6 files changed

+95
-19
lines changed

.one-pipeline.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ setup:
7070
if [[ "$arch" == "X" ]]; then
7171
./scripts/pipeline/getCluster.sh "X"
7272
else
73-
# ./scripts/pipeline/getCluster.sh "Z"
73+
./scripts/pipeline/getCluster.sh "Z"
7474
./scripts/pipeline/getCluster.sh "X"
75-
# ./scripts/pipeline/getCluster.sh "P"
75+
./scripts/pipeline/getCluster.sh "P"
7676
fi
7777
fi
7878
@@ -446,9 +446,9 @@ acceptance-test:
446446
export arch=$(get_env architecture)
447447
448448
if [[ "$arch" == "ZXP" ]]; then
449-
# source runTest.sh Z
449+
source runTest.sh Z
450450
source runTest.sh X
451-
# source runTest.sh P
451+
source runTest.sh P
452452
else
453453
source runTest.sh X
454454
fi

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ test-pipeline-e2e:
348348
--registry-name "${PIPELINE_REGISTRY}" --registry-image "${PIPELINE_OPERATOR_IMAGE}" \
349349
--registry-user "${PIPELINE_USERNAME}" --registry-password "${PIPELINE_PASSWORD}" \
350350
--test-tag "${TRAVIS_BUILD_NUMBER}" --release "${RELEASE_TARGET}" --channel "${DEFAULT_CHANNEL}" \
351-
--install-mode "${INSTALL_MODE}"
351+
--install-mode "${INSTALL_MODE}" --architecture "${ARCHITECTURE}"
352352

353353
bundle-build-podman:
354354
podman build -f bundle.Dockerfile -t "${BUNDLE_IMG}"

bundle/tests/scorecard/kuttl/image-stream/02-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apiVersion: v1
1111
kind: Pod
1212
spec:
1313
containers:
14-
- image: icr.io/appcafe/websphere-liberty@sha256:73cce354026b3a3c19b4eb759fdd8b11b748481588a242c22106e00b0ffd52e4
14+
- image: icr.io/appcafe/websphere-liberty@sha256:5db4910bb5d5f479c55cba3ed0d9572676d50e30bf61b4a00d086f79016b8d53
1515
status:
1616
containerStatuses:
1717
- ready: true

scripts/acceptance-test.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ docker build -t e2e-runner:latest -f Dockerfile.e2e --build-arg GO_VERSION="${GO
1111
}
1212

1313
declare -A E2E_TESTS=(
14-
[ocp-e2e-run]=$(cat <<-EOF
14+
[ocp-e2e-run-${ARCHITECTURE}]=$(cat <<-EOF
1515
--volume /var/run/docker.sock:/var/run/docker.sock \
1616
--env PIPELINE_USERNAME=${PIPELINE_USERNAME} \
1717
--env PIPELINE_PASSWORD=${PIPELINE_PASSWORD} \
@@ -27,13 +27,14 @@ declare -A E2E_TESTS=(
2727
--env CATALOG_IMAGE=${PIPELINE_REGISTRY}/${PIPELINE_OPERATOR_IMAGE}-catalog:${RELEASE_TARGET} \
2828
--env DEBUG_FAILURE=${DEBUG_FAILURE} \
2929
--env INSTALL_MODE=${INSTALL_MODE} \
30+
--env ARCHITECTURE=${ARCHITECTURE}
3031
e2e-runner:latest \
3132
make test-pipeline-e2e
3233
EOF
3334
)
3435
)
3536

36-
if [[ "${SKIP_KIND_E2E_TEST}" != true ]]; then
37+
if [[ "${SKIP_KIND_E2E_TEST}" != true && "${ARCHITECTURE}" == "X" ]]; then
3738
E2E_TESTS[kind-e2e-run]=$(cat <<- EOF
3839
--volume /var/run/docker.sock:/var/run/docker.sock \
3940
--env FYRE_USER=${FYRE_USER} \
@@ -48,7 +49,7 @@ if [[ "${SKIP_KIND_E2E_TEST}" != true ]]; then
4849
EOF
4950
)
5051
else
51-
echo "SKIP_KIND_E2E was set. Skipping kind e2e..."
52+
echo "SKIP_KIND_E2E was set or architecture is not X. Skipping kind e2e..."
5253
fi
5354

5455
echo "****** Starting e2e tests"

scripts/pipeline/ocp-cluster-e2e.sh

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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:
268299
EOF
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+
271335
parse_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 "$@"

scripts/pipeline/runTest.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export GO_VERSION=$(get_env go-version)
2525
make setup-go GO_RELEASE_VERSION=$GO_VERSION
2626
export PATH=$PATH:/usr/local/go/bin
2727
export INSTALL_MODE=$(get_env install-mode)
28+
export ARCHITECTURE=$arch
2829

2930
# OCP test
3031
export PIPELINE_USERNAME=$(get_env ibmcloud-api-user)
@@ -81,3 +82,9 @@ else
8182
curl -X POST -H 'Content-type: application/json' --data '{"text":"access console at: '$console'"}' $(get_env slack_web_hook_url) </dev/null
8283
curl -X POST -H 'Content-type: application/json' --data '{"text":"credentials: kubeadmin/'$token'"}' $(get_env slack_web_hook_url) </dev/null
8384
fi
85+
86+
echo "Cleaning up after tests have be completed"
87+
echo "switching back to scripts/pipeline directory"
88+
cd ..
89+
oc logout
90+
export CLUSTER_URL=""

0 commit comments

Comments
 (0)