Newer
Older
#!/usr/bin/env bash
debug() {
>&2 echo "DEBUG: $@"
}
error() {
>&2 echo "ERROR: $@"
exit 1
}
install_charts() {
# use the production rabbitmq config
./helpers/deploy_rabbitmq.sh "ci_tests" "${RELEASE_PREFIX}"
pushd geosphere-grb/chart
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "../../ci_tests/values-grb-g16.yaml"
helm upgrade -v 2 --install --namespace $ns -f ../../ci_tests/values-grb-g16.yaml ${GRB_RELEASE_NAME} cspp-geo-grb/
popd
grb_pvc=$(get_pvc_name ${GRB_RELEASE_NAME})
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "ci_tests/values-geo2grid-g16-radm1.yaml"
sed -i "s/cspp-geo-grb/${GRB_RELEASE_NAME}/g" "ci_tests/values-geo2grid-g16-radm1.yaml"
./helpers/deploy_geo2grid.sh "ci_tests" "${RELEASE_PREFIX}" "-g16-radm1"
# Tile Gen
geotiff_pvc=$(get_pvc_name ${GEO2GRID_RELEASE_NAME})
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "ci_tests/values-tile-gen-g16-radm1.yaml"
sed -i "s/cspp-geo-geo2grid/${GEO2GRID_RELEASE_NAME}/g" "ci_tests/values-tile-gen-g16-radm1.yaml"
./helpers/deploy_tile_gen.sh "ci_tests" "${RELEASE_PREFIX}" "-g16-radm1"
# MapServer
sed -i "s/cspp-geo-geo2grid/${GEO2GRID_RELEASE_NAME}/g" "ci_tests/values-mapserver.yaml"
sed -i "s/geosphere-tile-gen-shapefiles/${TILEGEN_RELEASE_NAME}/g" "ci_tests/values-mapserver.yaml"
./helpers/deploy_mapserver.sh "ci_tests" "${RELEASE_PREFIX}"
# MapCache
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "ci_tests/values-mapcache.yaml"
sed -i "s/geosphere-mapserver/${MAPSERVER_RELEASE_NAME}/g" "ci_tests/values-mapcache.yaml"
./helpers/deploy_mapcache.sh "ci_tests" "${RELEASE_PREFIX}"
# Client
sed -i "s/geosphere-mapserver/${MAPSERVER_RELEASE_NAME}/g" "ci_tests/values-client.yaml"
sed -i "s/geosphere-mapcache/${MAPCACHE_RELEASE_NAME}/g" "ci_tests/values-client.yaml"
./helpers/deploy_client.sh "ci_tests" "${RELEASE_PREFIX}"
}
get_pod_name() {
release_name="$1"
kubectl -n $ns get pods --selector=app.kubernetes.io/instance=${release_name} -o name
}
get_pvc_name() {
release_name="$1"
kubectl -n $ns get pvc --selector=app.kubernetes.io/instance=${release_name} -o name
}
debug "Waiting for ${pod_name} pod to be ready..."
kubectl -n $ns wait --for=condition=Ready ${pod_name} --timeout=120s
run_grb_checks() {
count=0
while true; do
num_files=$(kubectl exec -n $ns ${GRB_POD_NAME} -c cspp-geo-grb-notifier -- ls -1 /dst | wc -l || echo 0)
let count=count+1
if [[ $num_files -gt 16 ]]; then
debug "Got at least 16 files ($num_files)"
break
fi
if [[ $count -gt 10 ]]; then
error "Took too long for GRB to produce files ($num_files so far)"
debug "Found $num_files files, waiting for more..."
sleep 10
done
}
run_geo2grid_checks() {
count=0
while true; do
num_files=$(kubectl exec -n $ns ${GEO2GRID_POD_NAME} -- ls -1 /dst/geotiffs/g16/abi/radm1/ | wc -l || echo 0)
let count=count+1
if [[ $num_files -gt 16 ]]; then
debug "Got at least 16 files ($num_files)"
break
fi
if [[ $count -gt 10 ]]; then
error "Took too long for Geo2Grid to produce files ($num_files so far)"
debug "Found $num_files files, waiting for more..."
sleep 10
done
}
run_tile_gen_checks() {
return 0
}
run_mapserver_checks() {
return 0
}
run_mapcache_checks() {
return 0
}
run_client_checks() {
# just try to load the webpage at all
curl -s "http://${CLIENT_RELEASE_NAME}/"
}
set -e
ns=$(./helpers/get_namespace.sh)
source ci_tests/get_release_names.sh
install_charts
# give kubernetes a bit to create the resources
sleep 60
debug "Getting GRB pod name"
GRB_POD_NAME=$(get_pod_name "${GRB_RELEASE_NAME}")
debug "GRB pod name: ${GRB_POD_NAME}"
GEO2GRID_POD_NAME=$(get_pod_name "${GEO2GRID_RELEASE_NAME}")
debug "Geo2Grid pod name: ${GEO2GRID_POD_NAME}"
TILEGEN_POD_NAME=$(get_pod_name "${TILEGEN_RELEASE_NAME}")
debug "Tile Generation pod name: ${TILEGEN_POD_NAME}"
MAPSERVER_POD_NAME=$(get_pod_name "${MAPSERVER_RELEASE_NAME}")
debug "MapServer pod name: ${MAPSERVER_POD_NAME}"
MAPCACHE_POD_NAME=$(get_pod_name "${MAPCACHE_RELEASE_NAME}")
debug "MapCache pod name: ${MAPCACHE_POD_NAME}"
CLIENT_POD_NAME=$(get_pod_name "${CLIENT_RELEASE_NAME}")
debug "Client pod name: ${CLIENT_POD_NAME}"
wait_for_pod ${GRB_POD_NAME} || error "GRB pod was never ready"
run_grb_checks || error "GRB checks failed"
wait_for_pod ${GEO2GRID_POD_NAME} || error "Geo2Grid pod was never ready"
run_geo2grid_checks || error "Geo2Grid checks failed"
wait_for_pod ${TILEGEN_POD_NAME} || error "Tile Gen pod was never ready"
run_tile_gen_checks || error "Tile Generation checks failed"
wait_for_pod ${MAPSERVER_POD_NAME} || error "MapServer pod was never ready"
run_mapserver_checks || error "MapServer checks failed"
wait_for_pod ${MAPCACHE_POD_NAME} || error "MapCache pod was never ready"
run_mapcache_checks || error "MapCache checks failed"
wait_for_pod ${CLIENT_POD_NAME} || error "Client pod was never ready"
run_client_checks || error "Client checks failed"