Skip to content
Snippets Groups Projects
Verified Commit ee50353f authored by David Hoese's avatar David Hoese
Browse files

Refactor ci tests to add additional tests

parent 157b4fce
No related branches found
No related tags found
No related merge requests found
Showing
with 274 additions and 160 deletions
#!/usr/bin/env bash
debug() {
>&2 echo "DEBUG: $@"
}
error() {
>&2 echo "ERROR: $@"
exit 1
}
install_rabbitmq_chart() {
TEST_VALUES_DIR=$1
./helpers/deploy_rabbitmq.sh "${TEST_VALUES_DIR}" "${RELEASE_PREFIX}"
}
install_postgres_chart() {
TEST_VALUES_DIR=$1
}
install_grb_chart() {
TEST_VALUES_DIR=$1
pushd geosphere-grb/chart
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "../../${TEST_VALUES_DIR}/values-grb-g16.yaml"
helm upgrade -v 2 --install --namespace $ns -f ../../${TEST_VALUES_DIR}/values-grb-g16.yaml ${GRB_RELEASE_NAME} cspp-geo-grb/
popd
}
install_geo2grid_chart() {
TEST_VALUES_DIR=$1
grb_pvc=$(get_pvc_name ${GRB_RELEASE_NAME})
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "${TEST_VALUES_DIR}/values-geo2grid-g16-radm1.yaml"
sed -i "s/cspp-geo-grb/${GRB_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-geo2grid-g16-radm1.yaml"
./helpers/deploy_geo2grid.sh "${TEST_VALUES_DIR}" "${RELEASE_PREFIX}" "-g16-radm1"
}
install_tile_gen_chart() {
TEST_VALUES_DIR=$1
geotiff_pvc=$(get_pvc_name ${GEO2GRID_RELEASE_NAME})
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "${TEST_VALUES_DIR}/values-tile-gen-g16-radm1.yaml"
sed -i "s/cspp-geo-geo2grid/${GEO2GRID_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-tile-gen-g16-radm1.yaml"
./helpers/deploy_tile_gen.sh "${TEST_VALUES_DIR}" "${RELEASE_PREFIX}" "-g16-radm1"
}
install_mapserver_chart() {
TEST_VALUES_DIR=$1
sed -i "s/cspp-geo-geo2grid/${GEO2GRID_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-mapserver.yaml"
sed -i "s/geosphere-tile-gen-shapefiles/${TILEGEN_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-mapserver.yaml"
./helpers/deploy_mapserver.sh "${TEST_VALUES_DIR}" "${RELEASE_PREFIX}"
}
install_mapcache_chart() {
TEST_VALUES_DIR=$1
sed -i "s/geosphere-rabbit-rabbitmq/${RABBITMQ_SERVICE_NAME}/g" "${TEST_VALUES_DIR}/values-mapcache.yaml"
sed -i "s/geosphere-mapserver/${MAPSERVER_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-mapcache.yaml"
./helpers/deploy_mapcache.sh "${TEST_VALUES_DIR}" "${RELEASE_PREFIX}"
}
install_client_chart() {
TEST_VALUES_DIR=$1
sed -i "s/geosphere-mapserver/${MAPSERVER_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-client.yaml"
sed -i "s/geosphere-mapcache/${MAPCACHE_RELEASE_NAME}/g" "${TEST_VALUES_DIR}/values-client.yaml"
./helpers/deploy_client.sh "${TEST_VALUES_DIR}" "${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
}
wait_for_pod() {
pod_name="$1"
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)"
fi
debug "Found $num_files files, waiting for more..."
sleep 12
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)"
fi
debug "Found $num_files files, waiting for more..."
sleep 12
done
}
run_tile_gen_checks() {
count=0
while true; do
num_files=$(kubectl exec -n $ns ${TILEGEN_POD_NAME} -- ls -1 /dst/tiles/g16/abi/radm1/C01/ | wc -l || echo 0)
let count=count+1
if [[ $num_files -gt 3 ]]; then
debug "Got at least 3 files ($num_files)"
break
fi
if [[ $count -gt 10 ]]; then
error "Took too long for tile generation to produce its shape file"
fi
debug "Found $num_files files, waiting for more..."
sleep 12
done
return 0
}
run_mapserver_checks() {
# Ex: ["2020-11-24T22:23:19", "2020...
# Get the first element without quotes
first_time=$(curl -sS "http://${MAPSERVER_RELEASE_NAME}.${ns}/wms_times/g16/abi/radm1/C01" | head -c 21 | tail -c 19)
debug "MapServer first time: ${first_time}"
# if there aren't any times then we failed
if [ $first_time == "" ]; then
return 1
else
return 0
fi
}
run_mapcache_checks() {
first_time=$(curl -sS "http://${MAPSERVER_RELEASE_NAME}.${ns}/wms_times/g16/abi/radm1/C01" | head -c 21 | tail -c 19)
debug "MapServer first time: ${first_time}"
curl "http://${MAPCACHE_RELEASE_NAME}.${ns}/mapcache/wmts/?TIME=${first_time}Z&TILEMATRIXSET=grid_g16_abi_radf_1000m&LAYER=g16_abi_radf_l1b_C01&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=0&TileCol=0&TileRow=0" >/dev/null
}
run_client_checks() {
# just try to load the webpage at all
curl "http://${CLIENT_RELEASE_NAME}.${ns}/" >/dev/null
}
check_and_uninstall() {
ns="$1"
release_name="$2"
if [[ -z "${release_name}" ]]; then
# the chart was never created
debug "Release doesn't exist"
return
fi
debug "Uninstalling ${release_name}"
helm uninstall -n "${ns}" "${release_name}" || (debug "Could not uninstall chart $release_name" && return 1)
}
File moved
#!/usr/bin/env bash #!/usr/bin/env bash
debug() { source ci_tests/_tests_common.sh
>&2 echo "DEBUG: $@"
}
error() {
>&2 echo "ERROR: $@"
exit 1
}
check_and_uninstall() {
ns="$1"
release_name="$2"
if [[ -z "${release_name}" ]]; then
# the chart was never created
debug "Release doesn't exist"
return
fi
debug "Uninstalling ${release_name}"
helm uninstall -n "${ns}" "${release_name}" || (debug "Could not uninstall chart $release_name" && return 1)
}
ns=$(./helpers/get_namespace.sh) ns=$(./helpers/get_namespace.sh)
source ./ci_tests/get_release_names.sh source ./ci_tests/get_release_names.sh
......
#!/usr/bin/env bash
source ci_tests/_tests_common.sh
ns=$(./helpers/get_namespace.sh)
source ./ci_tests/get_release_names.sh
EXIT_STATUS=0
#check_and_uninstall "${ns}" "${GRB_RELEASE_NAME}" || EXIT_STATUS=$?
#check_and_uninstall "${ns}" "${RABBITMQ_RELEASE_NAME}" || EXIT_STATUS=$?
#check_and_uninstall "${ns}" "${GEO2GRID_RELEASE_NAME}" || EXIT_STATUS=$?
#check_and_uninstall "${ns}" "${TILEGEN_RELEASE_NAME}" || EXIT_STATUS=$?
#check_and_uninstall "${ns}" "${MAPSERVER_RELEASE_NAME}" || EXIT_STATUS=$?
#check_and_uninstall "${ns}" "${MAPCACHE_RELEASE_NAME}" || EXIT_STATUS=$?
#check_and_uninstall "${ns}" "${CLIENT_RELEASE_NAME}" || EXIT_STATUS=$?
exit $EXIT_STATUS
...@@ -12,8 +12,11 @@ test_basic_grb: ...@@ -12,8 +12,11 @@ test_basic_grb:
stage: test stage: test
script: script:
- ./ci_tests/run_basic_grb_test.sh - ./ci_tests/run_basic_grb_test.sh
# run, but don't care about failure
- ./ci_tests/run_basic_postgres_test.sh || true
after_script: after_script:
- ./ci_tests/cleanup_basic_grb_test.sh - ./ci_tests/cleanup_basic_grb_test.sh
- ./ci_tests/cleanup_basic_postgres_test.sh
dependencies: dependencies:
- get_chart_grb - get_chart_grb
- get_chart_geo2grid - get_chart_geo2grid
...@@ -23,3 +26,22 @@ test_basic_grb: ...@@ -23,3 +26,22 @@ test_basic_grb:
- get_chart_client - get_chart_client
rules: rules:
- when: on_success - when: on_success
test_basic_postgres:
extends: .helm_based_job
stage: test
script:
# run, but don't care about failure
- ./ci_tests/run_basic_postgres_test.sh || true
after_script:
- ./ci_tests/cleanup_basic_postgres_test.sh
dependencies:
- get_chart_grb
- get_chart_geo2grid
- get_chart_tilegen
- get_chart_mapserver
- get_chart_mapcache
- get_chart_client
allow_failure: true
rules:
- when: on_success
#!/usr/bin/env bash #!/usr/bin/env bash
debug() { install_basic_grb_charts() {
>&2 echo "DEBUG: $@" install_rabbitmq_chart $1
} install_grb_chart $1
install_geo2grid_chart $1
error() { install_tile_gen_chart $1
>&2 echo "ERROR: $@" install_mapserver_chart $1
exit 1 install_mapcache_chart $1
} install_client_chart $1
install_charts() {
# use the production rabbitmq config
./helpers/deploy_rabbitmq.sh "ci_tests" "${RELEASE_PREFIX}"
# GRB
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
# Geo2Grid
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}"
debug "$(helm -n $ns list)" debug "$(helm -n $ns list)"
} }
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
}
wait_for_pod() {
pod_name="$1"
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)"
fi
debug "Found $num_files files, waiting for more..."
sleep 12
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)"
fi
debug "Found $num_files files, waiting for more..."
sleep 12
done
}
run_tile_gen_checks() {
count=0
while true; do
num_files=$(kubectl exec -n $ns ${TILEGEN_POD_NAME} -- ls -1 /dst/tiles/g16/abi/radm1/C01/ | wc -l || echo 0)
let count=count+1
if [[ $num_files -gt 3 ]]; then
debug "Got at least 3 files ($num_files)"
break
fi
if [[ $count -gt 10 ]]; then
error "Took too long for tile generation to produce its shape file"
fi
debug "Found $num_files files, waiting for more..."
sleep 12
done
return 0
}
run_mapserver_checks() {
# Ex: ["2020-11-24T22:23:19", "2020...
# Get the first element without quotes
first_time=$(curl -sS "http://${MAPSERVER_RELEASE_NAME}.${ns}/wms_times/g16/abi/radm1/C01" | head -c 21 | tail -c 19)
debug "MapServer first time: ${first_time}"
# if there aren't any times then we failed
if [ $first_time == "" ]; then
return 1
else
return 0
fi
}
run_mapcache_checks() {
first_time=$(curl -sS "http://${MAPSERVER_RELEASE_NAME}.${ns}/wms_times/g16/abi/radm1/C01" | head -c 21 | tail -c 19)
debug "MapServer first time: ${first_time}"
curl "http://${MAPCACHE_RELEASE_NAME}.${ns}/mapcache/wmts/?TIME=${first_time}Z&TILEMATRIXSET=grid_g16_abi_radf_1000m&LAYER=g16_abi_radf_l1b_C01&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=0&TileCol=0&TileRow=0" >/dev/null
}
run_client_checks() {
# just try to load the webpage at all
curl "http://${CLIENT_RELEASE_NAME}.${ns}/" >/dev/null
}
set -e set -e
source ci_tests/_tests_common.sh
ns=$(./helpers/get_namespace.sh) ns=$(./helpers/get_namespace.sh)
source ci_tests/get_release_names.sh source ci_tests/get_release_names.sh
install_charts install_basic_grb_charts "ci_tests/basic_grb"
# give kubernetes a bit to create the resources # give kubernetes a bit to create the resources
debug "Waiting for Kubernetes to deploy and schedule components..." debug "Waiting for Kubernetes to deploy and schedule components..."
......
#!/usr/bin/env bash
...@@ -34,4 +34,6 @@ ...@@ -34,4 +34,6 @@
$test_script $image_url $docker_tag; $test_script $image_url $docker_tag;
done done
- docker push ${image_url}:${docker_tag} - docker push ${image_url}:${docker_tag}
- docker push ${image_url}:latest - if [[ $CI_COMMIT_BRANCH == "master" ]]; then
docker push ${image_url}:latest;
fi
#!/usr/bin/env bash
set -e
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
echo "Usage: ./helpers/deploy_rabbitmq.sh <values_base_dir> [<release_prefix>]"
exit 1
fi
# ci_geosphere-test
values_base="$1"
# Prefix Example: testing-YYYYMMDD-
if [[ $# -eq 1 ]]; then
release_prefix=""
else
release_prefix="$2"
fi
ns=$(./helpers/get_namespace.sh)
# get password from any previous installation
# if we don't do this the password will get out of sync
# WARNING: If you can't figure out why the password isn't working and you
# can't authenticate the user, double check that the PVC for rabbitmq
# is deleted. This is storing the old password and may be messing
# things up.
# Test user authentication by logging in to the rabbitmq pod and running:
# rabbitmqctl authenticate_user user <password>
# where password is accessed from the kubectl secret:
# kubectl get secret --namespace geosphere geosphere-rabbit-rabbitmq -o jsonpath="{.data.rabbitmq-password}" | base64 --decode
sec_info=$(kubectl get secret --namespace $ns geosphere-rabbit-rabbitmq || echo "")
echo $sec_info
auth_sec="geosphere-rabbit-rabbitmq"
if [[ "$sec_info" != "" ]]; then
pw=$(kubectl get secret --namespace $ns $auth_sec -o jsonpath="{.data.rabbitmq-password}" | base64 -d);
ec=$(kubectl get secret --namespace $ns $auth_sec -o jsonpath="{.data.rabbitmq-erlang-cookie}" | base64 -d);
EXTRA_ARGS="--set auth.password=$pw --set auth.erlangCookie=$ec";
fi
echo "Adding extra arguments: $EXTRA_ARGS"
# install third-party rabbitmq server
helm repo add bitnami "https://charts.bitnami.com/bitnami"
release_name="${release_prefix}geosphere-rabbit"
helm upgrade -v 2 --install -f ${values_base}/values-geosphere-rabbit.yaml $EXTRA_ARGS --namespace $ns "${release_name}" bitnami/rabbitmq
# do a little waiting for the rabbitmq pod to be ready so future stages
# don't fail to communicate with it
echo "Start waiting for rabbitmq: $(date +%Y%m%dT%H%M%S)"
kubectl wait -n $ns pod/"${release_name}-rabbitmq-0" --timeout 120s --for=condition=Ready
status=$?
echo "Done waiting for rabbitmq: $(date +%Y%m%dT%H%M%S) : $status"
exit $status
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment