Skip to content

Commit

Permalink
HDDS-2211. Collect docker logs if env fails to start (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai authored and arp7 committed Oct 3, 2019
1 parent a3fe404 commit 51eaeca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions hadoop-ozone/dist/src/main/compose/test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rm "$ALL_RESULT_DIR/*"
RESULT=0
IFS=$'\n'
# 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")"

#required to read the .env file from the right location
Expand All @@ -41,7 +41,7 @@ for test in $(find "$SCRIPT_DIR" -name test.sh); do
echo "ERROR: Test execution of $(dirname "$test") is FAILED!!!!"
fi
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

rebot -N "smoketests" -d "$SCRIPT_DIR/result" "$SCRIPT_DIR/result/robot-*.xml"
Expand Down
12 changes: 7 additions & 5 deletions hadoop-ozone/dist/src/main/compose/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ wait_for_datanodes(){
sleep 2
done
echo "WARNING! Datanodes are not started successfully. Please check the docker-compose files"
return 1
}

## @description Starts a docker-compose based test environment
Expand All @@ -86,13 +87,14 @@ start_docker_env(){

create_results_dir

docker-compose -f "$COMPOSE_FILE" down
docker-compose -f "$COMPOSE_FILE" up -d --scale datanode="${datanode_count}" \
docker-compose -f "$COMPOSE_FILE" --no-ansi down
docker-compose -f "$COMPOSE_FILE" --no-ansi up -d --scale datanode="${datanode_count}" \
&& wait_for_datanodes "$COMPOSE_FILE" "${datanode_count}" \
&& sleep 10

if [[ $? -gt 0 ]]; then
docker-compose -f "$COMPOSE_FILE" down
OUTPUT_NAME="$COMPOSE_ENV_NAME"
stop_docker_env
return 1
fi
}
Expand Down Expand Up @@ -136,9 +138,9 @@ execute_command_in_container(){

## @description Stops a docker-compose based test environment (with saving the logs)
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
docker-compose -f "$COMPOSE_FILE" down
docker-compose -f "$COMPOSE_FILE" --no-ansi down
fi
}

Expand Down

0 comments on commit 51eaeca

Please sign in to comment.