summaryrefslogtreecommitdiffstats
path: root/compose/stop-compose.sh
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-05-01 14:08:35 +0100
committeradheli.tavares <adheli.tavares@est.tech>2024-05-14 11:33:11 +0100
commit80e382eaac6fa812ea0c242c4a0c3a0390a4c130 (patch)
treefa984ad999edefa4f3affba4070415e94fffbb5f /compose/stop-compose.sh
parentaed46b6a5bfe0680043a2fd2239f642aee5902d7 (diff)
Restructure of CSIT scripts
- CSIT robot test suits are now compiled into a docker image - dependencies are now installed as part of Dockerfile build Issue-ID: POLICY-4987 Change-Id: I5ae4e9f58471a6038c25548d9392ece78b20e67a Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'compose/stop-compose.sh')
-rwxr-xr-xcompose/stop-compose.sh28
1 files changed, 25 insertions, 3 deletions
diff --git a/compose/stop-compose.sh b/compose/stop-compose.sh
index 0a7d9af4..013fbe1e 100755
--- a/compose/stop-compose.sh
+++ b/compose/stop-compose.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
# ============LICENSE_START====================================================
-# Copyright (C) 2023 Nordix Foundation.
+# Copyright (C) 2023-2024 Nordix Foundation.
# =============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,6 +23,14 @@ if [ -z "${WORKSPACE}" ]; then
WORKSPACE=$(git rev-parse --show-toplevel)
export WORKSPACE
fi
+
+# docker compose fails when not running CSIT
+if [ -z "$ROBOT_LOG_DIR" ]; then
+ export ROBOT_LOG_DIR=/tmp/
+ export ROBOT_FILES=none
+ export PROJECT=api
+fi
+
COMPOSE_FOLDER="${WORKSPACE}"/compose
cd ${COMPOSE_FOLDER}
@@ -31,10 +39,24 @@ source export-ports.sh > /dev/null 2>&1
source get-versions.sh > /dev/null 2>&1
echo "Collecting logs from docker compose containers..."
-docker-compose logs > docker_compose.log
+rm -rf docker_compose.log
+
+# this will collect logs by service instead of mixing all together
+containers=$(docker compose ps --all --format '{{.Service}}')
+
+IFS=$'\n' read -d '' -r -a item_list <<< "$containers"
+for item in "${item_list[@]}"
+do
+ if [ -n "$item" ]; then
+ echo "======== Logs from ${item} ========" >> docker_compose.log
+ docker compose logs $item >> docker_compose.log
+ echo "===================================" >> docker_compose.log
+ fi
+done
+
cat docker_compose.log
echo "Tearing down containers..."
-docker-compose down -v --remove-orphans
+docker compose down -v --remove-orphans
cd ${WORKSPACE}