Select Git revision
test_calculated_qualities_outputs.py
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
run_integration_test.sh 4.78 KiB
#!/bin/bash -e
# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0
# Usage function explains how parameters are parsed
function usage {
echo "./$(basename "$0")
no arguments, builds and configures all docker containers and starts each
stage of the integration test one after the other. Between each stage the
dsconfig is updated accordingly."
echo ""
echo "./$(basename "$0") -h
displays this help message"
}
# Configure the config database, restart containers and run a specific
# integration module or even specific tests
# integration_test module restarted_containers config_files specific_test
function integration_test {
IFS=" " read -r -a restarts <<< "${2}"
IFS=" " read -r -a configs <<< "${3}"
for config in "${configs[@]}"; do
echo "Updating config ${config} ..."
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${config}"
done
if [ -n "${2+x}" ]; then
# shellcheck disable=SC2145
echo "make restart ${restarts[@]} ..."
make restart "${restarts[@]}"
# shellcheck disable=SC2145
echo "make await ${restarts[@]} ..."
make await "${restarts[@]}"
fi
echo "make integration ${1} ..."
make integration "${1}"
}
# list of arguments expected in the input
optstring=":h"
while getopts ${optstring} arg; do
case ${arg} in
h)
usage
exit 0
;;
?)
echo "Invalid option: -${OPTARG}."
exit 2
;;
esac
done
if [ -z "$LOFAR20_DIR" ]; then
# We assume we aren't in the PATH, so we can derive our path.
# We need our parent directory.
LOFAR20_DIR_RELATIVE=$(dirname "$0")/..
# As an absolute path
LOFAR20_DIR=$(readlink -f "${LOFAR20_DIR_RELATIVE}")
fi
cd "$LOFAR20_DIR/docker-compose" || exit 1
# Start the database server first
make build databaseds dsconfig
make start databaseds dsconfig
# Give dsconfig and databaseds time to start
sleep 1 # dsconfig container must be up and running...
# shellcheck disable=SC2016
echo '/usr/local/bin/wait-for-it.sh ${TANGO_HOST} --strict --timeout=300 -- true' | make run dsconfig bash -
# Devices list is used to explitly word split when supplied to commands, must
# disable shellcheck SC2086 for each case.
DEVICES=(device-station-manager device-boot device-apsct device-ccd device-apspu device-sdp device-recv device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-antennafield device-temperature-manager device-observation device-observation-control device-configuration)
SIMULATORS=(sdptr-sim recv-sim unb2-sim apsct-sim apspu-sim ccd-sim)
# Build only the required images, please do not build everything that makes CI
# take really long to finish, especially grafana / jupyter / prometheus.
# jupyter is physically large > 2.5gb and overlayfs is really slow.
make build "${DEVICES[@]}" "${SIMULATORS[@]}"
make build logstash integration-test http-json-schemas
# Start and stop sequence
make stop http-json-schemas
make stop "${DEVICES[@]}" "${SIMULATORS[@]}"
make stop device-docker # this one does not test well in docker-in-docker
make stop logstash
# Run dummy integration test to install pytango in tox virtualenv without
# the memory pressure of the ELK stack.
# Alternatively this step can be avoided if we use:
# `tox --sitepackages -e integration` for the integration docker container,
# however, that does require creating a container specific integration job.
# TODO(L2SS-992): Remove me and above documentation
integration_test dummy
make start logstash http-json-schemas
# Update the dsconfig
# Do not remove `bash`, otherwise statement ignored by gitlab ci shell!
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/LOFAR_ConfigDb.json
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/test_environment_ConfigDb.json
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/simulators_ConfigDb.json
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/stations/dummy_positions_ConfigDb.json
cd "$LOFAR20_DIR/docker-compose" || exit 1
make start "${SIMULATORS[@]}"
# Give the simulators time to start
sleep 5
# shellcheck disable=SC2086
make start "${DEVICES[@]}"
# Wait for devices to restart
make await "${DEVICES[@]}"
# Start the integration test
cd "$LOFAR20_DIR/docker-compose" || exit 1
make up integration-test
integration_test default
integration_test tilebeam_performance "device-recv device-tilebeam device-antennafield" "${LOFAR20_DIR}/CDB/integrations/tilebeam_cluster_ConfigDb.json"
integration_test digitalbeam_performance "device-sdp device-recv device-digitalbeam device-beamlet device-antennafield" "${LOFAR20_DIR}/CDB/integrations/digitalbeam_cluster_ConfigDb.json"
integration_test configuration "device-configuration"
make restart "${DEVICES[@]}"