mirror of
https://github.com/openshift/community.okd.git
synced 2026-03-26 19:03:14 +00:00
65 lines
1.7 KiB
Bash
Executable File
65 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
# IMAGE_FORMAT be in the form $registry/$org/$image:$$component, ie
|
|
# quay.io/openshift/release:$component
|
|
# To test with your own image, build and push the test image
|
|
# (using the Dockerfile in ci/Dockerfile)
|
|
# and set the IMAGE_FORMAT environment variable so that it properly
|
|
# resolves to your image. For example, quay.io/mynamespace/$component
|
|
# would resolve to quay.io/mynamespace/molecule-test-runner
|
|
component='molecule-test-runner'
|
|
eval IMAGE=$IMAGE_FORMAT
|
|
|
|
PULL_POLICY=${PULL_POLICY:-IfNotPresent}
|
|
|
|
echo "Deleting test job if it exists"
|
|
kubectl delete job molecule-integration-test --wait --ignore-not-found
|
|
|
|
echo "Creating molecule test job"
|
|
cat << EOF | kubectl create -f -
|
|
---
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: molecule-integration-test
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: test-runner
|
|
image: ${IMAGE}
|
|
imagePullPolicy: ${PULL_POLICY}
|
|
command:
|
|
- make
|
|
- test-integration
|
|
restartPolicy: Never
|
|
backoffLimit: 2
|
|
completions: 1
|
|
parallelism: 1
|
|
EOF
|
|
|
|
echo "Waiting for test job to report success"
|
|
|
|
# Ensure the child processes are killed
|
|
trap 'kill $(jobs -p) || true' SIGINT SIGTERM EXIT
|
|
|
|
# Wait for job completion in background
|
|
kubectl wait --for=condition=complete job/molecule-integration-test --timeout 5m &
|
|
completion_pid=$!
|
|
|
|
# Wait for job failure in background
|
|
kubectl wait --for=condition=failed job/molecule-integration-test --timeout 5m && exit 1 &
|
|
failure_pid=$!
|
|
|
|
|
|
if wait -n $completion_pid $failure_pid ; then
|
|
echo "Molecule integration tests ran successfully"
|
|
exit 0
|
|
else
|
|
kubectl logs job/molecule-integration-test
|
|
echo "Molecule integration tests failed, see logs for more information..."
|
|
exit 1
|
|
fi
|