knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject knox git commit: [KNOX-169] - Test issue for patch test automation via PreCommit-Knox-Build job
Date Fri, 29 Jan 2016 20:35:21 GMT
Repository: knox
Updated Branches:
  refs/heads/master cd11749f4 -> 878c6ecc5


[KNOX-169] - Test issue for patch test automation via PreCommit-Knox-Build job


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

Branch: refs/heads/master
Commit: 878c6ecc5ca90578dd94e4c582fbf52317854cbf
Parents: cd11749
Author: Kevin Minder <kminder@apache.org>
Authored: Fri Jan 29 15:35:16 2016 -0500
Committer: Kevin Minder <kminder@apache.org>
Committed: Fri Jan 29 15:35:16 2016 -0500

----------------------------------------------------------------------
 dev-support/find-new-patch-available-jiras      | 129 ++++++
 dev-support/raw-check-patch                     |  47 +++
 dev-support/test-patch                          | 416 +++++++++++++++++++
 dev-support/test-patch-00-clean                 | 100 +++++
 dev-support/test-patch-05-patch-raw-analysis    | 165 ++++++++
 dev-support/test-patch-08-rat                   | 132 ++++++
 dev-support/test-patch-09-javadoc               | 118 ++++++
 dev-support/test-patch-10-compile               | 144 +++++++
 dev-support/test-patch-11-findbugs              | 156 +++++++
 dev-support/test-patch-20-tests                 | 125 ++++++
 dev-support/test-patch-30-dist                  | 106 +++++
 ...test-patch-find-new-patch-available-jiras.sh | 127 ------
 dev-support/test-patch.sh                       | 413 ------------------
 13 files changed, 1638 insertions(+), 540 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/find-new-patch-available-jiras
----------------------------------------------------------------------
diff --git a/dev-support/find-new-patch-available-jiras b/dev-support/find-new-patch-available-jiras
new file mode 100755
index 0000000..f5253f1
--- /dev/null
+++ b/dev-support/find-new-patch-available-jiras
@@ -0,0 +1,129 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TEMPDIR=${BASEDIR}/tmp
+
+JIRAAVAILPATCHQUERY="https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+in+%28KNOX%29+AND+status+%3D+%22Patch+Available%22+ORDER+BY+updated+DESC&tempMax=1000"
+TESTPATCHJOBURL="https://builds.apache.org/job/PreCommit-Knox-Build"
+TOKEN=""
+SUBMIT="false"
+DELETEHISTORYFILE="false"
+
+RUNTESTSFILE=${BASEDIR}/TESTED_PATCHES.txt
+
+printUsage() {
+    echo "Usage: $0 <OPTIONS>"
+    echo "          --submit --token=<KNOX PRECOMMIT JOB TOKEN>"
+    echo "          [--delete-history-file]"
+    echo "          [--script-debug]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --submit)
+            SUBMIT="true"
+            ;;
+        --token=*)
+            TOKEN=${i#*=}
+            ;;
+        --script-debug)
+            DEBUG="-x"
+            ;;
+        --delete-history-file)
+            DELETEHISTORYFILE="true"
+            ;;
+        *)
+            echo "Invalid option"
+            echo
+            printUsage
+            exit 1
+            ;;
+        esac
+    done
+    if [[ "$SUBMIT" == "true" && "${TOKEN}" == "" ]] ; then
+        echo "Token has not been specified"
+        echo
+        printUsage
+        exit 1
+    fi
+}
+
+###############################################################################
+findAndSubmitAvailablePatches() {
+    ## Grab all the key (issue numbers) and largest attachment id for each item in the XML
+    curl --fail --location --retry 3 "${JIRAAVAILPATCHQUERY}" > ${TEMPDIR}/patch-availables.xml
+    if [ "$?" != "0" ] ; then
+        echo "Could not retrieve available patches from JIRA"
+        exit 1
+    fi
+    xpath -e "//item/key/text() | //item/attachments/attachment[not(../attachment/@id > @id)]/@id" \
+        ${TEMPDIR}/patch-availables.xml > ${TEMPDIR}/patch-attachments.element
+
+    ### Replace newlines with nothing, then replace id=" with =, then replace " with newline
+    ### to yield lines with pairs (issueNumber,largestAttachmentId). Example: KNOX-123,456984
+    cat ${TEMPDIR}/patch-attachments.element \
+        | awk '{ if ( $1 ~ /^KNOX\-/) {JIRA=$1 }; if ($1 ~ /id=/) { print JIRA","$1} }' \
+        | sed 's/id\="//' | sed 's/"//' > ${TEMPDIR}/patch-availables.pair
+
+    ### Iterate through issue list and find the (issueNumber,largestAttachmentId) pairs that have
+    ### not been tested (ie don't already exist in the patch_tested.txt file
+    touch ${RUNTESTSFILE}
+    cat ${TEMPDIR}/patch-availables.pair | while read PAIR ; do
+        set +e
+        COUNT=`grep -c "$PAIR" ${RUNTESTSFILE}`
+        set -e
+        if [ "$COUNT" -lt "1" ] ; then
+        ### Parse $PAIR into project, issue number, and attachment id
+            ISSUE=`echo $PAIR | sed -e "s/,.*$//"`
+            echo "Found new patch for issue $ISSUE"
+            if [ "$SUBMIT" == "true" ]; then
+            ### Kick off job
+                echo "Submitting job for issue $ISSUE"
+                curl --fail --location --retry 3 \
+                    "${TESTPATCHJOBURL}/buildWithParameters?token=${TOKEN}&JIRA_NUMBER=${ISSUE}" > /dev/null
+                if [ "$?" != "0" ] ; then
+                    echo "Could not submit precommit job for $ISSUE"
+                    exit 1
+                fi
+            fi
+            ### Mark this pair as tested by appending to file
+            echo "$PAIR" >> ${RUNTESTSFILE}
+        fi
+    done
+}
+###############################################################################
+
+mkdir -p ${TEMPDIR} 2>&1 $STDOUT
+
+parseArgs "$@"
+
+if [ -n "${DEBUG}" ] ; then
+    set -x
+fi
+
+if [ "${DELETEHISTORYFILE}" == "true" ] ; then
+    rm ${RUNTESTSFILE}
+fi
+
+findAndSubmitAvailablePatches
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/raw-check-patch
----------------------------------------------------------------------
diff --git a/dev-support/raw-check-patch b/dev-support/raw-check-patch
new file mode 100644
index 0000000..b3bfd01
--- /dev/null
+++ b/dev-support/raw-check-patch
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+printTrailingSpaces() {
+    PATCH=$1
+    cat $PATCH | awk '/^+/ { if (/ $/) { print "\tL" NR ":" $0} }'
+}
+
+printTabs() {
+    PATCH=$1
+    cat $PATCH | awk '/^+/ { if (/\t/) { print "\tL" NR ":" $0 } }'
+}
+
+printAuthors() {
+    PATCH=$1
+    cat $PATCH | awk '/^+/ { L=tolower($0); if (L ~ /.*\*.* @author/) { print "\tL" NR ":" $0 } }'
+}
+
+printLongLines() {
+    PATCH=$1
+    cat $PATCH | awk '/^+/ { if ( length > 121 ) { print "\tL" NR ":" $0 } }'
+}
+
+if [[ "X$(basename -- "$0")" = "Xraw-check-patch" ]]; then
+    echo Trailing spaces
+    printTrailingSpaces $1
+    echo
+    echo Tabs
+    printTabs $1
+    echo
+    echo Authors
+    printAuthors $1
+    echo
+    echo Long lines
+    printLongLines $1
+fi

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch
----------------------------------------------------------------------
diff --git a/dev-support/test-patch b/dev-support/test-patch
new file mode 100755
index 0000000..e81d653
--- /dev/null
+++ b/dev-support/test-patch
@@ -0,0 +1,416 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TESTPATCHDIRNAME=test-patch
+TESTPATCHDIR=${BASEDIR}/${TESTPATCHDIRNAME}
+TOOLSDIR=${TESTPATCHDIR}/tools
+TEMPDIR=${TESTPATCHDIR}/tmp
+REPORTDIR=${TESTPATCHDIR}/reports
+SUMMARYFILE=${REPORTDIR}/TEST-SUMMARY.jira
+SUMMARYFILETXT=${REPORTDIR}/TEST-SUMMARY.txt
+
+JIRAHOST="https://issues.apache.org"
+JIRAURL="${JIRAHOST}/jira"
+JIRAURLISSUEPREFIX="${JIRAURL}/browse/"
+
+JIRAUPDATE="false"
+JIRAUSER=""
+JIRAPASSWORD=""
+
+
+VERBOSEOPTION=""
+JIRAISSUE=""
+PATCHFILE=""
+TASKSTORUN=""
+TASKSTOSKIP=""
+RESETSCM="false"
+DIRTYSCM="false"
+STDOUT="/dev/null"
+MVNPASSTHRU=""
+
+###############################################################################
+gitOrSvn() {
+    SCM="NONE"
+    which git &> /dev/null
+    if [[ $? == 0 ]] ; then
+        git status &> /dev/null
+        if [[ $? == 0 ]] ; then
+            SCM="git"
+        fi
+    fi
+    if [ "${SCM}" == "NONE" ] ; then
+        which svn &> /dev/null
+        if [[ $? == 0 ]] ; then
+            svnOutput=`svn status 2>&1`
+            if [[  "$svnOutput" != *"is not a working copy" ]] ; then
+                SCM="svn"
+            fi
+        fi
+    fi
+    if [ "${SCM}" == "NONE" ] ; then
+        echo "The current workspace is not under Source Control (GIT or SVN)"
+        exit 1
+    fi
+}
+###############################################################################
+prepareSCM() {
+    gitOrSvn
+    if [ "${DIRTYSCM}" != "true" ] ; then
+        if [ "${RESETSCM}" == "true" ] ; then
+            if [ "${SCM}" == "git" ] ; then
+                git reset --hard HEAD > /dev/null
+                git clean -f -d -e $TESTPATCHDIRNAME > /dev/null
+            fi
+            if [ "${SCM}" == "svn" ] ; then
+                svn revert -R . > /dev/null
+                svn status | grep "\?" | awk '{print $2}' | xargs rm -rf
+            fi
+        else
+            echo "It should not happen DIRTYSCM=false & RESETSCM=false"
+            exit 1
+        fi
+        echo "Cleaning local ${SCM} workspace" >> ${SUMMARYFILE}
+    else
+        echo "WARNING: Running test-patch on a dirty local ${SCM} workspace" >> ${SUMMARYFILE}
+    fi
+}
+###############################################################################
+prepareTestPatchDirs() {
+    mkdir -p ${TESTPATCHDIR} 2> /dev/null
+    rm -rf ${REPORTDIR} 2> /dev/null
+    rm -rf ${TEMPDIR} 2> /dev/null
+    mkdir -p ${TOOLSDIR} 2> /dev/null
+    mkdir -p ${TEMPDIR} 2> /dev/null
+    mkdir -p ${REPORTDIR} 2> /dev/null
+    if [ ! -e "${TESTPATCHDIR}" ] ; then
+        echo "Could not create test-patch/ dir"
+        exit 1
+    fi
+}
+###############################################################################
+updateJira() {
+    if [[ "${JIRAUPDATE}" != "" && "${JIRAISSUE}" != "" ]] ; then
+        if [[ "$JIRAPASSWORD" != "" ]] ; then
+            JIRACLI=${TOOLSDIR}/jira-cli/jira.sh
+            if [ ! -e "${JIRACLI}" ] ; then
+                curl https://bobswift.atlassian.net/wiki/download/attachments/16285777/jira-cli-2.6.0-distribution.zip > ${TEMPDIR}/jira-cli.zip
+                if [ $? != 0 ] ; then
+                    echo
+                    echo "Could not download jira-cli tool, thus no JIRA updating"
+                    echo
+                    exit 1
+                fi
+                mkdir ${TEMPDIR}/jira-cli-tmp
+                (cd ${TEMPDIR}/jira-cli-tmp;jar xf ${TEMPDIR}/jira-cli.zip; mv jira-cli-2.6.0 ${TOOLSDIR}/jira-cli)
+                chmod u+x ${JIRACLI}
+            fi
+            echo "Adding comment to JIRA"
+            comment=`cat ${SUMMARYFILE}`
+            $JIRACLI -s $JIRAURL -a addcomment -u $JIRAUSER -p "$JIRAPASSWORD" --comment "$comment" --issue $JIRAISSUE
+            echo
+        else
+            echo "Skipping JIRA update"
+            echo
+        fi
+    fi
+}
+###############################################################################
+cleanupAndExit() {
+    updateJira
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 <OPTIONS>"
+    echo "          (--jira=<JIRA ISSUE> | --patch=<PATCH PATH>)"
+    echo "          (--reset-scm | --dirty-scm)"
+    echo "          [--tasks=<TASK,...>]"
+    echo "          [--skip-tasks=<TASK,...>]"
+    echo "          [--jira-cli=<JIRA CLIENT>]"
+    echo "          [--jira-user=<JIRA USER>]"
+    echo "          [--jira-password=<JIRA PASSWORD>]"
+    echo "          [-D<MVN PROPERTY>...]"
+    echo "          [-P<MVN PROFILE>...]"
+    echo "          [--list-tasks]"
+    echo "          [--verbose]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --jira=*)
+            JIRAISSUE=${i#*=}
+            ;;
+        --patch=*)
+            PATCHFILE=${i#*=}
+            ;;
+        --tasks=*)
+            TASKSTORUN=${i#*=}
+            ;;
+        --skip-tasks=*)
+            TASKSTOSKIP=${i#*=}
+            ;;
+        --list-tasks)
+            listTasks
+            cleanupAndExit 0
+            ;;
+        --jira-cli=*)
+            JIRACLI=${i#*=}
+            ;;
+        --jira-user=*)
+            JIRAUSER=${i#*=}
+            ;;
+        --jira-password=*)
+            JIRAPASSWORD=${i#*=}
+            JIRAUPDATE="true"
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        --reset-scm)
+            RESETSCM="true"
+            ;;
+        --dirty-scm)
+            DIRTYSCM="true"
+            ;;
+        --verbose)
+            VERBOSEOPTION="--verbose"
+            STDOUT="/dev/stdout"
+            ;;
+        *)
+            echo "Invalid option"
+            echo
+            printUsage
+            exit 1
+            ;;
+        esac
+    done
+
+    if [[ "${JIRAISSUE}" == "" && "${PATCHFILE}" == "" ]] ; then
+        echo "Either --jira or --patch option must be specified"
+        echo
+        printUsage
+        exit 1
+    fi
+    if [[ "${JIRAISSUE}" != "" && "${PATCHFILE}" != "" ]] ; then
+        echo "Cannot specify --jira or --patch options together"
+        echo
+        printUsage
+        exit 1
+    fi
+    if [[ "${RESETSCM}" == "false" && "${DIRTYSCM}" == "false" ]] ; then
+        echo "Either --reset-scm or --dirty-scm option must be specified"
+        echo
+        printUsage
+        exit 1
+    fi
+    if [[ "${RESETSCM}" == "true" && "${DIRTYSCM}" == "true" ]] ; then
+        echo "Cannot specify --reset-scm and --dirty-scm options together"
+        echo
+        printUsage
+        exit 1
+    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
+    curl "${JIRAURLISSUEPREFIX}${JIRAISSUE}" > ${jiraPage}
+    if [[ `grep -c 'Patch Available' ${jiraPage}` == 0 ]] ; then
+        echo "$JIRAISSUE is not \"Patch Available\".  Exiting."
+        echo
+        exit 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]*/[^"]*'`
+    patchURL="${JIRAHOST}${relativePatchURL}"
+    patchNum=`echo $patchURL | grep -o '[0-9]*/' | grep -o '[0-9]*'`
+    curl ${patchURL} > ${PATCHFILE}
+    if [[ $? != 0 ]] ; then
+        echo "Could not download patch for ${JIRAISSUE} from ${patchURL}"
+        echo
+        cleanupAndExit 1
+    fi
+    PATCHNAME=$(echo $patchURL | sed 's/.*\///g')
+    echo "JIRA ${JIRAISSUE}, patch downloaded at `date` from ${patchURL}" 
+    echo
+    echo "Patch [$PATCHNAME|$patchURL] downloaded at $(date)" >> ${SUMMARYFILE}
+    echo "" >> ${SUMMARYFILE}
+}
+###############################################################################
+applyPatch() {
+    echo "Applying patch" >> $STDOUT
+    echo "" >> $STDOUT
+    patch -f -E --dry-run -p0 < ${PATCHFILE} | tee ${REPORTDIR}/APPLY-PATCH.txt \
+        >> $STDOUT
+    if [[  ${PIPESTATUS[0]} != 0 ]] ; then
+        echo "Patch failed to apply to head of branch"
+        echo "{color:red}-1{color} Patch failed to apply to head of branch" >> ${SUMMARYFILE}
+        echo "" >> ${SUMMARYFILE}
+        echo "----------------------------" >> ${SUMMARYFILE}
+        echo
+        cleanupAndExit 1
+    fi
+    patch -f -E -p0 < ${PATCHFILE} > ${REPORTDIR}/APPLY-PATCH.txt
+    if [[ $? != 0 ]] ; then
+        echo "ODD!, dry run passed, but patch failed to apply to head of branch"
+        echo
+        cleanupAndExit 1
+    fi
+    echo "" >> $STDOUT
+    echo "Patch applied"
+    echo "{color:green}+1 PATCH_APPLIES{color}" >> $SUMMARYFILE
+    echo
+}
+###############################################################################
+run() {
+    task=`bash $1 --taskname`
+    if [[ "${TASKSTORUN}" == "" || "${TASKSTORUN}" =~ "${task}" ]] ; then
+        if [[ ! "${TASKSTOSKIP}" =~ "${task}" ]] ; then
+            echo "  Running test-patch task ${task}"
+            outputFile="`basename $1`-$2.out"
+            $1 --op=$2 --tempdir=${TEMPDIR} --reportdir=${REPORTDIR} \
+                --summaryfile=${SUMMARYFILE} --patchfile=${PATCHFILE} ${MVNPASSTHRU} \
+                ${VERBOSEOPTION} | tee ${TEMPDIR}/${outputFile} >> $STDOUT
+            if [[ $? != 0 ]] ; then
+                echo "  Failure, check for details ${TEMPDIR}/${outputFile}"
+                echo
+                cleanupAndExit 1
+            fi
+        fi
+    fi
+}
+###############################################################################
+getAllTasks() {
+    TASKFILES=`ls -a bin/test\-patch\-[0-9][0-9]\-*`
+}
+###############################################################################
+prePatchRun() {
+    echo "Pre patch"
+    for taskFile in ${TASKFILES} ; do
+        run $taskFile pre
+    done
+    echo
+}
+###############################################################################
+postPatchRun() {
+    echo "Post patch"
+    for taskFile in ${TASKFILES} ; do
+        run $taskFile post
+    done
+    echo
+}
+###############################################################################
+createReports() {
+    echo "Reports"
+    for taskFile in ${TASKFILES} ; do
+        run $taskFile report
+    done
+    echo
+}
+###############################################################################
+
+echo
+
+parseArgs "$@"
+
+prepareSCM
+
+prepareTestPatchDirs
+
+echo "" > ${SUMMARYFILE}
+
+if [ "${PATCHFILE}" == "" ] ; then
+    echo "Testing JIRA ${JIRAISSUE}"
+    echo
+    echo "Testing JIRA ${JIRAISSUE}" >> ${SUMMARYFILE}
+    echo "" >> ${SUMMARYFILE}
+else
+    if [ ! -e ${PATCHFILE} ] ; then
+        echo "Patch file does not exist"
+        cleanupAndExit 1
+    fi
+    echo "Testing patch ${PATCHFILE}"
+    echo
+    echo "Testing patch ${PATCHFILE}" >> ${SUMMARYFILE}
+    echo "" >> ${SUMMARYFILE}
+fi
+
+echo "" >> ${SUMMARYFILE}
+
+if [ "${PATCHFILE}" == "" ] ; then
+    downloadPatch ${JIRAISSUE}
+fi
+
+echo "----------------------------" >> ${SUMMARYFILE}
+echo "" >> ${SUMMARYFILE}
+getAllTasks
+prePatchRun
+applyPatch
+postPatchRun
+createReports
+echo "" >> ${SUMMARYFILE}
+echo "----------------------------" >> ${SUMMARYFILE}
+MINUSONES=`grep -c "\}\-1" ${SUMMARYFILE}`
+if [[ $MINUSONES == 0 ]]; then
+    echo "{color:green}*+1 Overall result, good!, no -1s*{color}" >> ${SUMMARYFILE}
+else
+    echo "{color:red}*-1 Overall result, please check the reported -1(s)*{color}" >> ${SUMMARYFILE}
+fi
+echo "" >> ${SUMMARYFILE}
+WARNINGS=`grep -c "\}WARNING" ${SUMMARYFILE}`
+if [[ $WARNINGS != 0 ]]; then
+    echo "{color:red}.   There is at least one warning, please check{color}" >> ${SUMMARYFILE}
+fi
+echo "" >> ${SUMMARYFILE}
+
+if [ ! -z "${JIRAISSUE}" ]; then
+    echo "The full output of the test-patch run is available at"  >> ${SUMMARYFILE}
+    echo ""  >> ${SUMMARYFILE}
+    echo ".   ${BUILD_URL}"  >> ${SUMMARYFILE}
+    echo ""  >> ${SUMMARYFILE}
+else
+    echo
+    echo "Refer to ${REPORTDIR} for detailed test-patch reports"
+    echo
+fi
+
+cat ${SUMMARYFILE} | sed -e 's/{color}//' -e 's/{color:green}//' -e 's/{color:red}//' -e 's/^\.//' -e 's/^\*//' -e 's/\*$//' > ${SUMMARYFILETXT}
+
+cat ${SUMMARYFILETXT}
+
+cleanupAndExit `expr $MINUSONES != 0`

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-00-clean
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-00-clean b/dev-support/test-patch-00-clean
new file mode 100755
index 0000000..d266bbe
--- /dev/null
+++ b/dev-support/test-patch-00-clean
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="CLEAN"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR>) [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${OP}" == "" || "${TEMPDIR}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    mvn clean ${MVNPASSTHRU} > ${TEMPDIR}/${TASKNAME}.txt
+    EXITCODE=$?
+    # removing files created by dependency:copy-dependencies
+    rm -f */lib/*
+    exit $EXITCODE
+    ;;
+post)
+    mvn clean ${MVNPASSTHRU} >> ${TEMPDIR}/${TASKNAME}.txt
+    EXITCODE=$?
+    ;;
+report)
+    echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-05-patch-raw-analysis
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-05-patch-raw-analysis b/dev-support/test-patch-05-patch-raw-analysis
new file mode 100755
index 0000000..52c0b2f
--- /dev/null
+++ b/dev-support/test-patch-05-patch-raw-analysis
@@ -0,0 +1,165 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+source $(dirname "$0")/raw-check-patch
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="RAW_PATCH_ANALYSIS"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+PATCHFILE=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>)"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        --patchfile=*)
+            PATCHFILE=${i#*=}
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" || "${PATCHFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+checkNoAuthors() {
+    TMPFILE=$TEMPDIR/$TASKNAME-authors.txt
+    printAuthors $PATCHFILE > $TMPFILE
+    authorTags=$(wc -l $TMPFILE | awk '{print $1}')
+    if [[ ${authorTags} != 0 ]] ; then
+        REPORT+=("{color:red}-1{color} the patch seems to contain ${authorTags} line(s) with @author tags")
+        REPORT+=("$(cat $TMPFILE)")
+    else
+        REPORT+=("{color:green}+1{color} the patch does not introduce any @author tags")
+    fi
+}
+###############################################################################
+checkNoTabs() {
+    TMPFILE=$TEMPDIR/$TASKNAME-tabs.txt
+    printTabs $PATCHFILE > $TMPFILE
+    tabs=$(wc -l $TMPFILE | awk '{print $1}')
+    if [[ ${tabs} != 0 ]] ; then
+        REPORT+=("{color:red}-1{color} the patch contains ${tabs} line(s) with tabs")
+        REPORT+=("$(cat $TMPFILE)")
+    else
+        REPORT+=("{color:green}+1{color} the patch does not introduce any tabs")
+    fi
+}
+###############################################################################
+checkNoTrailingSpaces() {
+    TMPFILE=$TEMPDIR/$TASKNAME-trailingspaces.txt
+    printTrailingSpaces $PATCHFILE > $TMPFILE
+    trailingSpaces=$(wc -l $TMPFILE | awk '{print $1}')
+    if [[ ${trailingSpaces} != 0 ]] ; then
+        REPORT+=("{color:red}-1{color} the patch contains ${trailingSpaces} line(s) with trailing spaces")
+        REPORT+=("$(cat $TMPFILE)")
+    else
+        REPORT+=("{color:green}+1{color} the patch does not introduce any trailing spaces")
+    fi
+}
+###############################################################################
+checkLinesLength() {
+    TMPFILE=$TEMPDIR/$TASKNAME-trailingspaces.txt
+    printLongLines $PATCHFILE > $TMPFILE
+    longLines=$(wc -l $TMPFILE | awk '{print $1}')
+    if [[ ${longLines} != 0 ]] ; then
+        REPORT+=("{color:red}-1{color} the patch contains ${longLines} line(s) longer than 120 characters")
+        REPORT+=("$(cat $TMPFILE)")
+    else
+        REPORT+=("{color:green}+1{color} the patch does not introduce any line longer than 120")
+    fi
+}
+###############################################################################
+checkForTestcases() {
+    testcases=`grep -c -i -e '^+++.*/test' ${PATCHFILE}`
+    if [[ ${testcases} == 0 ]] ; then
+        REPORT+=("{color:red}-1{color} the patch does not add/modify any testcase")
+    #reverting for summary +1 calculation
+        testcases=1
+    else
+        REPORT+=("{color:green}+1{color} the patch does adds/modifies ${testcases} testcase(s)")
+    #reverting for summary +1 calculation
+        testcases=0
+    fi
+}
+###############################################################################
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    ;;
+post)
+    ;;
+report)
+    REPORT=()
+    checkNoAuthors
+    checkNoTabs
+    checkNoTrailingSpaces
+    checkLinesLength
+    checkForTestcases
+    total=`expr $authorTags + $tabs + $trailingSpaces + $longLines + $testcases`
+    if [[ $total == 0 ]] ; then
+        echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    else
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    fi
+    for line in "${REPORT[@]}" ; do
+        echo ".    ${line}" >> $SUMMARYFILE
+    done
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-08-rat
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-08-rat b/dev-support/test-patch-08-rat
new file mode 100755
index 0000000..f403301
--- /dev/null
+++ b/dev-support/test-patch-08-rat
@@ -0,0 +1,132 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="RAT"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+STDOUT="/dev/null"
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        --verbose)
+            STDOUT="/dev/stdout"
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+checkForWarnings() {
+    cleanWarns=`grep -c '\!?????' ${REPORTDIR}/${TASKNAME}-clean.txt`
+    patchWarns=`grep -c '\!?????' ${REPORTDIR}/${TASKNAME}-patch.txt`
+    newWarns=`expr $patchWarns - $cleanWarns`
+    if [[ $newWarns -le 0 ]] ; then
+        REPORT+=("{color:green}+1{color} the patch does not seem to introduce new RAT warnings")
+        newWarns=0
+    else
+        REPORT+=("{color:red}-1{color} the patch seems to introduce $newWarns new RAT warning(s)")
+        newWarns=1
+    fi
+    if [[ $cleanWarns != 0 ]] ; then
+        REPORT+=("{color:red}WARNING: the current HEAD has $cleanWarns RAT warning(s), they should be addressed ASAP{color}")
+    fi
+}
+###############################################################################
+copyRatFiles() {
+    TAG=$1
+    rm -f ${REPORTDIR}/${TASKNAME}-$TAG.txt
+    for f in $(find . -name rat.txt); do
+        cat $f >> ${REPORTDIR}/${TASKNAME}-$TAG.txt
+    done
+}
+###############################################################################
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    mvn apache-rat:check ${MVNPASSTHRU} > $STDOUT
+    copyRatFiles clean
+    ;;
+post)
+    mvn apache-rat:check ${MVNPASSTHRU} > $STDOUT
+    copyRatFiles patch
+    ;;
+report)
+    checkForWarnings
+    if [[ $newWarns == 0 ]] ; then
+        echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    else
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    fi
+    for line in "${REPORT[@]}" ; do
+        echo ".    ${line}" >> $SUMMARYFILE
+    done
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-09-javadoc
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-09-javadoc b/dev-support/test-patch-09-javadoc
new file mode 100755
index 0000000..54bbf93
--- /dev/null
+++ b/dev-support/test-patch-09-javadoc
@@ -0,0 +1,118 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="JAVADOC"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+checkForWarnings() {
+    cleanWarns=`grep '\[WARNING\]' ${REPORTDIR}/${TASKNAME}-clean.txt | awk '/Javadoc Warnings/,EOF' | grep warning | awk 'BEGIN {total = 0} {total += 1} END {print total}'`
+    patchWarns=`grep '\[WARNING\]' ${REPORTDIR}/${TASKNAME}-patch.txt | awk '/Javadoc Warnings/,EOF' | grep warning | awk 'BEGIN {total = 0} {total += 1} END {print total}'`
+    newWarns=`expr $patchWarns - $cleanWarns`
+    if [[ $newWarns -le 0 ]] ; then
+        REPORT+=("{color:green}+1{color} the patch does not seem to introduce new Javadoc warnings")
+        newWarns=0
+    else
+        REPORT+=("{color:red}-1{color} the patch seems to introduce $newWarns new Javadoc warning(s)")
+        newWarns=1
+    fi
+    if [[ $cleanWarns != 0 ]] ; then
+        REPORT+=("{color:red}WARNING{color}: the current HEAD has $cleanWarns Javadoc warning(s)")
+    fi
+}
+###############################################################################
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    mvn clean javadoc:aggregate ${MVNPASSTHRU} > ${REPORTDIR}/${TASKNAME}-clean.txt
+    ;;
+post)
+    mvn clean javadoc:aggregate ${MVNPASSTHRU} > ${REPORTDIR}/${TASKNAME}-patch.txt
+    ;;
+report)
+    checkForWarnings
+    if [[ $newWarns == 0 ]] ; then
+        echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    else
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    fi
+    for line in "${REPORT[@]}" ; do
+        echo ".    ${line}" >> $SUMMARYFILE
+    done
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-10-compile
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-10-compile b/dev-support/test-patch-10-compile
new file mode 100755
index 0000000..5714b22
--- /dev/null
+++ b/dev-support/test-patch-10-compile
@@ -0,0 +1,144 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="COMPILE"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+STDOUT="/dev/null"
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose] [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        --verbose)
+            STDOUT="/dev/stdout"
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+checkForWarnings() {
+    grep '\[WARNING\]' ${REPORTDIR}/${TASKNAME}-clean.txt > ${TEMPDIR}/${TASKNAME}-javacwarns-clean.txt
+    grep '\[WARNING\]' ${REPORTDIR}/${TASKNAME}-patch.txt > ${TEMPDIR}/${TASKNAME}-javacwarns-patch.txt
+    cleanWarns=`cat ${TEMPDIR}/${TASKNAME}-javacwarns-clean.txt | awk 'BEGIN {total = 0} {total += 1} END {print total}'`
+    patchWarns=`cat ${TEMPDIR}/${TASKNAME}-javacwarns-patch.txt | awk 'BEGIN {total = 0} {total += 1} END {print total}'`
+    newWarns=`expr $patchWarns - $cleanWarns`
+    if [[ $newWarns -le 0 ]] ; then
+        REPORT+=("{color:green}+1{color} the patch does not seem to introduce new javac warnings")
+        newWarns=0
+    else
+        REPORT+=("{color:red}-1{color} the patch seems to introduce $newWarns new javac warning(s)")
+        newWarns=1
+    fi
+    if [[ $cleanWarns != 0 ]] ; then
+        REPORT+=("{color:red}WARNING{color}: the current HEAD has $cleanWarns javac warning(s)")
+    fi
+}
+###############################################################################
+
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    mvn clean install -DskipTests ${MVNPASSTHRU} | tee ${REPORTDIR}/${TASKNAME}-clean.txt >> $STDOUT
+    if [[ ${PIPESTATUS[0]} == 0 ]] ; then
+        echo "{color:green}+1{color} HEAD compiles" >> ${TEMPDIR}/${TASKNAME}-compile.txt
+    else
+        echo "{color:red}-1{color} HEAD does not compile" >> ${TEMPDIR}/${TASKNAME}-compile.txt
+    fi
+    ;;
+post)
+    mvn clean install -DskipTests ${MVNPASSTHRU} | tee ${REPORTDIR}/${TASKNAME}-patch.txt >> $STDOUT
+    if [[ ${PIPESTATUS[0]} == 0 ]] ; then
+        echo "{color:green}+1{color} patch compiles" >> ${TEMPDIR}/${TASKNAME}-compile.txt
+    else
+        echo "{color:red}-1{color} patch does not compile" >> ${TEMPDIR}/${TASKNAME}-compile.txt
+    fi
+    ;;
+report)
+    REPORT=()
+    compileErrors=0
+    while read line; do
+        REPORT+=("$line")
+        if [[ "$line" =~ "-1" ]] ; then
+            compileErrors=1
+        fi
+    done < ${TEMPDIR}/${TASKNAME}-compile.txt
+    checkForWarnings
+    total=`expr $compileErrors + $newWarns`
+    if [[ $total == 0 ]] ; then
+        echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    else
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    fi
+    for line in "${REPORT[@]}" ; do
+        echo ".    ${line}" >> $SUMMARYFILE
+    done
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-11-findbugs
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-11-findbugs b/dev-support/test-patch-11-findbugs
new file mode 100755
index 0000000..c91daff
--- /dev/null
+++ b/dev-support/test-patch-11-findbugs
@@ -0,0 +1,156 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="FINDBUGS"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+STDOUT="/dev/null"
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        --verbose)
+            STDOUT="/dev/stdout"
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+checkForWarnings() {
+    cleanBugs=0
+    patchBugs=0
+    for m in $(getModules); do
+        MODNAME=$(echo $m | sed 's/\///')
+
+        m_cleanBugs=$(cat ${REPORTDIR}/${TASKNAME}-${MODNAME}-clean.xml \
+            | sed 's/<\/BugInstance>/<\/BugInstance>\n/g' | grep BugInstance | wc -l)
+        m_patchBugs=$(cat ${REPORTDIR}/${TASKNAME}-${MODNAME}-patch.xml \
+            | sed 's/<\/BugInstance>/<\/BugInstance>\n/g' | grep BugInstance | wc -l)
+        m_newBugs=`expr $m_patchBugs - $m_cleanBugs`
+        if [[ $m_newBugs != 0 ]] ; then
+            BUGMODULES="$MODNAME $BUGMODULES"
+        fi
+
+        cleanBugs=$(($cleanBugs+$m_cleanBugs))
+        patchBugs=$(($patchBugs+$m_patchBugs))
+    done
+
+    BUGMODULES=$(echo $BUGMODULES | sed 's/^ *//' | sed 's/ *$//')
+    newBugs=`expr $patchBugs - $cleanBugs`
+    if [[ $newBugs -le 0 ]] ; then
+        REPORT+=("{color:green}+1{color} the patch does not seem to introduce new Findbugs warnings")
+        newBugs=0
+    else
+        REPORT+=("{color:red}-1{color} the patch seems to introduce $patchBugs new Findbugs warning(s) in module(s) [$BUGMODULES]")
+        newBugs=1
+    fi
+    if [[ $cleanBugs != 0 ]] ; then
+        REPORT+=("{color:red}WARNING: the current HEAD has $cleanWarns Findbugs warning(s), they should be addressed ASAP{color}")
+    fi
+}
+
+###############################################################################
+
+getModules() {
+    find . -name pom.xml | sed 's/^.\///' | sed 's/pom.xml$//' | grep -v compat
+}
+###############################################################################
+
+copyFindbugsXml() {
+    TAG=$1
+    for m in $(getModules); do
+        MODNAME=$(echo $m | sed 's/\///')
+        cp ${m}target/findbugsXml.xml ${REPORTDIR}/${TASKNAME}-${MODNAME}-$TAG.xml
+    done
+}
+
+parseArgs "$@"
+
+
+case $OP in
+pre)
+    mvn findbugs:findbugs ${MVNPASSTHRU} > $STDOUT
+    copyFindbugsXml clean
+    ;;
+post)
+    mvn findbugs:findbugs ${MVNPASSTHRU} > $STDOUT
+    copyFindbugsXml patch
+    ;;
+report)
+    checkForWarnings
+    if [[ $newBugs == 0 ]] ; then
+        echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    else
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+    fi
+    for line in "${REPORT[@]}" ; do
+        echo ".    ${line}" >> $SUMMARYFILE
+    done
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-20-tests
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-20-tests b/dev-support/test-patch-20-tests
new file mode 100755
index 0000000..ab77bcd
--- /dev/null
+++ b/dev-support/test-patch-20-tests
@@ -0,0 +1,125 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="TESTS"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+STDOUT="/dev/null"
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose] [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        --verbose)
+            STDOUT="/dev/stdout"
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    ;;
+post)
+    # must use package instead of test so that compat-deps shaded jars are correct
+    mvn package ${MVNPASSTHRU} -Dmaven.test.failure.ignore=true \
+        -Dmaven.test.error.ignore=true -fae \
+        -Dtest.timeout=7200 | tee ${TEMPDIR}/${TASKNAME}.out >> $STDOUT
+    exitCode=${PIPESTATUS[0]}
+    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/ .*//'`
+    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`
+    if [[ $hasFailures != 0 ]] ; then
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+        echo ".    Tests run: $testsRun" >> $SUMMARYFILE
+        echo ".    Tests failed: $testsFailed" >> $SUMMARYFILE
+        echo ".    Tests errors: $testsErrors" >> $SUMMARYFILE
+        echo "" >> ${SUMMARYFILE}
+        echo ".    The patch failed the following testcases:" >> $SUMMARYFILE
+        echo "" >> ${SUMMARYFILE}
+        echo "${failedTests}" | sed 's/^/.      /' >> $SUMMARYFILE
+        echo "" >> ${SUMMARYFILE}
+    else
+        if [[ "$testsExitCode" != "0" ]] ; then
+            echo "{color:red}-1 ${TASKNAME}{color} - patch does not compile, cannot run testcases" >> $SUMMARYFILE
+        else
+            echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+            echo ".    Tests run: $testsRun" >> $SUMMARYFILE
+        fi
+    fi
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-30-dist
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-30-dist b/dev-support/test-patch-30-dist
new file mode 100755
index 0000000..33d4d6c
--- /dev/null
+++ b/dev-support/test-patch-30-dist
@@ -0,0 +1,106 @@
+#!/bin/bash
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+if [ "${TESTPATCHDEBUG}" == "true" ] ; then
+    set -x
+fi
+
+BASEDIR=$(pwd)
+TASKNAME="DISTRO"
+OP=""
+TEMPDIR=""
+REPORTDIR=""
+SUMMARYFILE=""
+STDOUT="/dev/null"
+MVNPASSTHRU=""
+
+###############################################################################
+cleanupAndExit() {
+    exit $1
+}
+###############################################################################
+printUsage() {
+    echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir=<TEMP DIR> --reportdir=<REPORT DIR> --summaryfile=<SUMMARY FILE>) [--verbose] [-D<VALUE>...] [-P<VALUE>...]"
+    echo
+}
+###############################################################################
+parseArgs() {
+    for i in $*
+    do
+        case $i in
+        --taskname)
+            echo ${TASKNAME}
+            exit 0
+            ;;
+        --op=*)
+            OP=${i#*=}
+            ;;
+        --tempdir=*)
+            TEMPDIR=${i#*=}
+            ;;
+        --reportdir=*)
+            REPORTDIR=${i#*=}
+            ;;
+        --summaryfile=*)
+            SUMMARYFILE=${i#*=}
+            ;;
+        --verbose)
+            STDOUT="/dev/stdout"
+            ;;
+        -D*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        -P*)
+            MVNPASSTHRU="${MVNPASSTHRU} $i"
+            ;;
+        esac
+    done
+    if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then
+        echo "Missing options"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+    if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then
+        echo "Invalid operation"
+        echo
+        printUsage
+        cleanupAndExit 1
+    fi
+}
+###############################################################################
+
+parseArgs "$@"
+
+case $OP in
+pre)
+    ;;
+post)
+    mvn package assembly:single -DskipTests | tee ${REPORTDIR}/${TASKNAME}.out >> $STDOUT
+    exitCode=${PIPESTATUS[0]}
+    echo "$exitCode" >  ${TEMPDIR}/${TASKNAME}.exitCode
+    ;;
+report)
+    exitCode=`cat ${TEMPDIR}/${TASKNAME}.exitCode`
+    if [[ "$exitCode" != "0" ]] ; then
+        echo "{color:red}-1 ${TASKNAME}{color}" >> $SUMMARYFILE
+        echo ".    {color:red}-1{color} distro tarball fails with the patch" >> $SUMMARYFILE
+    else
+        echo "{color:green}+1 ${TASKNAME}{color}" >> $SUMMARYFILE
+        echo ".    {color:green}+1{color} distro tarball builds with the patch " >> $SUMMARYFILE
+    fi
+    ;;
+esac
+
+exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch-find-new-patch-available-jiras.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch-find-new-patch-available-jiras.sh b/dev-support/test-patch-find-new-patch-available-jiras.sh
deleted file mode 100755
index 317be6b..0000000
--- a/dev-support/test-patch-find-new-patch-available-jiras.sh
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/bin/bash
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-
-if [ "${TESTPATCHDEBUG}" == "true" ] ; then
-  set -x
-fi
-
-BASEDIR=$(pwd)
-TEMPDIR=${BASEDIR}/tmp
-
-JIRAAVAILPATCHQUERY="https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+in+%28KNOX%29+AND+status+%3D+%22Patch+Available%22+ORDER+BY+updated+DESC&tempMax=1000"
-TESTPATCHJOBURL="https://builds.apache.org/job/PreCommit-Knox-Build"
-TOKEN=""
-SUBMIT="false"
-DELETEHISTORYFILE="false"
-
-RUNTESTSFILE=${BASEDIR}/TESTED_PATCHES.txt
-
-printUsage() {
-  echo "Usage: $0 <OPTIONS>"
-  echo "          --submit --token=<KNOX PRECOMMIT JOB TOKEN>"
-  echo "          [--delete-history-file]"
-  echo "          [--script-debug]"
-  echo
-}
-
-###############################################################################
-parseArgs() {
-  for i in $*
-  do
-    case $i in
-    --submit)
-      SUBMIT="true"
-      ;;
-    --token=*)
-      TOKEN=${i#*=}
-      ;;
-    --script-debug)
-      DEBUG="-x"
-      ;;
-    --delete-history-file)
-      DELETEHISTORYFILE="true"
-      ;;
-    *)
-      echo "Invalid option"
-      echo
-      printUsage
-      exit 1
-      ;;
-    esac
-  done
-  if [[ "$SUBMIT" == "true" && "${TOKEN}" == "" ]] ; then
-    echo "Token has not been specified"
-    echo
-    printUsage
-    exit 1
-  fi
-}
-
-###############################################################################
-findAndSubmitAvailablePatches() {
-
-## Grab all the key (issue numbers) and largest attachment id for each item in the XML
-curl --fail --location --retry 3 "${JIRAAVAILPATCHQUERY}" > ${TEMPDIR}/patch-availables.xml
-if [ "$?" != "0" ] ; then
-    echo "Could not retrieve available patches from JIRA"
-    exit 1
-fi
-xpath -q -e "//item/key/text() | //item/attachments/attachment[not(../attachment/@id > @id)]/@id" ${TEMPDIR}/patch-availables.xml > ${TEMPDIR}/patch-attachments.element
-
-### Replace newlines with nothing, then replace id=" with =, then replace " with newline
-### to yield lines with pairs (issueNumber,largestAttachmentId). Example: KNOX-123,456984
-cat ${TEMPDIR}/patch-attachments.element | awk '{ if ( $1 ~ /^KNOX\-/) {JIRA=$1 }; if ($1 ~ /id=/) { print JIRA","$1} }' | sed 's/id\="//' | sed 's/"//' > ${TEMPDIR}/patch-availables.pair
-
-### Iterate through issue list and find the (issueNumber,largestAttachmentId) pairs that have
-### not been tested (ie don't already exist in the patch_tested.txt file
-touch ${RUNTESTSFILE}
-cat ${TEMPDIR}/patch-availables.pair | while read PAIR ; do
-  set +e
-  COUNT=`grep -c "$PAIR" ${RUNTESTSFILE}`
-  set -e
-  if [ "$COUNT" -lt "1" ] ; then
-    ### Parse $PAIR into project, issue number, and attachment id
-    ISSUE=`echo $PAIR | sed -e "s/,.*$//"`
-    echo "Found new patch for issue $ISSUE"
-    if [ "$SUBMIT" == "true" ]; then
-      ### Kick off job
-      echo "Submitting job for issue $ISSUE"
-      curl --fail --location --retry 3 "${TESTPATCHJOBURL}/buildWithParameters?token=${TOKEN}&JIRA_NUMBER=${ISSUE}" > /dev/null
-      if [ "$?" != "0" ] ; then
-        echo "Could not submit precommit job for $ISSUE"
-        exit 1
-      fi
-    fi
-    ### Mark this pair as tested by appending to file
-    echo "$PAIR" >> ${RUNTESTSFILE}
-  fi
-done
-}
-###############################################################################
-
-mkdir -p ${TEMPDIR} 2>&1 $STDOUT
-
-parseArgs "$@"
-
-if [ -n "${DEBUG}" ] ; then
-  set -x
-fi
-
-if [ "${DELETEHISTORYFILE}" == "true" ] ; then
-  rm ${RUNTESTSFILE}
-fi
-
-findAndSubmitAvailablePatches
-
-exit 0

http://git-wip-us.apache.org/repos/asf/knox/blob/878c6ecc/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
deleted file mode 100755
index 70e3045..0000000
--- a/dev-support/test-patch.sh
+++ /dev/null
@@ -1,413 +0,0 @@
-#!/bin/bash
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-
-if [ "${TESTPATCHDEBUG}" == "true" ] ; then
-  set -x
-fi
-
-BASEDIR=$(pwd)
-TESTPATCHDIR=${BASEDIR}/test-patch
-TOOLSDIR=${TESTPATCHDIR}/tools
-TEMPDIR=${TESTPATCHDIR}/tmp
-REPORTDIR=${TESTPATCHDIR}/reports
-SUMMARYFILE=${REPORTDIR}/TEST-SUMMARY.jira
-SUMMARYFILETXT=${REPORTDIR}/TEST-SUMMARY.txt
-
-JIRAHOST="https://issues.apache.org"
-JIRAURL="${JIRAHOST}/jira"
-JIRAURLISSUEPREFIX="${JIRAURL}/browse/"
-
-JIRAUPDATE="false"
-JIRAUSER="knoxqa"
-JIRAPASSWORD=""
-
-
-VERBOSEOPTION=""
-JIRAISSUE=""
-PATCHFILE=""
-TASKSTORUN=""
-TASKSTOSKIP=""
-RESETSCM="false"
-DIRTYSCM="false"
-STDOUT="/dev/null"
-MVNPASSTHRU=""
-
-###############################################################################
-gitOrSvn() {
-  SCM="NONE"
-  which git &> /dev/null
-  if [[ $? == 0 ]] ; then
-    git status &> /dev/null
-    if [[ $? == 0 ]] ; then
-      SCM="git"
-    fi
-  fi
-  if [ "${SCM}" == "NONE" ] ; then
-    which svn &> /dev/null
-    if [[ $? == 0 ]] ; then
-      svnOutput=`svn status 2>&1`
-      if [[  "$svnOutput" != *"is not a working copy" ]] ; then
-        SCM="svn"
-      fi
-    fi
-  fi
-  if [ "${SCM}" == "NONE" ] ; then
-    echo "The current workspace is not under Source Control (GIT or SVN)"
-    exit 1
-  fi
-}
-###############################################################################
-prepareSCM() {
-  gitOrSvn
-  if [ "${DIRTYSCM}" != "true" ] ; then
-    if [ "${RESETSCM}" == "true" ] ; then
-      if [ "${SCM}" == "git" ] ; then
-        git reset --hard HEAD > /dev/null
-        git clean -f -d > /dev/null
-      fi
-      if [ "${SCM}" == "svn" ] ; then
-        svn revert -R . > /dev/null
-        svn status | grep "\?" | awk '{print $2}' | xargs rm -rf
-      fi
-    else
-      echo "It should not happen DIRTYSCM=false & RESETSCM=false"
-      exit 1
-    fi
-    echo "Cleaning local ${SCM} workspace" >> ${SUMMARYFILE}
-  else
-    echo "WARNING: Running test-patch on a dirty local ${SCM} workspace" >> ${SUMMARYFILE}
-  fi
-}
-###############################################################################
-prepareTestPatchDirs() {
-  mkdir ${TESTPATCHDIR} 2> /dev/null
-  rm -rf ${REPORTDIR} 2> /dev/null
-  rm -rf ${TEMPDIR} 2> /dev/null
-  mkdir ${TOOLSDIR} 2> /dev/null
-  mkdir ${TEMPDIR} 2> /dev/null
-  mkdir ${REPORTDIR} 2> /dev/null
-  if [ ! -e "${TESTPATCHDIR}" ] ; then
-    echo "Could not create test-patch/ dir"
-    exit 1
-  fi
-}
-###############################################################################
-updateJira() {
-  if [[ "${JIRAUPDATE}" != "" && "${JIRAISSUE}" != "" ]] ; then
-    if [[ "$JIRAPASSWORD" != "" ]] ; then
-      JIRACLI=${TOOLSDIR}/jira-cli/jira.sh
-      if [ ! -e "${JIRACLI}" ] ; then
-        curl https://bobswift.atlassian.net/wiki/download/attachments/16285777/jira-cli-2.6.0-distribution.zip > ${TEMPDIR}/jira-cli.zip
-        if [ $? != 0 ] ; then
-         echo
-         echo "Could not download jira-cli tool, thus no JIRA updating"
-         echo
-         exit 1
-        fi
-        mkdir ${TEMPDIR}/jira-cli-tmp
-        (cd ${TEMPDIR}/jira-cli-tmp;jar xf ${TEMPDIR}/jira-cli.zip; mv jira-cli-2.6.0 ${TOOLSDIR}/jira-cli)
-        chmod u+x ${JIRACLI}
-      fi
-      echo "Adding comment to JIRA"
-      comment=`cat ${SUMMARYFILE}`
-      $JIRACLI -s $JIRAURL -a addcomment -u $JIRAUSER -p "$JIRAPASSWORD" --comment "$comment" --issue $JIRAISSUE
-      echo
-    else
-      echo "Skipping JIRA update"
-      echo
-    fi
-  fi
-}
-###############################################################################
-cleanupAndExit() {
-  updateJira
-  echo "test-patch exit code: $1"
-  echo
-  exit $1
-}
-###############################################################################
-printUsage() {
-  echo "Usage: $0 <OPTIONS>"
-  echo "          (--jira=<JIRA ISSUE> | --patch=<PATCH PATH>)"
-  echo "          (--reset-scm | --dirty-scm)"
-  echo "          [--tasks=<TASK,...>]"
-  echo "          [--skip-tasks=<TASK,...>]"
-  echo "          [--jira-cli=<JIRA CLIENT>]"
-  echo "          [--jira-user=<JIRA USER>]"
-  echo "          [--jira-password=<JIRA PASSWORD>]"
-  echo "          [-D<MVN PROPERTY>...]"
-  echo "          [-P<MVN PROFILE>...]"
-  echo "          [--list-tasks]"
-  echo "          [--verbose]"
-  echo
-}
-###############################################################################
-parseArgs() {
-  for i in $*
-  do
-    case $i in
-    --jira=*)
-      JIRAISSUE=${i#*=}
-      ;;
-    --patch=*)
-      PATCHFILE=${i#*=}
-      ;;
-    --tasks=*)
-      TASKSTORUN=${i#*=}
-      ;;
-    --skip-tasks=*)
-      TASKSTOSKIP=${i#*=}
-      ;;
-    --list-tasks)
-      listTasks
-      cleanupAndExit 0
-      ;;
-    --jira-cli=*)
-      JIRACLI=${i#*=}
-      ;;
-    --jira-user=*)
-      JIRAUSER=${i#*=}
-      ;;
-    --jira-password=*)
-      JIRAPASSWORD=${i#*=}
-      JIRAUPDATE="true"
-      ;;
-    -D*)
-      MVNPASSTHRU="${MVNPASSTHRU} $i"
-      ;;
-    -P*)
-      MVNPASSTHRU="${MVNPASSTHRU} $i"
-      ;;
-    --reset-scm)
-      RESETSCM="true"
-      ;;
-    --dirty-scm)
-      DIRTYSCM="true"
-      ;;
-    --verbose)
-      VERBOSEOPTION="--verbose"
-      STDOUT="/dev/stdout"
-      ;;
-    *)
-      echo "Invalid option"
-      echo
-      printUsage
-      exit 1
-      ;;
-    esac
-  done
-  if [[ "${JIRAISSUE}" == "" && "${PATCHFILE}" == "" ]] ; then
-    echo "Either --jira or --patch option must be specified"
-    echo
-    printUsage
-    exit 1
-  fi
-  if [[ "${JIRAISSUE}" != "" && "${PATCHFILE}" != "" ]] ; then
-    echo "Cannot specify --jira or --patch options together"
-    echo
-    printUsage
-    exit 1
-  fi
-  if [[ "${RESETSCM}" == "false" && "${DIRTYSCM}" == "false" ]] ; then
-    echo "Either --reset-scm or --dirty-scm option must be specified"
-    echo
-    printUsage
-    exit 1
-  fi
-  if [[ "${RESETSCM}" == "true" && "${DIRTYSCM}" == "true" ]] ; then
-    echo "Cannot specify --reset-scm and --dirty-scm options together"
-    echo
-    printUsage
-    exit 1
-  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
-  curl "${JIRAURLISSUEPREFIX}${JIRAISSUE}" > ${jiraPage}
-  if [[ `grep -c 'Patch Available' ${jiraPage}` == 0 ]] ; then
-    echo "$JIRAISSUE is not \"Patch Available\".  Exiting."
-    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]*/[^"]*'`
-  patchURL="${JIRAHOST}${relativePatchURL}"
-  patchNum=`echo $patchURL | grep -o '[0-9]*/' | grep -o '[0-9]*'`
-  curl ${patchURL} > ${PATCHFILE}
-  if [[ $? != 0 ]] ; then
-    echo "Could not download patch for ${JIRAISSUE} from ${patchURL}"
-    echo
-    cleanupAndExit 1
-  fi
-  echo "JIRA ${JIRAISSUE}, patch downloaded at `date` from ${patchURL}"
-  echo
-}
-###############################################################################
-applyPatch() {
-  echo "Applying patch" >> $STDOUT
-  echo "" >> $STDOUT
-  patch -f -E --dry-run -p0 < ${PATCHFILE} | tee ${REPORTDIR}/APPLY-PATCH.txt \
-        >> $STDOUT
-  if [[  ${PIPESTATUS[0]} != 0 ]] ; then
-    echo "Patch failed to apply to head of branch"
-    echo "{color:red}-1{color} Patch failed to apply to head of branch" >> ${SUMMARYFILE}
-    echo "" >> ${SUMMARYFILE}
-    echo "----------------------------" >> ${SUMMARYFILE}
-    echo
-    cleanupAndExit 1
-  fi
-  patch -f -E -p0 < ${PATCHFILE} > ${REPORTDIR}/APPLY-PATCH.txt
-  if [[ $? != 0 ]] ; then
-    echo "ODD!, dry run passed, but patch failed to apply to head of branch"
-    echo
-    cleanupAndExit 1
-  fi
-  echo "" >> $STDOUT
-  echo "Patch applied"
-  echo "{color:green}+1 PATCH_APPLIES{color}" >> $SUMMARYFILE
-  echo
-}
-###############################################################################
-run() {
-  task=`bash $1 --taskname`
-  if [[ "${TASKSTORUN}" == "" || "${TASKSTORUN}" =~ "${task}" ]] ; then
-    if [[ ! "${TASKSTOSKIP}" =~ "${task}" ]] ; then
-      echo "  Running test-patch task ${task}"
-      outputFile="`basename $1`-$2.out"
-      $1 --op=$2 --tempdir=${TEMPDIR} --reportdir=${REPORTDIR} \
-         --summaryfile=${SUMMARYFILE} --patchfile=${PATCHFILE} ${MVNPASSTHRU} \
-         ${VERBOSEOPTION} | tee ${TEMPDIR}/${outputFile} >> $STDOUT
-      if [[ $? != 0 ]] ; then
-        echo "  Failure, check for details ${TEMPDIR}/${outputFile}"
-        echo
-        cleanupAndExit 1
-      fi
-    fi
-  fi
-}
-###############################################################################
-getAllTasks() {
-  TASKFILES=`ls -a bin/test\-patch\-[0-9][0-9]\-*`
-}
-###############################################################################
-prePatchRun() {
-  echo "Pre patch"
-  for taskFile in ${TASKFILES} ; do
-    run $taskFile pre
-  done
-  echo
-}
-###############################################################################
-postPatchRun() {
-  echo "Post patch"
-  for taskFile in ${TASKFILES} ; do
-    run $taskFile post
-  done
-  echo
-}
-###############################################################################
-createReports() {
-  echo "Reports"
-  for taskFile in ${TASKFILES} ; do
-    run $taskFile report
-  done
-  echo
-}
-###############################################################################
-
-echo ""
-
-parseArgs "$@"
-
-prepareTestPatchDirs
-
-echo "" > ${SUMMARYFILE}
-
-if [ "${PATCHFILE}" == "" ] ; then
-  echo "Testing JIRA ${JIRAISSUE}"
-  echo
-  echo "Testing JIRA ${JIRAISSUE}" >> ${SUMMARYFILE}
-  echo "" >> ${SUMMARYFILE}
-else
-  if [ ! -e ${PATCHFILE} ] ; then
-    echo "Patch file does not exist"
-    cleanupAndExit 1
-  fi
-  echo "Testing patch ${PATCHFILE}"
-  echo
-  echo "Testing patch ${PATCHFILE}" >> ${SUMMARYFILE}
-  echo "" >> ${SUMMARYFILE}
-fi
-
-prepareSCM
-
-echo "" >> ${SUMMARYFILE}
-
-if [ "${PATCHFILE}" == "" ] ; then
-  downloadPatch ${JIRAISSUE}
-fi
-
-echo "----------------------------" >> ${SUMMARYFILE}
-echo "" >> ${SUMMARYFILE}
-getAllTasks
-prePatchRun
-applyPatch
-postPatchRun
-createReports
-echo "" >> ${SUMMARYFILE}
-echo "----------------------------" >> ${SUMMARYFILE}
-MINUSONES=`grep -c "\}\-1" ${SUMMARYFILE}`
-if [[ $MINUSONES == 0 ]]; then
-  echo "{color:green}*+1 Overall result, good!, no -1s*{color}" >> ${SUMMARYFILE}
-else
-  echo "{color:red}*-1 Overall result, please check the reported -1(s)*{color}" >> ${SUMMARYFILE}
-fi
-echo "" >> ${SUMMARYFILE}
-WARNINGS=`grep -c "\}WARNING" ${SUMMARYFILE}`
-if [[ $WARNINGS != 0 ]]; then
-  echo "{color:red}.   There is at least one warning, please check{color}" >> ${SUMMARYFILE}
-fi
-echo "" >> ${SUMMARYFILE}
-
-if [ ! -z "${JIRAISSUE}" ]; then
-  echo "The full output of the test-patch run is available at"  >> ${SUMMARYFILE}
-  echo ""  >> ${SUMMARYFILE}
-  echo ".   ${BUILD_URL}"  >> ${SUMMARYFILE}
-  echo ""  >> ${SUMMARYFILE}
-else
-  echo
-  echo "Refer to ${REPORTDIR} for detailed test-patch reports"
-  echo
-fi
-
-cat ${SUMMARYFILE} | sed -e 's/{color}//' -e 's/{color:green}//' -e 's/{color:red}//' -e 's/^\.//' -e 's/^\*//' -e 's/\*$//' > ${SUMMARYFILETXT}
-
-cat ${SUMMARYFILETXT}
-
-grep "^+1 Overall result" ${SUMMARYFILETXT} &> /dev/null
-cleanupAndExit "$?"
\ No newline at end of file


Mime
View raw message