source: proiecte/HadoopJUnit/hadoop-0.20.1/src/test/bin/test-patch.sh @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 28.2 KB
Line 
1#!/usr/bin/env bash
2
3#set -x
4ulimit -n 1024
5
6### Setup some variables. 
7### JOB_NAME, SVN_REVISION, and BUILD_NUMBER are set by Hudson if it is run by patch process
8
9###############################################################################
10parseArgs() {
11  case "$1" in
12    HUDSON)
13      ### Set HUDSON to true to indicate that this script is being run by Hudson
14      HUDSON=true
15      if [[ $# != 17 ]] ; then
16        echo "ERROR: usage $0 HUDSON <PATCH_DIR> <SUPPORT_DIR> <PS_CMD> <WGET_CMD> <JIRACLI> <SVN_CMD> <GREP_CMD> <PATCH_CMD> <FINDBUGS_HOME> <FORREST_HOME> <ECLIPSE_HOME> <PYTHON_HOME> <WORKSPACE_BASEDIR> <TRIGGER_BUILD> <JIRA_PASSWD> <JAVA5_HOME> "
17        cleanupAndExit 0
18      fi
19      PATCH_DIR=$2
20      SUPPORT_DIR=$3
21      PS=$4
22      WGET=$5
23      JIRACLI=$6
24      SVN=$7
25      GREP=$8
26      PATCH=$9
27      FINDBUGS_HOME=${10}
28      FORREST_HOME=${11}
29      ECLIPSE_HOME=${12}
30      PYTHON_HOME=${13}
31      BASEDIR=${14}
32      TRIGGER_BUILD_URL=${15}
33      JIRA_PASSWD=${16}
34      JAVA5_HOME=${17}
35      ### Retrieve the defect number
36      if [ ! -e $PATCH_DIR/defectNum ] ; then
37        echo "Could not determine the patch to test.  Exiting."
38        cleanupAndExit 0
39      fi
40      defect=`cat $PATCH_DIR/defectNum`
41      if [ -z "$defect" ] ; then
42        echo "Could not determine the patch to test.  Exiting."
43        cleanupAndExit 0
44      fi
45      ECLIPSE_PROPERTY="-Declipse.home=$ECLIPSE_HOME"
46      PYTHON_PROPERTY="-Dpython.home=$PYTHON_HOME"
47      ;;
48    DEVELOPER)
49      ### Set HUDSON to false to indicate that this script is being run by a developer
50      HUDSON=false
51      if [[ $# != 10 ]] ; then
52        echo "ERROR: usage $0 DEVELOPER <PATCH_FILE> <SCRATCH_DIR> <SVN_CMD> <GREP_CMD> <PATCH_CMD> <FINDBUGS_HOME> <FORREST_HOME> <WORKSPACE_BASEDIR> <JAVA5_HOME>"
53        cleanupAndExit 0
54      fi
55      ### PATCH_FILE contains the location of the patchfile
56      PATCH_FILE=$2 
57      if [[ ! -e "$PATCH_FILE" ]] ; then
58        echo "Unable to locate the patch file $PATCH_FILE"
59        cleanupAndExit 0
60      fi
61      PATCH_DIR=$3
62      ### Check if $PATCH_DIR exists. If it does not exist, create a new directory
63      if [[ ! -e "$PATCH_DIR" ]] ; then
64        mkdir "$PATCH_DIR"
65        if [[ $? == 0 ]] ; then 
66          echo "$PATCH_DIR has been created"
67        else
68          echo "Unable to create $PATCH_DIR"
69          cleanupAndExit 0
70        fi
71      fi
72      SVN=$4
73      GREP=$5
74      PATCH=$6
75      FINDBUGS_HOME=$7
76      FORREST_HOME=$8
77      BASEDIR=$9
78      JAVA5_HOME=${10}
79      ### Obtain the patch filename to append it to the version number
80      defect=`basename $PATCH_FILE` 
81      ;;
82    *)
83      echo "ERROR: usage $0 HUDSON [args] | DEVELOPER [args]"
84      cleanupAndExit 0
85      ;;
86  esac
87}
88
89###############################################################################
90checkout () {
91  echo ""
92  echo ""
93  echo "======================================================================"
94  echo "======================================================================"
95  echo "    Testing patch for ${defect}."
96  echo "======================================================================"
97  echo "======================================================================"
98  echo ""
99  echo ""
100  ### When run by a developer, if the workspace contains modifications, do not continue
101  status=`$SVN stat`
102  if [[ $HUDSON == "false" ]] ; then
103    if [[ "$status" != "" ]] ; then
104      echo "ERROR: can't run in a workspace that contains the following modifications"
105      echo "$status"
106      cleanupAndExit 1
107    fi
108  else   
109    cd $BASEDIR
110    $SVN revert -R .
111    rm -rf `$SVN status`
112    $SVN update
113  fi
114  return $?
115}
116
117###############################################################################
118setup () {
119  ### Download latest patch file (ignoring .htm and .html) when run from patch process
120  if [[ $HUDSON == "true" ]] ; then
121    $WGET -q -O $PATCH_DIR/jira http://issues.apache.org/jira/browse/$defect
122    if [[ `$GREP -c 'Patch Available' $PATCH_DIR/jira` == 0 ]] ; then
123      echo "$defect is not \"Patch Available\".  Exiting."
124      cleanupAndExit 0
125    fi
126    relativePatchURL=`$GREP -o '"/jira/secure/attachment/[0-9]*/[^"]*' $PATCH_DIR/jira | $GREP -v -e 'htm[l]*$' | sort | tail -1 | $GREP -o '/jira/secure/attachment/[0-9]*/[^"]*'`
127    patchURL="http://issues.apache.org${relativePatchURL}"
128    patchNum=`echo $patchURL | $GREP -o '[0-9]*/' | $GREP -o '[0-9]*'`
129    echo "$defect patch is being downloaded at `date` from"
130    echo "$patchURL"
131    $WGET -q -O $PATCH_DIR/patch $patchURL
132    VERSION=${SVN_REVISION}_${defect}_PATCH-${patchNum}
133    JIRA_COMMENT="Here are the results of testing the latest attachment
134  $patchURL
135  against trunk revision ${SVN_REVISION}."
136
137    ### Copy in any supporting files needed by this process
138    cp -r $SUPPORT_DIR/lib/* ./lib
139    #PENDING: cp -f $SUPPORT_DIR/etc/checkstyle* ./src/test
140  ### Copy the patch file to $PATCH_DIR
141  else
142    VERSION=PATCH-${defect}
143    cp $PATCH_FILE $PATCH_DIR/patch
144    if [[ $? == 0 ]] ; then
145      echo "Patch file $PATCH_FILE copied to $PATCH_DIR"
146    else
147      echo "Could not copy $PATCH_FILE to $PATCH_DIR"
148      cleanupAndExit 0
149    fi
150  fi
151  echo ""
152  echo ""
153  echo "======================================================================"
154  echo "======================================================================"
155  echo "    Pre-building trunk to determine trunk number"
156  echo "    of release audit, javac, and Findbugs warnings."
157  echo "======================================================================"
158  echo "======================================================================"
159  echo ""
160  echo ""
161  ### DISABLE RELEASE AUDIT UNTIL HADOOP-4074 IS FIXED
162  ### Do not call releaseaudit when run by a developer
163  ### if [[ $HUDSON == "true" ]] ; then
164    ### echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= releaseaudit > $PATCH_DIR/trunkReleaseAuditWarnings.txt 2>&1"
165    ### $ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= releaseaudit > $PATCH_DIR/trunkReleaseAuditWarnings.txt 2>&1
166  ### fi
167  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -Djavac.args="-Xlint -Xmaxwarns 1000" $ECLIPSE_PROPERTY -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= clean tar > $PATCH_DIR/trunkJavacWarnings.txt 2>&1"
168  $ANT_HOME/bin/ant -Dversion="${VERSION}" -Djavac.args="-Xlint -Xmaxwarns 1000" $ECLIPSE_PROPERTY -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= clean tar > $PATCH_DIR/trunkJavacWarnings.txt 2>&1
169  if [[ $? != 0 ]] ; then
170    echo "Trunk compilation is broken?"
171    cleanupAndExit 1
172  fi
173  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -Dfindbugs.home=$FINDBUGS_HOME -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= findbugs > /dev/null 2>&1"
174  $ANT_HOME/bin/ant -Dversion="${VERSION}" -Dfindbugs.home=$FINDBUGS_HOME -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= findbugs > /dev/null 2>&1
175  if [[ $? != 0 ]] ; then
176    echo "Trunk findbugs is broken?"
177    cleanupAndExit 1
178  fi
179  cp $BASEDIR/build/test/findbugs/*.xml $PATCH_DIR/trunkFindbugsWarnings.xml
180}
181
182###############################################################################
183### Check for @author tags in the patch
184checkAuthor () {
185  echo ""
186  echo ""
187  echo "======================================================================"
188  echo "======================================================================"
189  echo "    Checking there are no @author tags in the patch."
190  echo "======================================================================"
191  echo "======================================================================"
192  echo ""
193  echo ""
194  authorTags=`$GREP -c -i '@author' $PATCH_DIR/patch`
195  echo "There appear to be $authorTags @author tags in the patch."
196  if [[ $authorTags != 0 ]] ; then
197    JIRA_COMMENT="$JIRA_COMMENT
198
199    -1 @author.  The patch appears to contain $authorTags @author tags which the Hadoop community has agreed to not allow in code contributions."
200    return 1
201  fi
202  JIRA_COMMENT="$JIRA_COMMENT
203
204    +1 @author.  The patch does not contain any @author tags."
205  return 0
206}
207
208###############################################################################
209### Check for tests in the patch
210checkTests () {
211  echo ""
212  echo ""
213  echo "======================================================================"
214  echo "======================================================================"
215  echo "    Checking there are new or changed tests in the patch."
216  echo "======================================================================"
217  echo "======================================================================"
218  echo ""
219  echo ""
220  testReferences=`$GREP -c -i '/test' $PATCH_DIR/patch`
221  echo "There appear to be $testReferences test files referenced in the patch."
222  if [[ $testReferences == 0 ]] ; then
223    if [[ $HUDSON == "true" ]] ; then
224      patchIsDoc=`$GREP -c -i 'title="documentation' $PATCH_DIR/jira`
225      if [[ $patchIsDoc != 0 ]] ; then
226        echo "The patch appears to be a documentation patch that doesn't require tests."
227        JIRA_COMMENT="$JIRA_COMMENT
228
229    +0 tests included.  The patch appears to be a documentation patch that doesn't require tests."
230        return 0
231      fi
232    fi
233    JIRA_COMMENT="$JIRA_COMMENT
234
235    -1 tests included.  The patch doesn't appear to include any new or modified tests.
236                        Please justify why no tests are needed for this patch."
237    return 1
238  fi
239  JIRA_COMMENT="$JIRA_COMMENT
240
241    +1 tests included.  The patch appears to include $testReferences new or modified tests."
242  return 0
243}
244
245###############################################################################
246### Attempt to apply the patch
247applyPatch () {
248  echo ""
249  echo ""
250  echo "======================================================================"
251  echo "======================================================================"
252  echo "    Applying patch."
253  echo "======================================================================"
254  echo "======================================================================"
255  echo ""
256  echo ""
257  $PATCH -E -p0 < $PATCH_DIR/patch
258  if [[ $? != 0 ]] ; then
259    echo "PATCH APPLICATION FAILED"
260    JIRA_COMMENT="$JIRA_COMMENT
261
262    -1 patch.  The patch command could not apply the patch."
263    return 1
264  fi
265  return 0
266}
267
268###############################################################################
269### Check there are no javadoc warnings
270checkJavadocWarnings () {
271  echo ""
272  echo ""
273  echo "======================================================================"
274  echo "======================================================================"
275  echo "    Determining number of patched javadoc warnings."
276  echo "======================================================================"
277  echo "======================================================================"
278  echo ""
279  echo ""
280  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= clean javadoc | tee $PATCH_DIR/patchJavadocWarnings.txt"
281  $ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= clean javadoc | tee $PATCH_DIR/patchJavadocWarnings.txt
282  javadocWarnings=`$GREP -c '\[javadoc\] [0-9]* warning' $PATCH_DIR/patchJavadocWarnings.txt`
283  echo ""
284  echo ""
285  echo "There appear to be $javadocWarnings javadoc warnings generated by the patched build."
286  if [[ $javadocWarnings != 0 ]] ; then
287    JIRA_COMMENT="$JIRA_COMMENT
288
289    -1 javadoc.  The javadoc tool appears to have generated $javadocWarnings warning messages."
290    return 1
291  fi
292  JIRA_COMMENT="$JIRA_COMMENT
293
294    +1 javadoc.  The javadoc tool did not generate any warning messages."
295return 0
296}
297
298###############################################################################
299### Check there are no changes in the number of Javac warnings
300checkJavacWarnings () {
301  echo ""
302  echo ""
303  echo "======================================================================"
304  echo "======================================================================"
305  echo "    Determining number of patched javac warnings."
306  echo "======================================================================"
307  echo "======================================================================"
308  echo ""
309  echo ""
310  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -Djavac.args="-Xlint -Xmaxwarns 1000" $ECLIPSE_PROPERTY -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= tar > $PATCH_DIR/patchJavacWarnings.txt 2>&1"
311  $ANT_HOME/bin/ant -Dversion="${VERSION}" -Djavac.args="-Xlint -Xmaxwarns 1000" $ECLIPSE_PROPERTY -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= tar > $PATCH_DIR/patchJavacWarnings.txt 2>&1
312
313  ### Compare trunk and patch javac warning numbers
314  if [[ -f $PATCH_DIR/patchJavacWarnings.txt ]] ; then
315    trunkJavacWarnings=`$GREP -o '\[javac\] [0-9]* warning' $PATCH_DIR/trunkJavacWarnings.txt | awk '{total += $2} END {print total}'`
316    patchJavacWarnings=`$GREP -o '\[javac\] [0-9]* warning' $PATCH_DIR/patchJavacWarnings.txt | awk '{total += $2} END {print total}'`
317    echo "There appear to be $trunkJavacWarnings javac compiler warnings before the patch and $patchJavacWarnings javac compiler warnings after applying the patch."
318    if [[ $patchJavacWarnings != "" && $trunkJavacWarnings != "" ]] ; then
319      if [[ $patchJavacWarnings > $trunkJavacWarnings ]] ; then
320        JIRA_COMMENT="$JIRA_COMMENT
321
322    -1 javac.  The applied patch generated $patchJavacWarnings javac compiler warnings (more than the trunk's current $trunkJavacWarnings warnings)."
323        return 1
324      fi
325    fi
326  fi
327  JIRA_COMMENT="$JIRA_COMMENT
328
329    +1 javac.  The applied patch does not increase the total number of javac compiler warnings."
330  return 0
331}
332
333###############################################################################
334### Check there are no changes in the number of release audit (RAT) warnings
335checkReleaseAuditWarnings () {
336  echo ""
337  echo ""
338  echo "======================================================================"
339  echo "======================================================================"
340  echo "    Determining number of patched release audit warnings."
341  echo "======================================================================"
342  echo "======================================================================"
343  echo ""
344  echo ""
345  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= releaseaudit > $PATCH_DIR/patchReleaseAuditWarnings.txt 2>&1"
346  $ANT_HOME/bin/ant -Dversion="${VERSION}" -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= releaseaudit > $PATCH_DIR/patchReleaseAuditWarnings.txt 2>&1
347
348  ### Compare trunk and patch release audit warning numbers
349  if [[ -f $PATCH_DIR/patchReleaseAuditWarnings.txt ]] ; then
350    trunkReleaseAuditWarnings=`$GREP -c '\!?????' $PATCH_DIR/trunkReleaseAuditWarnings.txt`
351    patchReleaseAuditWarnings=`$GREP -c '\!?????' $PATCH_DIR/patchReleaseAuditWarnings.txt`
352    echo ""
353    echo ""
354    echo "There appear to be $trunkReleaseAuditWarnings release audit warnings before the patch and $patchReleaseAuditWarnings release audit warnings after applying the patch."
355    if [[ $patchReleaseAuditWarnings != "" && $trunkReleaseAuditWarnings != "" ]] ; then
356      if [[ $patchReleaseAuditWarnings > $trunkReleaseAuditWarnings ]] ; then
357        JIRA_COMMENT="$JIRA_COMMENT
358
359    -1 release audit.  The applied patch generated $patchReleaseAuditWarnings release audit warnings (more than the trunk's current $trunkReleaseAuditWarnings warnings)."
360        $GREP '\!?????' $PATCH_DIR/patchReleaseAuditWarnings.txt > $PATCH_DIR/patchReleaseAuditProblems.txt
361        $GREP '\!?????' $PATCH_DIR/trunkReleaseAuditWarnings.txt > $PATCH_DIR/trunkReleaseAuditProblems.txt
362        echo "A diff of patched release audit warnings with trunk release audit warnings." > $PATCH_DIR/releaseAuditDiffWarnings.txt
363        echo "Lines that start with ????? in the release audit report indicate files that do not have an Apache license header." > $PATCH_DIR/releaseAuditDiffWarnings.txt
364        echo "" > $PATCH_DIR/releaseAuditDiffWarnings.txt
365        diff $PATCH_DIR/patchReleaseAuditProblems.txt $PATCH_DIR/trunkReleaseAuditProblems.txt >> $PATCH_DIR/releaseAuditDiffWarnings.txt
366        JIRA_COMMENT_FOOTER="Release audit warnings: http://hudson.zones.apache.org/hudson/job/$JOB_NAME/$BUILD_NUMBER/artifact/trunk/current/releaseAuditDiffWarnings.txt
367$JIRA_COMMENT_FOOTER"
368        return 1
369      fi
370    fi
371  fi
372  JIRA_COMMENT="$JIRA_COMMENT
373
374    +1 release audit.  The applied patch does not increase the total number of release audit warnings."
375  return 0
376}
377
378###############################################################################
379### Check there are no changes in the number of Checkstyle warnings
380checkStyle () {
381  echo ""
382  echo ""
383  echo "======================================================================"
384  echo "======================================================================"
385  echo "    Determining number of patched checkstyle warnings."
386  echo "======================================================================"
387  echo "======================================================================"
388  echo ""
389  echo ""
390  echo "THIS IS NOT IMPLEMENTED YET"
391  echo ""
392  echo ""
393  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= checkstyle"
394  $ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= checkstyle
395  JIRA_COMMENT_FOOTER="Checkstyle results: http://hudson.zones.apache.org/hudson/job/$JOB_NAME/$BUILD_NUMBER/artifact/trunk/build/test/checkstyle-errors.html
396$JIRA_COMMENT_FOOTER"
397  ### TODO: calculate actual patchStyleErrors
398#  patchStyleErrors=0
399#  if [[ $patchStyleErrors != 0 ]] ; then
400#    JIRA_COMMENT="$JIRA_COMMENT
401#
402#    -1 checkstyle.  The patch generated $patchStyleErrors code style errors."
403#    return 1
404#  fi
405#  JIRA_COMMENT="$JIRA_COMMENT
406#
407#    +1 checkstyle.  The patch generated 0 code style errors."
408  return 0
409}
410
411###############################################################################
412### Check there are no changes in the number of Findbugs warnings
413checkFindbugsWarnings () {
414  echo ""
415  echo ""
416  echo "======================================================================"
417  echo "======================================================================"
418  echo "    Determining number of patched Findbugs warnings."
419  echo "======================================================================"
420  echo "======================================================================"
421  echo ""
422  echo ""
423  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -Dfindbugs.home=$FINDBUGS_HOME -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= findbugs"
424  $ANT_HOME/bin/ant -Dversion="${VERSION}" -Dfindbugs.home=$FINDBUGS_HOME -Djava5.home=${JAVA5_HOME} -Dforrest.home=${FORREST_HOME} -DHadoopPatchProcess= findbugs
425  if [ $? != 0 ] ; then
426    JIRA_COMMENT="$JIRA_COMMENT
427
428    -1 findbugs.  The patch appears to cause Findbugs to fail."
429    return 1
430  fi
431JIRA_COMMENT_FOOTER="Findbugs warnings: http://hudson.zones.apache.org/hudson/job/$JOB_NAME/$BUILD_NUMBER/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
432$JIRA_COMMENT_FOOTER"
433  cp $BASEDIR/build/test/findbugs/*.xml $PATCH_DIR/patchFindbugsWarnings.xml
434$FINDBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/1999" \
435    $PATCH_DIR/trunkFindbugsWarnings.xml \
436    $PATCH_DIR/trunkFindbugsWarnings.xml
437  $FINDBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/2000" \
438    $PATCH_DIR/patchFindbugsWarnings.xml \
439    $PATCH_DIR/patchFindbugsWarnings.xml
440  $FINDBUGS_HOME/bin/computeBugHistory -output $PATCH_DIR/findbugsMerge.xml \
441    $PATCH_DIR/trunkFindbugsWarnings.xml \
442    $PATCH_DIR/patchFindbugsWarnings.xml
443  findbugsWarnings=`$FINDBUGS_HOME/bin/filterBugs -first "01/01/2000" $PATCH_DIR/findbugsMerge.xml \
444    $BASEDIR/build/test/findbugs/newPatchFindbugsWarnings.xml | /usr/bin/awk '{print $1}'`
445  $FINDBUGS_HOME/bin/convertXmlToText -html \
446    $BASEDIR/build/test/findbugs/newPatchFindbugsWarnings.xml \
447    $BASEDIR/build/test/findbugs/newPatchFindbugsWarnings.html
448  cp $BASEDIR/build/test/findbugs/newPatchFindbugsWarnings.html $PATCH_DIR/newPatchFindbugsWarnings.html
449  cp $BASEDIR/build/test/findbugs/newPatchFindbugsWarnings.xml $PATCH_DIR/newPatchFindbugsWarnings.xml
450  if [[ $findbugsWarnings != 0 ]] ; then
451    JIRA_COMMENT="$JIRA_COMMENT
452
453    -1 findbugs.  The patch appears to introduce $findbugsWarnings new Findbugs warnings."
454    return 1
455  fi
456  JIRA_COMMENT="$JIRA_COMMENT
457
458    +1 findbugs.  The patch does not introduce any new Findbugs warnings."
459  return 0
460}
461
462###############################################################################
463### Run the test-core target
464runCoreTests () {
465  echo ""
466  echo ""
467  echo "======================================================================"
468  echo "======================================================================"
469  echo "    Running core tests."
470  echo "======================================================================"
471  echo "======================================================================"
472  echo ""
473  echo ""
474 
475  ### Kill any rogue build processes from the last attempt
476  $PS -auxwww | $GREP HadoopPatchProcess | /usr/bin/nawk '{print $2}' | /usr/bin/xargs -t -I {} /usr/bin/kill -9 {} > /dev/null
477
478  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=yes -Dcompile.c++=yes -Dforrest.home=$FORREST_HOME -Djava5.home=$JAVA5_HOME create-c++-configure docs tar test-core"
479  $ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=yes -Dcompile.c++=yes -Dforrest.home=$FORREST_HOME -Djava5.home=$JAVA5_HOME create-c++-configure docs tar test-core
480  if [[ $? != 0 ]] ; then
481    JIRA_COMMENT="$JIRA_COMMENT
482
483    -1 core tests.  The patch failed core unit tests."
484    return 1
485  fi
486  JIRA_COMMENT="$JIRA_COMMENT
487
488    +1 core tests.  The patch passed core unit tests."
489  return 0
490}
491
492###############################################################################
493### Tests parts of contrib specific to the eclipse files
494checkJarFilesDeclaredInEclipse () {
495  export DECLARED_JARS=$(sed -n 's@.*kind="lib".*path="\(.*jar\)".*@\1@p' < .eclipse.templates/.classpath)
496  export PRESENT_JARS=$(find build/ivy/lib/Hadoop/common/ lib/ src/test/lib/ -name '*.jar' |sort)
497  # When run by Hudson, consider libs from ${SUPPORT_DIR} declared
498  if [[ ${HUDSON} == "true" ]]; then
499      DECLARED_JARS="${DECLARED_JARS} $(cd "${SUPPORT_DIR}"; find lib -name '*.jar')"
500  fi
501  DECLARED_JARS=$(sed 'y/ /\n/' <<< ${DECLARED_JARS} | sort)
502  export ECLIPSE_DECLARED_SRC=$(sed -n 's@.*kind="src".*path="\(.*\)".*@\1@p' < .eclipse.templates/.classpath |sort)
503
504  if [ "${DECLARED_JARS}" != "${PRESENT_JARS}" ]; then
505    echo "
506FAILED. Some jars are not declared in the Eclipse project.
507  Declared jars: ${DECLARED_JARS}
508  Present jars:  ${PRESENT_JARS}"
509    return 1
510  fi
511  for dir in $ECLIPSE_DECLARED_SRC; do
512    [ '!' -d $dir ] && echo "
513FAILED: $dir is referenced in the Eclipse project although it doesn't exists anymore." && return 1
514  done
515  return 0
516}
517
518checkEclipse () {
519  echo ""
520  echo ""
521  echo "======================================================================"
522  echo "======================================================================"
523  echo "    Running Eclipse classpath verification."
524  echo "======================================================================"
525  echo "======================================================================"
526  echo ""
527  echo ""
528
529  checkJarFilesDeclaredInEclipse
530  if [[ $? != 0 ]] ; then
531    JIRA_COMMENT="$JIRA_COMMENT
532
533    -1 Eclipse classpath. The patch causes the Eclipse classpath to differ from the contents of the lib directories."
534    return 1
535  fi
536  JIRA_COMMENT="$JIRA_COMMENT
537
538    +1 Eclipse classpath. The patch retains Eclipse classpath integrity."
539  return 0
540}
541###############################################################################
542### Run the test-contrib target
543runContribTests () {
544  echo ""
545  echo ""
546  echo "======================================================================"
547  echo "======================================================================"
548  echo "    Running contrib tests."
549  echo "======================================================================"
550  echo "======================================================================"
551  echo ""
552  echo ""
553
554  ### Kill any rogue build processes from the last attempt
555  $PS -auxwww | $GREP HadoopPatchProcess | /usr/bin/nawk '{print $2}' | /usr/bin/xargs -t -I {} /usr/bin/kill -9 {} > /dev/null
556
557  echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" $ECLIPSE_PROPERTY $PYTHON_PROPERTY -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=yes test-contrib"
558  $ANT_HOME/bin/ant -Dversion="${VERSION}" $ECLIPSE_PROPERTY $PYTHON_PROPERTY -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=yes test-contrib
559  if [[ $? != 0 ]] ; then
560    JIRA_COMMENT="$JIRA_COMMENT
561
562    -1 contrib tests.  The patch failed contrib unit tests."
563    return 1
564  fi
565  JIRA_COMMENT="$JIRA_COMMENT
566
567    +1 contrib tests.  The patch passed contrib unit tests."
568  return 0
569}
570
571###############################################################################
572### Submit a comment to the defect's Jira
573submitJiraComment () {
574  local result=$1
575  ### Do not output the value of JIRA_COMMENT_FOOTER when run by a developer
576  if [[  $HUDSON == "false" ]] ; then
577    JIRA_COMMENT_FOOTER=""
578  fi
579  if [[ $result == 0 ]] ; then
580    comment="+1 overall.  $JIRA_COMMENT
581
582$JIRA_COMMENT_FOOTER"
583  else
584    comment="-1 overall.  $JIRA_COMMENT
585
586$JIRA_COMMENT_FOOTER"
587  fi
588  ### Output the test result to the console
589  echo "
590
591
592
593$comment" 
594
595  if [[ $HUDSON == "true" ]] ; then
596    echo ""
597    echo ""
598    echo "======================================================================"
599    echo "======================================================================"
600    echo "    Adding comment to Jira."
601    echo "======================================================================"
602    echo "======================================================================"
603    echo ""
604    echo ""
605
606    ### Update Jira with a comment
607    export USER=hudson
608    $JIRACLI -s issues.apache.org/jira login hadoopqa $JIRA_PASSWD
609    $JIRACLI -s issues.apache.org/jira comment $defect "$comment"
610    $JIRACLI -s issues.apache.org/jira logout
611  fi
612}
613
614###############################################################################
615### Cleanup files
616cleanupAndExit () {
617  local result=$1
618  if [[ $HUDSON == "true" ]] ; then
619    if [ -e "$PATCH_DIR" ] ; then
620      mv $PATCH_DIR $BASEDIR
621    fi
622  fi
623  echo ""
624  echo ""
625  echo "======================================================================"
626  echo "======================================================================"
627  echo "    Finished build."
628  echo "======================================================================"
629  echo "======================================================================"
630  echo ""
631  echo ""
632  exit $result
633}
634
635###############################################################################
636###############################################################################
637###############################################################################
638
639JIRA_COMMENT=""
640JIRA_COMMENT_FOOTER="Console output: http://hudson.zones.apache.org/hudson/job/$JOB_NAME/$BUILD_NUMBER/console
641
642This message is automatically generated."
643
644### Check if arguments to the script have been specified properly or not
645parseArgs $@
646cd $BASEDIR
647
648checkout
649RESULT=$?
650if [[ $HUDSON == "true" ]] ; then
651  if [[ $RESULT != 0 ]] ; then
652    ### Resubmit build.
653    $WGET -q -O $PATCH_DIR/build $TRIGGER_BUILD_URL
654    exit 100
655  fi
656fi
657setup
658checkAuthor
659RESULT=$?
660
661checkTests
662(( RESULT = RESULT + $? ))
663applyPatch
664if [[ $? != 0 ]] ; then
665  submitJiraComment 1
666  cleanupAndExit 1
667fi
668checkJavadocWarnings
669(( RESULT = RESULT + $? ))
670checkJavacWarnings
671(( RESULT = RESULT + $? ))
672checkStyle
673(( RESULT = RESULT + $? ))
674checkFindbugsWarnings
675(( RESULT = RESULT + $? ))
676checkEclipse
677(( RESULT = RESULT + $? ))
678### Do not call these when run by a developer
679if [[ $HUDSON == "true" ]] ; then
680  ### DISABLE RELEASE AUDIT UNTIL HADOOP-4074 IS FIXED
681  ### checkReleaseAuditWarnings
682  ### (( RESULT = RESULT + $? ))
683  runCoreTests
684  (( RESULT = RESULT + $? ))
685  runContribTests
686  (( RESULT = RESULT + $? ))
687fi
688JIRA_COMMENT_FOOTER="Test results: http://hudson.zones.apache.org/hudson/job/$JOB_NAME/$BUILD_NUMBER/testReport/
689$JIRA_COMMENT_FOOTER"
690
691submitJiraComment $RESULT
692cleanupAndExit $RESULT
693
694
Note: See TracBrowser for help on using the repository browser.