Files
fission-src/test/test.sh
T
Ta-Ching ChenandGitHub fe8fa94c77 Enable concurrent CI builds (#1236)
Currently, only one CI build can be started at the same time due to we only have only one testing cluster. This PR aims to enable multiple concurrent builds can be triggered to reduce the waiting time for CI builds. The major changes listed below:

1. Each build generate unique images for testing and debugging
2. Check whether the testing cluster is being used by another build.
3. Cache docker image & go mod after build finished
4. Improve dockerfiles for reusing docker build cache
2019-07-15 16:33:26 +08:00

51 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Unbound variables cause failure, so this readable if block instead of Parameter Expansion
if [[ ${TRAVIS_EVENT_TYPE+NOVALUE} == "cronNOVALUE" ]]
then
echo "Skipping build & test, this is cron job for fission upgrade tests"
exit 0
fi
if [ ! -f ${HOME}/.kube/config ]
then
echo "Skipping end to end tests, no cluster credentials"
exit 0
fi
source $(dirname $0)/test_utils.sh
dump_system_info
setupCIBuildEnv
while true; do
# ensure that gke cluster is now free for testing
previous_build_id=$(kubectl --namespace default get configmap in-test --ignore-not-found -o=jsonpath='{.metadata.labels.travisID}')
build_state=$(curl -s -X GET https://api.travis-ci.org/build/${previous_build_id} \
-H "Authorization: token ${TRAVIS_TOKEN}" \
-H "Travis-API-Version: 3" | python -c "import sys,json; print json.load(sys.stdin)['state']")
# If previous build state is not equal to "started" or the previous build id
# equals to the current build ID means the previous build is end or restart.
# We can remove the configmap safely and start next k8s test safely.
if [[ ${TRAVIS_TOKEN} == ${previous_build_id} ]] || [[ $build_state != "started" ]]; then
kubectl --namespace default delete configmap -l travisID=${previous_build_id}
fi
created=$(kubectl --namespace default create configmap in-test|grep "created"||true)
if [[ -z $created ]]; then
echo "Cluster is now in used. Retrying after 15 seconds..."
sleep 15
continue
fi
kubectl --namespace default label configmap in-test travisID=${TRAVIS_BUILD_ID}
break
done
install_and_test $REPO $IMAGE $TAG $FETCHER_IMAGE $TAG $PRUNE_INTERVAL $ROUTER_SERVICE_TYPE $SERVICE_TYPE $PRE_UPGRADE_CHECK_IMAGE