Преглед изворни кода

HDDS-616. Collect all the robot test outputs and return with the right exit code. Contributed by Elek, Marton.

Márton Elek пре 6 година
родитељ
комит
820d1ec5d2
1 измењених фајлова са 22 додато и 3 уклоњено
  1. 22 3
      hadoop-ozone/dist/src/main/smoketest/test.sh

+ 22 - 3
hadoop-ozone/dist/src/main/smoketest/test.sh

@@ -17,19 +17,35 @@
 
 set -e
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
+RESULT_DIR=result
+#delete previous results
+rm -rf "${DIR:?}/$RESULT_DIR"
+mkdir -p "$DIR/$RESULT_DIR"
+#Should be writeable from the docker containers where user is different.
+chmod ogu+w "$DIR/$RESULT_DIR"
 
 execute_tests(){
-  COMPOSE_FILE=$DIR/../compose/$1/docker-compose.yaml
+  COMPOSE_DIR=$1
+  COMPOSE_FILE=$DIR/../compose/$COMPOSE_DIR/docker-compose.yaml
   TESTS=$2
-  echo "Executing test ${TESTS[*]} with $COMPOSE_FILE"
+  echo "-------------------------------------------------"
+  echo "Executing test(s): [${TESTS[*]}]"
+  echo ""
+  echo "  Cluster type:      $COMPOSE_DIR"
+  echo "  Compose file:      $COMPOSE_FILE"
+  echo "  Output dir:        $DIR/$RESULT_DIR"
+  echo "  Command to rerun:  ./test.sh --keep --env $COMPOSE_DIR $TESTS"
+  echo "-------------------------------------------------"
   docker-compose -f "$COMPOSE_FILE" down
   docker-compose -f "$COMPOSE_FILE" up -d
   echo "Waiting 30s for cluster start up..."
   sleep 30
   for TEST in "${TESTS[@]}"; do
+     TITLE="Ozone $TEST tests with $COMPOSE_DIR cluster"
      set +e
-     docker-compose -f "$COMPOSE_FILE" exec datanode python -m robot "smoketest/$TEST"
+     docker-compose -f "$COMPOSE_FILE" exec datanode python -m robot --log NONE --report NONE "${OZONE_ROBOT_OPTS[@]}" --output "smoketest/$RESULT_DIR/robot-$COMPOSE_DIR-${TEST//\//_/}.xml" --logtitle "$TITLE" --reporttitle "$TITLE" "smoketest/$TEST"
      set -e
+     docker-compose -f "$COMPOSE_FILE" logs > "$DIR/$RESULT_DIR/docker-$COMPOSE_DIR-${TEST//\//_/}.log"
   done
   if [ "$KEEP_RUNNING" = false ]; then
      docker-compose -f "$COMPOSE_FILE" down
@@ -99,3 +115,6 @@ if [ "$RUN_ALL" = true ]; then
 else
    execute_tests "$DOCKERENV" "${POSITIONAL[@]}"
 fi
+
+#Generate the combined output and return with the right exit code (note: robot = execute test, rebot = generate output)
+docker run --rm -it -v "$DIR/..:/opt/hadoop" apache/hadoop-runner rebot -d "smoketest/$RESULT_DIR" "smoketest/$RESULT_DIR/robot-*.xml"