adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # ============LICENSE_START==================================================== |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 4 | # Copyright (C) 2023-2024 Nordix Foundation. |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 5 | # ============================================================================= |
| 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 | |
| 21 | echo "Shut down started!" |
| 22 | if [ -z "${WORKSPACE}" ]; then |
| 23 | WORKSPACE=$(git rev-parse --show-toplevel) |
| 24 | export WORKSPACE |
| 25 | fi |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 26 | |
adheli.tavares | 3612747 | 2024-07-02 11:51:35 +0100 | [diff] [blame] | 27 | # always 'docker' if running docker compose |
| 28 | export TEST_ENV="docker" |
| 29 | |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 30 | # docker compose fails when not running CSIT |
| 31 | if [ -z "$ROBOT_LOG_DIR" ]; then |
| 32 | export ROBOT_LOG_DIR=/tmp/ |
| 33 | export ROBOT_FILES=none |
| 34 | export PROJECT=api |
| 35 | fi |
| 36 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 37 | COMPOSE_FOLDER="${WORKSPACE}"/compose |
| 38 | |
adheli.tavares | 5980fb4 | 2023-03-16 16:31:11 +0000 | [diff] [blame] | 39 | cd ${COMPOSE_FOLDER} |
| 40 | |
| 41 | source export-ports.sh > /dev/null 2>&1 |
| 42 | source get-versions.sh > /dev/null 2>&1 |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 43 | |
| 44 | echo "Collecting logs from docker compose containers..." |
adheli.tavares | f11e6d9 | 2024-08-01 14:18:34 +0100 | [diff] [blame] | 45 | rm -rf *.log |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 46 | |
| 47 | # this will collect logs by service instead of mixing all together |
| 48 | containers=$(docker compose ps --all --format '{{.Service}}') |
| 49 | |
| 50 | IFS=$'\n' read -d '' -r -a item_list <<< "$containers" |
| 51 | for item in "${item_list[@]}" |
| 52 | do |
| 53 | if [ -n "$item" ]; then |
adheli.tavares | f11e6d9 | 2024-08-01 14:18:34 +0100 | [diff] [blame] | 54 | docker compose logs $item >> $item.log |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 55 | fi |
| 56 | done |
| 57 | |
adheli.tavares | 1f339f8 | 2023-02-17 15:14:07 +0000 | [diff] [blame] | 58 | echo "Tearing down containers..." |
adheli.tavares | 80e382e | 2024-05-01 14:08:35 +0100 | [diff] [blame] | 59 | docker compose down -v --remove-orphans |
adheli.tavares | 5980fb4 | 2023-03-16 16:31:11 +0000 | [diff] [blame] | 60 | |
| 61 | cd ${WORKSPACE} |