blob: 493f9b57f83d21e8e25ae45eba56949cd04b89c4 [file] [log] [blame]
adheli.tavares1f339f82023-02-17 15:14:07 +00001#!/bin/bash
2#
3# ============LICENSE_START====================================================
adheli.tavares80e382e2024-05-01 14:08:35 +01004# Copyright (C) 2023-2024 Nordix Foundation.
adheli.tavares1f339f82023-02-17 15:14:07 +00005# =============================================================================
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# SPDX-License-Identifier: Apache-2.0
19# ============LICENSE_END======================================================
20
21echo "Shut down started!"
22if [ -z "${WORKSPACE}" ]; then
23 WORKSPACE=$(git rev-parse --show-toplevel)
24 export WORKSPACE
25fi
adheli.tavares80e382e2024-05-01 14:08:35 +010026
adheli.tavares36127472024-07-02 11:51:35 +010027# always 'docker' if running docker compose
28export TEST_ENV="docker"
29
adheli.tavares80e382e2024-05-01 14:08:35 +010030# docker compose fails when not running CSIT
31if [ -z "$ROBOT_LOG_DIR" ]; then
32 export ROBOT_LOG_DIR=/tmp/
33 export ROBOT_FILES=none
34 export PROJECT=api
35fi
36
adheli.tavares1f339f82023-02-17 15:14:07 +000037COMPOSE_FOLDER="${WORKSPACE}"/compose
38
adheli.tavares5980fb42023-03-16 16:31:11 +000039cd ${COMPOSE_FOLDER}
40
41source export-ports.sh > /dev/null 2>&1
42source get-versions.sh > /dev/null 2>&1
adheli.tavares1f339f82023-02-17 15:14:07 +000043
44echo "Collecting logs from docker compose containers..."
adheli.tavaresf11e6d92024-08-01 14:18:34 +010045rm -rf *.log
adheli.tavares80e382e2024-05-01 14:08:35 +010046
47# this will collect logs by service instead of mixing all together
48containers=$(docker compose ps --all --format '{{.Service}}')
49
50IFS=$'\n' read -d '' -r -a item_list <<< "$containers"
51for item in "${item_list[@]}"
52do
53 if [ -n "$item" ]; then
adheli.tavaresf11e6d92024-08-01 14:18:34 +010054 docker compose logs $item >> $item.log
adheli.tavares80e382e2024-05-01 14:08:35 +010055 fi
56done
57
adheli.tavares1f339f82023-02-17 15:14:07 +000058echo "Tearing down containers..."
adheli.tavares80e382e2024-05-01 14:08:35 +010059docker compose down -v --remove-orphans
adheli.tavares5980fb42023-03-16 16:31:11 +000060
61cd ${WORKSPACE}