Browse Source

HADOOP-9583. test-patch gives +1 despite build failure when running tests. Contributed by Jason Lowe.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1513200 13f79535-47bb-0310-9956-ffa450edef68
Kihwal Lee 11 years ago
parent
commit
dedbd19bea
2 changed files with 41 additions and 8 deletions
  1. 38 8
      dev-support/test-patch.sh
  2. 3 0
      hadoop-common-project/hadoop-common/CHANGES.txt

+ 38 - 8
dev-support/test-patch.sh

@@ -731,32 +731,62 @@ of hadoop-common prior to running the unit tests in $ordered_modules"
           fi
       fi
   fi
+  failed_test_builds=""
+  test_timeouts=""
   for module in $ordered_modules; do
     cd $module
+    module_suffix=`basename ${module}`
+    test_logfile=$PATCH_DIR/testrun_${module_suffix}.txt
     echo "  Running tests in $module"
     echo "  $MVN clean install -fn $NATIVE_PROFILE $REQUIRE_TEST_LIB_HADOOP -D${PROJECT_NAME}PatchProcess"
-    $MVN clean install -fn $NATIVE_PROFILE $REQUIRE_TEST_LIB_HADOOP -D${PROJECT_NAME}PatchProcess
+    $MVN clean install -fae $NATIVE_PROFILE $REQUIRE_TEST_LIB_HADOOP -D${PROJECT_NAME}PatchProcess > $test_logfile 2>&1
+    test_build_result=$?
+    cat $test_logfile
+    module_test_timeouts=`$AWK '/^Running / { if (last) { print last } last=$2 } /^Tests run: / { last="" }' $test_logfile`
+    if [[ -n "$module_test_timeouts" ]] ; then
+      test_timeouts="$test_timeouts
+$module_test_timeouts"
+    fi
     module_failed_tests=`find . -name 'TEST*.xml' | xargs $GREP  -l -E "<failure|<error" | sed -e "s|.*target/surefire-reports/TEST-|                  |g" | sed -e "s|\.xml||g"`
-    # With -fn mvn always exits with a 0 exit code.  Because of this we need to
-    # find the errors instead of using the exit code.  We assume that if the build
-    # failed a -1 is already given for that case
     if [[ -n "$module_failed_tests" ]] ; then
       failed_tests="${failed_tests}
 ${module_failed_tests}"
     fi
+    if [[ $test_build_result != 0 && -z "$module_failed_tests" && -z "$module_test_timeouts" ]] ; then
+      failed_test_builds="$module $failed_test_builds"
+    fi
     cd -
   done
+  result=0
+  comment_prefix="    {color:red}-1 core tests{color}."
   if [[ -n "$failed_tests" ]] ; then
     JIRA_COMMENT="$JIRA_COMMENT
 
-    {color:red}-1 core tests{color}.  The patch failed these unit tests in $modules:
+$comment_prefix  The patch failed these unit tests in $modules:
 $failed_tests"
-    return 1
+    comment_prefix="                                    "
+    result=1
   fi
-  JIRA_COMMENT="$JIRA_COMMENT
+  if [[ -n "$test_timeouts" ]] ; then
+    JIRA_COMMENT="$JIRA_COMMENT
+
+$comment_prefix  The following test timeouts occurred in $modules:
+$test_timeouts"
+    comment_prefix="                                    "
+    result=1
+  fi
+  if [[ -n "$failed_test_builds" ]] ; then
+    JIRA_COMMENT="$JIRA_COMMENT
+
+$comment_prefix  The test build failed in $failed_test_builds"
+    result=1
+  fi
+  if [[ $result == 0 ]] ; then
+    JIRA_COMMENT="$JIRA_COMMENT
 
     {color:green}+1 core tests{color}.  The patch passed unit tests in $modules."
-  return 0
+  fi
+  return $result
 }
 
 ###############################################################################

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -268,6 +268,9 @@ Trunk (Unreleased)
     HADOOP-9433 TestLocalFileSystem#testHasFileDescriptor leaks file handle
     (Chris Nauroth via sanjay)
 
+    HADOOP-9583. test-patch gives +1 despite build failure when running tests.
+    (jlowe via kihwal)
+
   OPTIMIZATIONS
 
     HADOOP-7761. Improve the performance of raw comparisons. (todd)