OOZIE-2817 Increase test case stability in pre-commit job (gezapeti)

Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/cb03d287
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/cb03d287
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/cb03d287

Branch: refs/heads/oya
Commit: cb03d287e876882561dc5497aefec404895da515
Parents: 559595d
Author: Gezapeti Cseh <gezap...@gmail.com>
Authored: Wed Mar 22 11:50:24 2017 +0100
Committer: Gezapeti Cseh <gezap...@gmail.com>
Committed: Wed Mar 22 11:50:24 2017 +0100

----------------------------------------------------------------------
 bin/test-patch-20-tests | 31 ++++++++++++++++++++++++-------
 release-log.txt         |  1 +
 2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/cb03d287/bin/test-patch-20-tests
----------------------------------------------------------------------
diff --git a/bin/test-patch-20-tests b/bin/test-patch-20-tests
index d096575..b3a0fcd 100755
--- a/bin/test-patch-20-tests
+++ b/bin/test-patch-20-tests
@@ -91,16 +91,29 @@ case $OP in
         -Dmaven.test.error.ignore=true -fae -Doozie.test.waitfor.ratio=3 \
         -Dtest.timeout=7200 | tee ${TEMPDIR}/${TASKNAME}.out >> $STDOUT
     exitCode=${PIPESTATUS[0]}
+    failures=$(find . -name '*\.txt' | grep target/surefire-reports | xargs 
grep  "<<<" | grep -v "Tests run:" | sed 's/.*\.txt\://' | sed 's/ .*//' | grep 
-o '(\(.*\))' | tr -d '()'  | uniq | awk '{ sub ("\\\\$", ""); printf "%s", 
$0"," } END { print "" }')
+    if [ -n "${failures}" ]; then
+       echo "Rerunning failed tests: ${failures}"
+       echo $FAILURES > ${TEMPDIR}/${TASKNAME}.flakies.out
+       mvn test ${MVNPASSTHRU} -Dmaven.test.failure.ignore=true \
+        -Dmaven.test.error.ignore=true -fae -Doozie.test.waitfor.ratio=3 \
+        -Dtest.timeout=7200 -Dtest=${failures} | tee 
${TEMPDIR}/${TASKNAME}.rerun.out >> $STDOUT
+       exitCode=${PIPESTATUS[0]}
+    else
+       echo "No Reruns required, all tests passed."
+    fi
     echo "$exitCode" >  ${TEMPDIR}/${TASKNAME}.exitCode
     ;;
   report)
-    failedTests=` find . -name '*\.txt' | grep target/surefire-reports | xargs 
grep  "<<< FAILURE" | grep -v "Tests run:" | sed 's/.*\.txt\://' | sed 's/ 
.*//'`
-    testsWithError=` find . -name '*\.txt' | grep target/surefire-reports | 
xargs grep  "<<< ERROR" | grep -v "Tests run:" | sed 's/.*\.txt\://' | sed 's/ 
.*//'`
-    testsRun=`grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | grep -v " Time 
elapsed:" | awk '{print $3}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}'`
-    testsFailed=`grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | grep -v " Time 
elapsed:" | awk '{print $5}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}'`
-    testsErrors=`grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | grep -v " Time 
elapsed:" | awk '{print $7}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}'`
-    hasFailures=`expr $testsFailed + $testsErrors`
-    testsExitCode=`cat ${TEMPDIR}/${TASKNAME}.exitCode`
+    failedTests=$(find . -name '*\.txt' | grep target/surefire-reports | xargs 
grep  "<<< FAILURE" | grep -v "Tests run:" | sed 's/.*\.txt\://' | sed 's/ 
.*//')
+    testsWithError=$(find . -name '*\.txt' | grep target/surefire-reports | 
xargs grep  "<<< ERROR" | grep -v "Tests run:" | sed 's/.*\.txt\://' | sed 's/ 
.*//')
+    testsRun=$(grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | grep -v " Time 
elapsed:" | awk '{print $3}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}')
+    testsFailed=$(grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | grep -v " 
Time elapsed:" | awk '{print $5}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}')
+    testsErrors=$(grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | grep -v " 
Time elapsed:" | awk '{print $7}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}')
+    hasFailures=$(expr $testsFailed + $testsErrors)
+    testsExitCode=$(cat ${TEMPDIR}/${TASKNAME}.exitCode)
+    flakyTests=$(cat ${TEMPDIR}/${TASKNAME}.flakies.out)
+    testsReRun=$(grep "Tests run:" ${TEMPDIR}/${TASKNAME}.rerun.out | grep -v 
" Time elapsed:" | awk '{print $3}' | sed 's/,//' | awk 'BEGIN {count=0} 
{count=count+$1} END {print count}')
     if [[ $hasFailures != 0 ]] ; then
       echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
       echo ".    Tests run: $testsRun" >> $SUMMARYFILE
@@ -120,6 +133,10 @@ case $OP in
       else
         echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
         echo ".    Tests run: $testsRun" >> $SUMMARYFILE
+        if [ -n "${flakyTests}" ]; then
+          echo ".    Tests rerun: ${testsReRun}" >> $SUMMARYFILE
+          echo ".    Tests failed at first run: ${flakyTests}" >> $SUMMARYFILE
+        fi
       fi
     fi
     ;;

http://git-wip-us.apache.org/repos/asf/oozie/blob/cb03d287/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 0f96d47..b1c1d2b 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 4.4.0 release (trunk - unreleased)
 
+OOZIE-2817 Increase test case stability in pre-commit job (gezapeti)
 OOZIE-2820 Fix more spelling errors in exceptions and logging (lzeke via 
rkanter)
 OOZIE-2816 Strip out the first command word from Sqoop action if its "sqoop" 
(harsh)
 OOZIE-2813 Remove tabs and trailing whitespaces from oozie-defaul.xml 
(gezapeti)

Reply via email to