You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by tu...@apache.org on 2012/08/18 18:45:32 UTC

svn commit: r1374610 - in /incubator/oozie/trunk/bin: test-patch test-patch-08-rat test-patch-10-compile test-patch-20-tests

Author: tucu
Date: Sat Aug 18 16:45:31 2012
New Revision: 1374610

URL: http://svn.apache.org/viewvc?rev=1374610&view=rev
Log:
Improvements to test-patch script (tucu)

Modified:
    incubator/oozie/trunk/bin/test-patch
    incubator/oozie/trunk/bin/test-patch-08-rat
    incubator/oozie/trunk/bin/test-patch-10-compile
    incubator/oozie/trunk/bin/test-patch-20-tests

Modified: incubator/oozie/trunk/bin/test-patch
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/bin/test-patch?rev=1374610&r1=1374609&r2=1374610&view=diff
==============================================================================
--- incubator/oozie/trunk/bin/test-patch (original)
+++ incubator/oozie/trunk/bin/test-patch Sat Aug 18 16:45:31 2012
@@ -26,8 +26,10 @@ DEBUG=""
 JIRA_ISSUE=""
 PATCHFILE=""
 TASKSTORUN=""
+TASKSTOSKIP=""
 VCSCLEANUP="true"
 STDOUT="/dev/null"
+MVNPASSTHRU=""
 
 ###############################################################################
 testPatchPrepare() {
@@ -71,7 +73,16 @@ cleanupAndExit() {
 }
 ###############################################################################
 printUsage() {
-  echo "Usage: $0 (--jira=<JIRA ISSUE> | --patch=<PATCH PATH>) [--debug] [--verbose] [--tasks=<TASK,...>] [--no-cleanup]"
+  echo "Usage: $0 <OPTIONS>"
+  echo "          (--jira=<JIRA ISSUE> | --patch=<PATCH PATH>)"
+  echo "          [--tasks=<TASK,...>]"
+  echo "          [--skip-tasks=<TASK,...>]"
+  echo "          [-D<MVN PROPERTY>...]"
+  echo "          [-P<MVN PROFILE>...]"
+  echo "          [--list-tasks]"
+  echo "          [--no-cleanup]"
+  echo "          [--verbose]"
+  echo "          [--script-debug]"
   echo
 }
 ###############################################################################
@@ -88,10 +99,23 @@ parseArgs() {
     --tasks=*)
       TASKSTORUN=${i#*=}
       ;;
+    --skip-tasks=*)
+      TASKSTOSKIP=${i#*=}
+      ;;
+    --list-tasks)
+      listTasks
+      cleanupAndExit 0
+      ;;
+    -D*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
+    -P*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
     --no-cleanup)
       VCSCLEANUP=false
       ;;
-    --debug)
+    --script-debug)
       DEBUG="-x"
       ;;
     --verbose)
@@ -114,6 +138,17 @@ parseArgs() {
   fi
 }
 ###############################################################################
+listTasks() {
+  echo "Available Tasks:"
+  echo ""
+  getAllTasks
+  for taskFile in ${TASKFILES} ; do
+    taskName=`bash $taskFile --taskname`
+    echo "  $taskName"
+  done
+  echo
+}
+###############################################################################
 downloadPatch () {
   PATCHFILE=${TEMPDIR}/test.patch
   jiraPage=${TEMPDIR}/jira.txt
@@ -123,7 +158,9 @@ downloadPatch () {
     echo
     cleanupAndExit 1
   fi
-  relativePatchURL=`grep -o '"/jira/secure/attachment/[0-9]*/[^"]*' ${jiraPage} | grep -v -e 'htm[l]*$' | sort | tail -1 | grep -o '/jira/secure/attachment/[0-9]*/[^"]*'`
+  relativePatchURL=`grep -o '"/jira/secure/attachment/[0-9]*/[^"]*' ${jiraPage} \
+                   | grep -v -e 'htm[l]*$' | sort | tail -1 \
+                   | grep -o '/jira/secure/attachment/[0-9]*/[^"]*'`
   patchURL="${JIRA_URL}${relativePatchURL}"
   patchNum=`echo $patchURL | grep -o '[0-9]*/' | grep -o '[0-9]*'`
   curl ${patchURL} > ${PATCHFILE}
@@ -139,7 +176,8 @@ downloadPatch () {
 applyPatch() {
   echo "Applying patch" >> $STDOUT
   echo "" >> $STDOUT
-  patch -f -E --dry-run -p0 < ${PATCHFILE} | tee ${REPORTDIR}/APPLY-PATCH.txt >> $STDOUT
+  patch -f -E --dry-run -p0 < ${PATCHFILE} | tee ${REPORTDIR}/APPLY-PATCH.txt \
+        >> $STDOUT
   if [[ $? != 0 ]] ; then
     echo "Patch failed to apply to head of branch"
     echo
@@ -158,16 +196,20 @@ applyPatch() {
 }
 ###############################################################################
 run() {
-  task=`$1 --taskname`
+  task=`bash $1 --taskname`
   if [[ "${TASKSTORUN}" == "" || "${TASKSTORUN}" =~ "${task}" ]] ; then
+    if [[ ! "${TASKSTOSKIP}" =~ "${task}" ]] ; then
       echo "  Running test task ${task}"
       outputFile="`basename $1`-$2.out"
-      bash ${DEBUG} $1 --op=$2 --tempdir=${TEMPDIR} --reportdir=${REPORTDIR} --summaryfile=${SUMMARYFILE} --patchfile=${PATCHFILE} ${VERBOSEOPTION} 2>&1 | tee ${TEMPDIR}/${outputFile} >> $STDOUT
+      bash ${DEBUG} $1 --op=$2 --tempdir=${TEMPDIR} --reportdir=${REPORTDIR} \
+           --summaryfile=${SUMMARYFILE} --patchfile=${PATCHFILE} ${MVNPASSTHRU} \
+           ${VERBOSEOPTION} 2>&1 | tee ${TEMPDIR}/${outputFile} >> $STDOUT
       if [[ $? != 0 ]] ; then
         echo "  Failure, check for details ${TEMPDIR}/${outputFile}"
         echo
         cleanupAndExit 1
       fi
+    fi
   fi
 }
 ###############################################################################
@@ -251,4 +293,4 @@ echo "Refer to ${REPORTDIR} for detailed
 echo
 
 grep "\-1" ${SUMMARYFILE} &> /dev/null
-exit `expr $? = 0`
+cleanupAndExit `expr $? = 0`

Modified: incubator/oozie/trunk/bin/test-patch-08-rat
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/bin/test-patch-08-rat?rev=1374610&r1=1374609&r2=1374610&view=diff
==============================================================================
--- incubator/oozie/trunk/bin/test-patch-08-rat (original)
+++ incubator/oozie/trunk/bin/test-patch-08-rat Sat Aug 18 16:45:31 2012
@@ -18,6 +18,7 @@ OP=""
 TEMPDIR=""
 REPORTDIR=""
 SUMMARYFILE=""
+MVNPASSTHRU=""
 
 ###############################################################################
 cleanupAndExit() {
@@ -25,7 +26,7 @@ cleanupAndExit() {
 }
 ###############################################################################
 printUsage() {
-  echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>)"
+  echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [-D<VALUE>...] [-P<VALUE>...]"
   echo
 }
 ###############################################################################
@@ -49,6 +50,12 @@ parseArgs() {
     --summaryfile=*)
       SUMMARYFILE=${i#*=}
       ;;
+    -D*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
+    -P*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
     esac
   done
   if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
@@ -87,10 +94,10 @@ parseArgs "$@"
 
 case $OP in
   pre)
-    mvn apache-rat:check > ${TEMPDIR}/${TASKNAME}-ratwarns-clean.txt
+    mvn apache-rat:check ${MVNPASSTHRU} > ${TEMPDIR}/${TASKNAME}-ratwarns-clean.txt
     ;;
   post)
-    mvn apache-rat:check > ${TEMPDIR}/${TASKNAME}-ratwarns-patch.txt
+    mvn apache-rat:check ${MVNPASSTHRU} > ${TEMPDIR}/${TASKNAME}-ratwarns-patch.txt
     ;;
   report)
     checkForWarnings

Modified: incubator/oozie/trunk/bin/test-patch-10-compile
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/bin/test-patch-10-compile?rev=1374610&r1=1374609&r2=1374610&view=diff
==============================================================================
--- incubator/oozie/trunk/bin/test-patch-10-compile (original)
+++ incubator/oozie/trunk/bin/test-patch-10-compile Sat Aug 18 16:45:31 2012
@@ -19,6 +19,7 @@ TEMPDIR=""
 REPORTDIR=""
 SUMMARYFILE=""
 STDOUT="/dev/null"
+MVNPASSTHRU=""
 
 ###############################################################################
 cleanupAndExit() {
@@ -26,7 +27,7 @@ cleanupAndExit() {
 }
 ###############################################################################
 printUsage() {
-  echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose]"
+  echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose] [-D<VALUE>...] [-P<VALUE>...]"
   echo
 }
 ###############################################################################
@@ -53,6 +54,12 @@ parseArgs() {
     --verbose)
       STDOUT="/dev/stdout"
       ;;
+    -D*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
+    -P*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
     esac
   done
   if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
@@ -90,11 +97,11 @@ parseArgs "$@"
 
 case $OP in
   pre)
-    mvn clean test -PtestPatchCompile -DskipTests | tee ${REPORTDIR}/${TASKNAME}-clean.txt >> $STDOUT
+    mvn clean test -PtestPatchCompile -DskipTests ${MVNPASSTHRU} | tee ${REPORTDIR}/${TASKNAME}-clean.txt >> $STDOUT
     exit $?
     ;;
   post)
-    mvn clean test -PtestPatchCompile -DskipTests | tee ${REPORTDIR}/${TASKNAME}-patch.txt >> $STDOUT
+    mvn clean test -PtestPatchCompile -DskipTests ${MVNPASSTHRU} | tee ${REPORTDIR}/${TASKNAME}-patch.txt >> $STDOUT
     exit $?
     ;;
   report)

Modified: incubator/oozie/trunk/bin/test-patch-20-tests
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/bin/test-patch-20-tests?rev=1374610&r1=1374609&r2=1374610&view=diff
==============================================================================
--- incubator/oozie/trunk/bin/test-patch-20-tests (original)
+++ incubator/oozie/trunk/bin/test-patch-20-tests Sat Aug 18 16:45:31 2012
@@ -19,6 +19,7 @@ TEMPDIR=""
 REPORTDIR=""
 SUMMARYFILE=""
 STDOUT="/dev/null"
+MVNPASSTHRU=""
 
 ###############################################################################
 cleanupAndExit() {
@@ -26,7 +27,7 @@ cleanupAndExit() {
 }
 ###############################################################################
 printUsage() {
-  echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose]"
+  echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose] [-D<VALUE>...] [-P<VALUE>...]"
   echo
 }
 ###############################################################################
@@ -53,6 +54,12 @@ parseArgs() {
     --verbose)
       STDOUT="/dev/stdout"
       ;;
+    -D*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
+    -P*)
+      MVNPASSTHRU="${MVNPASSTHRU} $i"
+      ;;
     esac
   done
   if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
@@ -76,13 +83,20 @@ case $OP in
   pre)
     ;;
   post)
-    mvn test -Dmaven.test.failure.ignore=true -fae -Doozie.test.waitfor.ratio=3 -Dtest.timeout=7200 | tee ${TEMPDIR}/${TASKNAME}.out >> $STDOUT
-    mvn test -Dtest=TestHiveActionExecutor,TestHiveMain -PtestHive -Dmaven.test.failure.ignore=true -fae -Doozie.test.waitfor.ratio=3 -Dtest.timeout=7200 | tee ${TEMPDIR}/${TASKNAME}.out >> $STDOUT
+    mvn test ${MVNPASSTHRU} -Dmaven.test.failure.ignore=true \
+        -Dmaven.test.error.ignore=true -fae -Doozie.test.waitfor.ratio=3 \
+        -Dtest.timeout=7200 | tee ${TEMPDIR}/${TASKNAME}.out >> $STDOUT
+    mvn test -Dtest=TestHiveActionExecutor,TestHiveMain ${MVNPASSTHRU} \
+        -PtestHive -Dmaven.test.failure.ignore=true -Dmaven.test.error.ignore=true \
+        -fae -Doozie.test.waitfor.ratio=3 -Dtest.timeout=7200 \
+        | tee -a ${TEMPDIR}/${TASKNAME}.out >> $STDOUT
     exit 0
     ;;
   report)
     failedTests=`find . -name 'TEST*.xml' | xargs grep  -l -E "<failure|<error" | sed -e "s|.*target/surefire-reports/TEST-|          |g" | sed -e "s|\.xml||g"`
-    echo ">>>${failedTests}<<<"
+    testsRun=`grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | awk '{print $3}' | sed 's/,//' | awk 'BEGIN {count=0} {count=count+$1} END {print "Tests run: "count}'`
+    testsFailed=`grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | awk '{print $5}' | sed 's/,//' | awk 'BEGIN {count=0} {count=count+$1} END {print "Tests failures: "count}'`
+    testsErrors=`grep "Tests run:" ${TEMPDIR}/${TASKNAME}.out | awk '{print $7}' | sed 's/,//' | awk 'BEGIN {count=0} {count=count+$1} END {print "Tests errors: "count}'`
     if [ -n "${failedTests}" ] ; then
       echo "-1 ${TASKNAME} - the patch failed the following testcases:" >> $SUMMARYFILE
       echo "" >> ${SUMMARYFILE}
@@ -91,6 +105,9 @@ case $OP in
     else
       echo "+1 ${TASKNAME}" >> $SUMMARYFILE
     fi
+    echo "  $testsRun" >> $SUMMARYFILE
+    echo "  $testsFailed" >> $SUMMARYFILE
+    echo "  $testsErrors" >> $SUMMARYFILE
     ;;
 esac