This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 387fd6bb92 HDDS-11105. Generate Robot report in container (#6951)
387fd6bb92 is described below

commit 387fd6bb92f8bf7fb8f83f275b36f948242c6894
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri Aug 9 21:13:13 2024 +0200

    HDDS-11105. Generate Robot report in container (#6951)
---
 hadoop-ozone/dev-support/checks/acceptance.sh |  5 ---
 hadoop-ozone/dist/src/main/compose/testlib.sh | 59 +++++++++++++++++++--------
 2 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/hadoop-ozone/dev-support/checks/acceptance.sh 
b/hadoop-ozone/dev-support/checks/acceptance.sh
index 1e16b277af..3425f66605 100755
--- a/hadoop-ozone/dev-support/checks/acceptance.sh
+++ b/hadoop-ozone/dev-support/checks/acceptance.sh
@@ -52,11 +52,6 @@ if [[ "${OZONE_ACCEPTANCE_SUITE}" == "s3a" ]]; then
   download_hadoop_aws "${HADOOP_AWS_DIR}"
 fi
 
-if [[ "${OZONE_ACCEPTANCE_TEST_TYPE}" == "robot" ]]; then
-  install_virtualenv
-  install_robot
-fi
-
 export OZONE_ACCEPTANCE_SUITE OZONE_ACCEPTANCE_TEST_TYPE
 
 cd "$DIST_DIR/compose" || exit 1
diff --git a/hadoop-ozone/dist/src/main/compose/testlib.sh 
b/hadoop-ozone/dist/src/main/compose/testlib.sh
index 44b4f30380..1e9cc85781 100755
--- a/hadoop-ozone/dist/src/main/compose/testlib.sh
+++ b/hadoop-ozone/dist/src/main/compose/testlib.sh
@@ -37,8 +37,6 @@ create_results_dir() {
   #delete previous results
   [[ "${OZONE_KEEP_RESULTS:-}" == "true" ]] || rm -rf "$RESULT_DIR"
   mkdir -p "$RESULT_DIR"
-  #Should be writeable from the docker containers where user is different.
-  chmod ogu+w "$RESULT_DIR"
 }
 
 ## @description find all the test*.sh scripts in the immediate child dirs
@@ -390,22 +388,44 @@ cleanup_docker_images() {
   fi
 }
 
+## @description  Run Robot Framework report generator (rebot) in ozone-runner 
container.
+## @param input directory where source Robot XML files are
+## @param output directory where report should be placed
+## @param rebot options and arguments
+run_rebot() {
+  local input_dir="$(realpath "$1")"
+  local output_dir="$(realpath "$2")"
+
+  shift 2
+
+  local tempdir="$(mktemp -d --suffix rebot -p "${output_dir}")"
+  #Should be writeable from the docker containers where user is different.
+  chmod a+wx "${tempdir}"
+  if docker run --rm -v "${input_dir}":/rebot-input -v 
"${tempdir}":/rebot-output -w /rebot-input \
+      $(get_runner_image_spec) \
+      bash -c "rebot --nostatusrc -d /rebot-output $@"; then
+    mv -v "${tempdir}"/* "${output_dir}"/
+  fi
+  rmdir "${tempdir}"
+}
+
 ## @description  Generate robot framework reports based on the saved results.
 generate_report(){
   local title="${1:-${COMPOSE_ENV_NAME}}"
   local dir="${2:-${RESULT_DIR}}"
   local xunitdir="${3:-}"
 
-  if command -v rebot > /dev/null 2>&1; then
-     #Generate the combined output and return with the right exit code (note: 
robot = execute test, rebot = generate output)
-     if [ -z "${xunitdir}" ]; then
-       rebot --reporttitle "${title}" -N "${title}" -d "${dir}" "${dir}/*.xml"
-     else
-       rebot --reporttitle "${title}" -N "${title}" --xunit 
${xunitdir}/TEST-ozone.xml -d "${dir}" "${dir}/*.xml"
-     fi
-  else
-     echo "Robot framework is not installed, the reports cannot be generated 
(sudo pip install robotframework)."
-     exit 1
+  if [[ -n "$(find "${dir}" -mindepth 1 -maxdepth 1 -name "*.xml")" ]]; then
+    xunit_args=""
+    if [[ -n "${xunitdir}" ]] && [[ -e "${xunitdir}" ]]; then
+      xunit_args="--xunit TEST-ozone.xml"
+    fi
+
+    run_rebot "$dir" "$dir" "--reporttitle '${title}' -N '${title}' 
${xunit_args} *.xml"
+
+    if [[ -n "${xunit_args}" ]]; then
+      mv -v "${dir}"/TEST-ozone.xml "${xunitdir}"/ || rm -f 
"${dir}"/TEST-ozone.xml
+    fi
   fi
 }
 
@@ -429,8 +449,8 @@ copy_results() {
     target_dir="${target_dir}/${test_script_name}"
   fi
 
-  if command -v rebot > /dev/null 2>&1 && [[ -n "$(find "${result_dir}" -name 
"*.xml")" ]]; then
-    rebot --nostatusrc -N "${test_name}" -l NONE -r NONE -o 
"${all_result_dir}/${test_name}.xml" "${result_dir}"/*.xml \
+  if [[ -n "$(find "${result_dir}" -mindepth 1 -maxdepth 1 -name "*.xml")" ]]; 
then
+    run_rebot "${result_dir}" "${all_result_dir}" "-N '${test_name}' -l NONE 
-r NONE -o '${test_name}.xml' *.xml" \
       && rm -fv "${result_dir}"/*.xml "${result_dir}"/log.html 
"${result_dir}"/report.html
   fi
 
@@ -505,14 +525,21 @@ prepare_for_binary_image() {
 ## @description Define variables required for using `ozone-runner` docker image
 ##   (no binaries included)
 ## @param `ozone-runner` image version (optional)
-prepare_for_runner_image() {
+get_runner_image_spec() {
   local default_version=${docker.ozone-runner.version} # set at build-time 
from Maven property
   local runner_version=${OZONE_RUNNER_VERSION:-${default_version}} # may be 
specified by user running the test
   local runner_image=${OZONE_RUNNER_IMAGE:-apache/ozone-runner} # may be 
specified by user running the test
   local v=${1:-${runner_version}} # prefer explicit argument
 
+  echo "${runner_image}:${v}"
+}
+
+## @description Define variables required for using `ozone-runner` docker image
+##   (no binaries included)
+## @param `ozone-runner` image version (optional)
+prepare_for_runner_image() {
   export OZONE_DIR=/opt/hadoop
-  export OZONE_IMAGE="${runner_image}:${v}"
+  export OZONE_IMAGE="$(get_runner_image_spec "$@")"
 }
 
 ## @description Executing the Ozone Debug CLI related robot tests


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to