HADOOP-7561. Make test-patch only run tests for changed modules.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1161291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas White 2011-08-24 21:35:38 +00:00
parent 1eb272051d
commit 71c2f73175
3 changed files with 66 additions and 22 deletions

View File

@ -59,15 +59,15 @@ PREFIX_DIRS=$(cut -d '/' -f 1 $TMP | sort | uniq)
if [[ -d hadoop-common ]]; then if [[ -d hadoop-common ]]; then
echo Looks like this is being run at project root echo Looks like this is being run at project root
# if all of the lines start with hadoop-common/, hadoop-hdfs/, or mapreduce/, this is # if all of the lines start with hadoop-common/, hadoop-hdfs/, or hadoop-mapreduce/, this is
# relative to the hadoop root instead of the subproject root, so we need # relative to the hadoop root instead of the subproject root, so we need
# to chop off another layer # to chop off another layer
elif [[ "$PREFIX_DIRS" =~ ^(hadoop-hdfs|hadoop-common|mapreduce)$ ]]; then elif [[ "$PREFIX_DIRS" =~ ^(hadoop-alfredo|hadoop-annotations|hadoop-common|hadoop-hdfs|hadoop-mapreduce)$ ]]; then
echo Looks like this is relative to project root. Increasing PLEVEL echo Looks like this is relative to project root. Increasing PLEVEL
PLEVEL=$[$PLEVEL + 1] PLEVEL=$[$PLEVEL + 1]
elif ! echo "$PREFIX_DIRS" | grep -vxq 'hadoop-common\|hadoop-hdfs\|mapreduce' ; then elif ! echo "$PREFIX_DIRS" | grep -vxq 'hadoop-alfredo\|hadoop-annotations\|hadoop-common\|hadoop-hdfs\|hadoop-mapreduce' ; then
echo Looks like this is a cross-subproject patch. Try applying from the project root echo Looks like this is a cross-subproject patch. Try applying from the project root
exit 1 exit 1
fi fi

View File

@ -446,7 +446,7 @@ checkReleaseAuditWarnings () {
echo "" echo ""
echo "$MVN apache-rat:check -D${PROJECT_NAME}PatchProcess 2>&1" echo "$MVN apache-rat:check -D${PROJECT_NAME}PatchProcess 2>&1"
$MVN apache-rat:check -D${PROJECT_NAME}PatchProcess 2>&1 $MVN apache-rat:check -D${PROJECT_NAME}PatchProcess 2>&1
find . -name rat.txt | xargs cat > $PATCH_DIR/patchReleaseAuditWarnings.txt find $BASEDIR -name rat.txt | xargs cat > $PATCH_DIR/patchReleaseAuditWarnings.txt
### Compare trunk and patch release audit warning numbers ### Compare trunk and patch release audit warning numbers
if [[ -f $PATCH_DIR/patchReleaseAuditWarnings.txt ]] ; then if [[ -f $PATCH_DIR/patchReleaseAuditWarnings.txt ]] ; then
@ -549,7 +549,7 @@ checkFindbugsWarnings () {
$FINDBUGS_HOME/bin/convertXmlToText -html \ $FINDBUGS_HOME/bin/convertXmlToText -html \
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml \ $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml \
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html
JIRA_COMMENT_FOOTER="Findbugs warnings: $BUILD_URL/artifact/trunk/target/newPatchFindbugsWarnings${module_suffix}.html JIRA_COMMENT_FOOTER="Findbugs warnings: $BUILD_URL/artifact/trunk/patchprocess/newPatchFindbugsWarnings${module_suffix}.html
$JIRA_COMMENT_FOOTER" $JIRA_COMMENT_FOOTER"
done done
@ -567,42 +567,83 @@ $JIRA_COMMENT_FOOTER"
} }
############################################################################### ###############################################################################
### Run the test-core target ### Run the tests
runCoreTests () { runTests () {
echo "" echo ""
echo "" echo ""
echo "======================================================================" echo "======================================================================"
echo "======================================================================" echo "======================================================================"
echo " Running core tests." echo " Running tests."
echo "======================================================================" echo "======================================================================"
echo "======================================================================" echo "======================================================================"
echo "" echo ""
echo "" echo ""
failed_tests=""
modules=$(findModules)
for module in $modules;
do
pushd $module
echo " Running tests in $module"
### Kill any rogue build processes from the last attempt ### Kill any rogue build processes from the last attempt
$PS auxwww | $GREP ${PROJECT_NAME}PatchProcess | $AWK '{print $2}' | /usr/bin/xargs -t -I {} /bin/kill -9 {} > /dev/null $PS auxwww | $GREP ${PROJECT_NAME}PatchProcess | $AWK '{print $2}' | /usr/bin/xargs -t -I {} /bin/kill -9 {} > /dev/null
PreTestTarget=""
if [[ $defect == MAPREDUCE-* ]] ; then
PreTestTarget="create-c++-configure"
fi
echo "$MVN clean test -Pnative -D${PROJECT_NAME}PatchProcess" echo "$MVN clean test -Pnative -D${PROJECT_NAME}PatchProcess"
$MVN clean test -Pnative -D${PROJECT_NAME}PatchProcess $MVN clean test -Pnative -D${PROJECT_NAME}PatchProcess
if [[ $? != 0 ]] ; then if [[ $? != 0 ]] ; then
### Find and format names of failed tests ### Find and format names of failed tests
failed_tests=`grep -l -E "<failure|<error" $WORKSPACE/trunk/target/hadoop-common/surefire-reports/*.xml | sed -e "s|.*target/surefire-reports/TEST-| |g" | sed -e "s|\.xml||g"` module_failed_tests=`find . -name 'TEST*.xml' | xargs $GREP -l -E "<failure|<error" | sed -e "s|.*target/surefire-reports/TEST-| |g" | sed -e "s|\.xml||g"`
failed_tests="${failed_tests}
${module_failed_tests}"
fi
popd
done
echo $failed_tests
if [[ -n "$failed_tests" ]] ; then
JIRA_COMMENT="$JIRA_COMMENT JIRA_COMMENT="$JIRA_COMMENT
-1 core tests. The patch failed these core unit tests: -1 core tests. The patch failed these unit tests:
$failed_tests" $failed_tests"
return 1 return 1
fi fi
JIRA_COMMENT="$JIRA_COMMENT JIRA_COMMENT="$JIRA_COMMENT
+1 core tests. The patch passed core unit tests." +1 core tests. The patch passed unit tests in $modules."
return 0 return 0
} }
###############################################################################
### Find the modules changed by the patch
findModules () {
# Come up with a list of changed files into $TMP
TMP=/tmp/tmp.paths.$$
$GREP '^+++\|^---' $PATCH_DIR/patch | cut -c '5-' | $GREP -v /dev/null | sort | uniq > $TMP
# if all of the lines start with a/ or b/, then this is a git patch that
# was generated without --no-prefix
if ! $GREP -qv '^a/\|^b/' $TMP ; then
sed -i -e 's,^[ab]/,,' $TMP
fi
PREFIX_DIRS=$(cut -d '/' -f 1 $TMP | sort | uniq)
# if all of the lines start with hadoop-common/, hadoop-hdfs/, or hadoop-mapreduce/, this is
# relative to the hadoop root instead of the subproject root
if [[ "$PREFIX_DIRS" =~ ^(hadoop-alfredo|hadoop-annotations|hadoop-common|hadoop-hdfs|hadoop-mapreduce)$ ]]; then
echo $PREFIX_DIRS
return 0
elif ! echo "$PREFIX_DIRS" | grep -vxq 'hadoop-alfredo\|hadoop-annotations\|hadoop-common\|hadoop-hdfs\|hadoop-mapreduce' ; then
echo $PREFIX_DIRS
return 0
fi
# No modules found. Running from current directory.
echo .
}
############################################################################### ###############################################################################
### Run the test-contrib target ### Run the test-contrib target
runContribTests () { runContribTests () {
@ -658,6 +699,7 @@ checkInjectSystemFaults () {
#echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=no -Dcompile.c++=yes -Dforrest.home=$FORREST_HOME inject-system-faults" #echo "$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=no -Dcompile.c++=yes -Dforrest.home=$FORREST_HOME inject-system-faults"
#$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=no -Dcompile.c++=yes -Dforrest.home=$FORREST_HOME inject-system-faults #$ANT_HOME/bin/ant -Dversion="${VERSION}" -DHadoopPatchProcess= -Dtest.junit.output.format=xml -Dtest.output=no -Dcompile.c++=yes -Dforrest.home=$FORREST_HOME inject-system-faults
echo "NOP" echo "NOP"
return 0
if [[ $? != 0 ]] ; then if [[ $? != 0 ]] ; then
JIRA_COMMENT="$JIRA_COMMENT JIRA_COMMENT="$JIRA_COMMENT
@ -779,7 +821,7 @@ checkReleaseAuditWarnings
(( RESULT = RESULT + $? )) (( RESULT = RESULT + $? ))
### Do not call these when run by a developer ### Do not call these when run by a developer
if [[ $JENKINS == "true" ]] ; then if [[ $JENKINS == "true" ]] ; then
runCoreTests runTests
(( RESULT = RESULT + $? )) (( RESULT = RESULT + $? ))
runContribTests runContribTests
(( RESULT = RESULT + $? )) (( RESULT = RESULT + $? ))

View File

@ -340,6 +340,8 @@ Trunk (unreleased changes)
HADOOP-7496. Break Maven TAR & bintar profiles into just LAYOUT & TAR proper. HADOOP-7496. Break Maven TAR & bintar profiles into just LAYOUT & TAR proper.
(Alejandro Abdelnur via tomwhite) (Alejandro Abdelnur via tomwhite)
HADOOP-7561. Make test-patch only run tests for changed modules. (tomwhite)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole HADOOP-7333. Performance improvement in PureJavaCrc32. (Eric Caspole