Skip to content
Snippets Groups Projects
Commit cef15212 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-677: Store container logs as gitlab CI/CD artifacts

parent 9f891839
No related branches found
No related tags found
1 merge request!287L2SS-677: Save docker logs and tangodb dump as Gitlab CI artefacts
......@@ -27,5 +27,3 @@ tangostationcontrol/docs/build
**/pending_log_messages.db
**/.eggs
log/*.log
log/*.json
......@@ -448,10 +448,9 @@ integration_test_docker:
variables:
DOCKER_TLS_CERTDIR: "/certs"
artifacts:
name: integration-test-logs
when: always
paths:
- $CI_PROJECT_DIR/log/*
- log/
before_script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" && -z "$CI_COMMIT_TAG" ]]; then
......@@ -470,20 +469,23 @@ integration_test_docker:
- export BASH_SOURCE=$(pwd)/bootstrap/etc/lofar20rc.sh
# Hack HOSTNAME env variable into host.docker.internal, set in docker-compose
- export HOSTNAME=host.docker.internal
# - export HOSTNAME=$(hostname -i)
# - export HOSTNAME=$(cat /run/systemd/netif/leases/2 | grep ^ADDRESS= | awk -F'=' '{print $2}')
# source the lofarrc file and mask its non zero exit code
- . bootstrap/etc/lofar20rc.sh || true
# TANGO_HOST must be unset our databaseds will be unreachable
- unset TANGO_HOST
## Allow docker image script to execute
# - chmod u+x $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh
# Do not remove 'bash' or statement will be ignored by primitive docker shell
- bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh pull $tag
## Allow integration test to execute
# - chmod u+x $CI_PROJECT_DIR/sbin/run_integration_test.sh
# Do not remove 'bash' or statement will be ignored by primitive docker shell
- bash $CI_PROJECT_DIR/sbin/run_integration_test.sh
after_script:
# Collect output of all containers
- |
mkdir -p log
for container in $(docker ps -a --format "{{.Names}}")
do
echo "Saving log for container $container"
docker logs "${container}" >& "log/${container}.log"
done
wheel_packaging:
stage: packaging
artifacts:
......
......@@ -9,10 +9,6 @@ if [ -z "$LOFAR20_DIR" ]; then
LOFAR20_DIR=$(readlink -f "${LOFAR20_DIR_RELATIVE}")
fi
# Where to store any logs and output files we produce
ARTIFACT_DIR="${LOFAR20_DIR}/log"
mkdir -p "${ARTIFACT_DIR}"
cd "$LOFAR20_DIR/docker-compose" || exit 1
# Start the database server first
......@@ -48,9 +44,6 @@ bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/tango-archive
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
# Dump the resulting configuration for offline analysis
bash "${LOFAR20_DIR}"/bin/dump_ConfigDb.sh >& "${ARTIFACT_DIR}"/integration-test-ConfigDb-dump.json
cd "$LOFAR20_DIR/docker-compose" || exit 1
# shellcheck disable=SC2086
make start $SIMULATORS
......@@ -72,24 +65,11 @@ cd "$LOFAR20_DIR/docker-compose" || exit 1
make up integration-test
# Run the default integration tests
TEST_RESULT=0
make run integration-test default || TEST_RESULT=$?
make run integration-test default
if [ ${TEST_RESULT} -eq 0 ]
then
# Configure integration test for recv_cluster module
bash "${LOFAR20_DIR}"/sbin/update_ConfigDb.sh "${LOFAR20_DIR}"/CDB/integrations/recvcluster_ConfigDb.json
make restart device-recv device-tilebeam
sleep 5
TEST_RESULT=0
make run integration-test recv_cluster || TEST_RESULT=$?
fi
# Dump logs of important containers
for container in $DEVICES databaseds dsconfig tangodb
do
docker logs "${CONTAINER_NAME_PREFIX}${container}" >& "${ARTIFACT_DIR}/${container}.log"
done
exit $TEST_RESULT
make run integration-test recv_cluster
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment