Skip to content

Commit 51eaeca

Browse files
adoroszlaiarp7
authored andcommitted
HDDS-2211. Collect docker logs if env fails to start (#1553)
1 parent a3fe404 commit 51eaeca

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

hadoop-ozone/dist/src/main/compose/test-all.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ rm "$ALL_RESULT_DIR/*"
2929
RESULT=0
3030
IFS=$'\n'
3131
# shellcheck disable=SC2044
32-
for test in $(find "$SCRIPT_DIR" -name test.sh); do
32+
for test in $(find "$SCRIPT_DIR" -name test.sh | sort); do
3333
echo "Executing test in $(dirname "$test")"
3434

3535
#required to read the .env file from the right location
@@ -41,7 +41,7 @@ for test in $(find "$SCRIPT_DIR" -name test.sh); do
4141
echo "ERROR: Test execution of $(dirname "$test") is FAILED!!!!"
4242
fi
4343
RESULT_DIR="$(dirname "$test")/result"
44-
cp "$RESULT_DIR"/robot-*.xml "$ALL_RESULT_DIR"
44+
cp "$RESULT_DIR"/robot-*.xml "$RESULT_DIR"/docker-*.log "$ALL_RESULT_DIR"/
4545
done
4646

4747
rebot -N "smoketests" -d "$SCRIPT_DIR/result" "$SCRIPT_DIR/result/robot-*.xml"

hadoop-ozone/dist/src/main/compose/testlib.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ wait_for_datanodes(){
7777
sleep 2
7878
done
7979
echo "WARNING! Datanodes are not started successfully. Please check the docker-compose files"
80+
return 1
8081
}
8182

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

8788
create_results_dir
8889

89-
docker-compose -f "$COMPOSE_FILE" down
90-
docker-compose -f "$COMPOSE_FILE" up -d --scale datanode="${datanode_count}" \
90+
docker-compose -f "$COMPOSE_FILE" --no-ansi down
91+
docker-compose -f "$COMPOSE_FILE" --no-ansi up -d --scale datanode="${datanode_count}" \
9192
&& wait_for_datanodes "$COMPOSE_FILE" "${datanode_count}" \
9293
&& sleep 10
9394

9495
if [[ $? -gt 0 ]]; then
95-
docker-compose -f "$COMPOSE_FILE" down
96+
OUTPUT_NAME="$COMPOSE_ENV_NAME"
97+
stop_docker_env
9698
return 1
9799
fi
98100
}
@@ -136,9 +138,9 @@ execute_command_in_container(){
136138

137139
## @description Stops a docker-compose based test environment (with saving the logs)
138140
stop_docker_env(){
139-
docker-compose -f "$COMPOSE_FILE" logs > "$RESULT_DIR/docker-$OUTPUT_NAME.log"
141+
docker-compose -f "$COMPOSE_FILE" --no-ansi logs > "$RESULT_DIR/docker-$OUTPUT_NAME.log"
140142
if [ "${KEEP_RUNNING:-false}" = false ]; then
141-
docker-compose -f "$COMPOSE_FILE" down
143+
docker-compose -f "$COMPOSE_FILE" --no-ansi down
142144
fi
143145
}
144146

0 commit comments

Comments
 (0)