HDDS-2211. Collect docker logs if env fails to start (#1553)

This commit is contained in:
Doroszlai, Attila 2019-10-03 21:44:04 +02:00 committed by Arpit Agarwal
parent a3fe404244
commit 51eaecab20
2 changed files with 9 additions and 7 deletions

View File

@ -29,7 +29,7 @@ rm "$ALL_RESULT_DIR/*"
RESULT=0 RESULT=0
IFS=$'\n' IFS=$'\n'
# shellcheck disable=SC2044 # shellcheck disable=SC2044
for test in $(find "$SCRIPT_DIR" -name test.sh); do for test in $(find "$SCRIPT_DIR" -name test.sh | sort); do
echo "Executing test in $(dirname "$test")" echo "Executing test in $(dirname "$test")"
#required to read the .env file from the right location #required to read the .env file from the right location
@ -41,7 +41,7 @@ for test in $(find "$SCRIPT_DIR" -name test.sh); do
echo "ERROR: Test execution of $(dirname "$test") is FAILED!!!!" echo "ERROR: Test execution of $(dirname "$test") is FAILED!!!!"
fi fi
RESULT_DIR="$(dirname "$test")/result" RESULT_DIR="$(dirname "$test")/result"
cp "$RESULT_DIR"/robot-*.xml "$ALL_RESULT_DIR" cp "$RESULT_DIR"/robot-*.xml "$RESULT_DIR"/docker-*.log "$ALL_RESULT_DIR"/
done done
rebot -N "smoketests" -d "$SCRIPT_DIR/result" "$SCRIPT_DIR/result/robot-*.xml" rebot -N "smoketests" -d "$SCRIPT_DIR/result" "$SCRIPT_DIR/result/robot-*.xml"

View File

@ -77,6 +77,7 @@ wait_for_datanodes(){
sleep 2 sleep 2
done done
echo "WARNING! Datanodes are not started successfully. Please check the docker-compose files" echo "WARNING! Datanodes are not started successfully. Please check the docker-compose files"
return 1
} }
## @description Starts a docker-compose based test environment ## @description Starts a docker-compose based test environment
@ -86,13 +87,14 @@ start_docker_env(){
create_results_dir create_results_dir
docker-compose -f "$COMPOSE_FILE" down docker-compose -f "$COMPOSE_FILE" --no-ansi down
docker-compose -f "$COMPOSE_FILE" up -d --scale datanode="${datanode_count}" \ docker-compose -f "$COMPOSE_FILE" --no-ansi up -d --scale datanode="${datanode_count}" \
&& wait_for_datanodes "$COMPOSE_FILE" "${datanode_count}" \ && wait_for_datanodes "$COMPOSE_FILE" "${datanode_count}" \
&& sleep 10 && sleep 10
if [[ $? -gt 0 ]]; then if [[ $? -gt 0 ]]; then
docker-compose -f "$COMPOSE_FILE" down OUTPUT_NAME="$COMPOSE_ENV_NAME"
stop_docker_env
return 1 return 1
fi fi
} }
@ -136,9 +138,9 @@ execute_command_in_container(){
## @description Stops a docker-compose based test environment (with saving the logs) ## @description Stops a docker-compose based test environment (with saving the logs)
stop_docker_env(){ stop_docker_env(){
docker-compose -f "$COMPOSE_FILE" logs > "$RESULT_DIR/docker-$OUTPUT_NAME.log" docker-compose -f "$COMPOSE_FILE" --no-ansi logs > "$RESULT_DIR/docker-$OUTPUT_NAME.log"
if [ "${KEEP_RUNNING:-false}" = false ]; then if [ "${KEEP_RUNNING:-false}" = false ]; then
docker-compose -f "$COMPOSE_FILE" down docker-compose -f "$COMPOSE_FILE" --no-ansi down
fi fi
} }