Преглед изворни кода

HADOOP-11917. test-patch.sh should work with ${BASEDIR}/patchprocess setups (aw)

Allen Wittenauer пре 10 година
родитељ
комит
50a5d0b62b
4 измењених фајлова са 83 додато и 20 уклоњено
  1. 1 0
      .gitignore
  2. 68 10
      dev-support/test-patch.sh
  3. 3 0
      hadoop-common-project/hadoop-common/CHANGES.txt
  4. 11 10
      pom.xml

+ 1 - 0
.gitignore

@@ -22,3 +22,4 @@ hadoop-tools/hadoop-openstack/src/test/resources/contract-test-options.xml
 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/tla/yarnregistry.toolbox
 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/tla/yarnregistry.toolbox
 yarnregistry.pdf
 yarnregistry.pdf
 hadoop-tools/hadoop-aws/src/test/resources/contract-test-options.xml
 hadoop-tools/hadoop-aws/src/test/resources/contract-test-options.xml
+patchprocess/

+ 68 - 10
dev-support/test-patch.sh

@@ -535,6 +535,26 @@ function echo_and_redirect
   "${@}" > "${logfile}" 2>&1
   "${@}" > "${logfile}" 2>&1
 }
 }
 
 
+## @description is PATCH_DIR relative to BASEDIR?
+## @audience    public
+## @stability   stable
+## @replaceable yes
+## @returns     1 - no, PATCH_DIR
+## @returns     0 - yes, PATCH_DIR - BASEDIR
+function relative_patchdir
+{
+  local p=${PATCH_DIR#${BASEDIR}}
+
+  if [[ ${#p} -eq ${#PATCH_DIR} ]]; then
+    echo ${p}
+    return 1
+  fi
+  p=${p#/}
+  echo ${p}
+  return 0
+}
+
+
 ## @description  Print the usage information
 ## @description  Print the usage information
 ## @audience     public
 ## @audience     public
 ## @stability    stable
 ## @stability    stable
@@ -697,7 +717,8 @@ function parse_args
     esac
     esac
   done
   done
 
 
-  # if we get a relative path, turn it absolute
+  # we need absolute dir for ${BASEDIR}
+  cd "${CWD}"
   BASEDIR=$(cd -P -- "${BASEDIR}" >/dev/null && pwd -P)
   BASEDIR=$(cd -P -- "${BASEDIR}" >/dev/null && pwd -P)
 
 
   if [[ ${BUILD_NATIVE} == "true" ]] ; then
   if [[ ${BUILD_NATIVE} == "true" ]] ; then
@@ -723,6 +744,7 @@ function parse_args
     JENKINS=false
     JENKINS=false
   fi
   fi
 
 
+  cd "${CWD}"
   if [[ ! -d ${PATCH_DIR} ]]; then
   if [[ ! -d ${PATCH_DIR} ]]; then
     mkdir -p "${PATCH_DIR}"
     mkdir -p "${PATCH_DIR}"
     if [[ $? == 0 ]] ; then
     if [[ $? == 0 ]] ; then
@@ -733,6 +755,9 @@ function parse_args
     fi
     fi
   fi
   fi
 
 
+  # we need absolute dir for PATCH_DIR
+  PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
+
   GITDIFFLINES=${PATCH_DIR}/gitdifflines.txt
   GITDIFFLINES=${PATCH_DIR}/gitdifflines.txt
 }
 }
 
 
@@ -821,17 +846,36 @@ function find_changed_modules
 function git_checkout
 function git_checkout
 {
 {
   local currentbranch
   local currentbranch
+  local exemptdir
 
 
   big_console_header "Confirming git environment"
   big_console_header "Confirming git environment"
 
 
+  cd "${BASEDIR}"
+  if [[ ! -d .git ]]; then
+    hadoop_error "ERROR: ${BASEDIR} is not a git repo."
+    cleanup_and_exit 1
+  fi
+
   if [[ ${RESETREPO} == "true" ]] ; then
   if [[ ${RESETREPO} == "true" ]] ; then
-    cd "${BASEDIR}"
     ${GIT} reset --hard
     ${GIT} reset --hard
     if [[ $? != 0 ]]; then
     if [[ $? != 0 ]]; then
       hadoop_error "ERROR: git reset is failing"
       hadoop_error "ERROR: git reset is failing"
       cleanup_and_exit 1
       cleanup_and_exit 1
     fi
     fi
-    ${GIT} clean -xdf
+
+    # if PATCH_DIR is in BASEDIR, then we don't want
+    # git wiping it out.
+    exemptdir=$(relative_patchdir)
+    if [[ $? == 1 ]]; then
+      ${GIT} clean -xdf
+    else
+      # we do, however, want it emptied of all _files_.
+      # we need to leave _directories_ in case we are in
+      # re-exec mode (which places a directory full of stuff in it)
+      hadoop_debug "Exempting ${exemptdir} from clean"
+      rm "${PATCH_DIR}/*" 2>/dev/null
+      ${GIT} clean -xdf -e "${exemptdir}"
+    fi
     if [[ $? != 0 ]]; then
     if [[ $? != 0 ]]; then
       hadoop_error "ERROR: git clean is failing"
       hadoop_error "ERROR: git clean is failing"
       cleanup_and_exit 1
       cleanup_and_exit 1
@@ -875,11 +919,6 @@ function git_checkout
     fi
     fi
 
 
   else
   else
-    cd "${BASEDIR}"
-    if [[ ! -d .git ]]; then
-      hadoop_error "ERROR: ${BASEDIR} is not a git repo."
-      cleanup_and_exit 1
-    fi
 
 
     status=$(${GIT} status --porcelain)
     status=$(${GIT} status --porcelain)
     if [[ "${status}" != "" && -z ${DIRTY_WORKSPACE} ]] ; then
     if [[ "${status}" != "" && -z ${DIRTY_WORKSPACE} ]] ; then
@@ -1000,6 +1039,16 @@ function verify_valid_branch
   local check=$2
   local check=$2
   local i
   local i
 
 
+  # shortcut some common
+  # non-resolvable names
+  if [[ -z ${check} ]]; then
+    return 1
+  fi
+
+  if [[ ${check} == patch ]]; then
+    return 1
+  fi
+
   if [[ ${check} =~ ^git ]]; then
   if [[ ${check} =~ ^git ]]; then
     ref=$(echo "${check}" | cut -f2 -dt)
     ref=$(echo "${check}" | cut -f2 -dt)
     count=$(echo "${ref}" | wc -c | tr -d ' ')
     count=$(echo "${ref}" | wc -c | tr -d ' ')
@@ -2207,9 +2256,16 @@ function cleanup_and_exit
 
 
   if [[ ${JENKINS} == "true" ]] ; then
   if [[ ${JENKINS} == "true" ]] ; then
     if [[ -e "${PATCH_DIR}" ]] ; then
     if [[ -e "${PATCH_DIR}" ]] ; then
-      hadoop_debug "mv ${PATCH_DIR} ${BASEDIR} "
       if [[ -d "${PATCH_DIR}" ]]; then
       if [[ -d "${PATCH_DIR}" ]]; then
-        mv "${PATCH_DIR}" "${BASEDIR}"
+        # if PATCH_DIR is already inside BASEDIR, then
+        # there is no need to move it since we assume that
+        # Jenkins or whatever already knows where it is at
+        # since it told us to put it there!
+        relative_patchdir >/dev/null
+        if [[ $? == 0 ]]; then
+          hadoop_debug "mv ${PATCH_DIR} ${BASEDIR}"
+          mv "${PATCH_DIR}" "${BASEDIR}"
+        fi
       fi
       fi
     fi
     fi
   fi
   fi
@@ -2442,6 +2498,8 @@ find_changed_files
 
 
 determine_needed_tests
 determine_needed_tests
 
 
+# from here on out, we'll be in ${BASEDIR} for cwd
+# routines need to pushd/popd if they change.
 git_checkout
 git_checkout
 RESULT=$?
 RESULT=$?
 if [[ ${JENKINS} == "true" ]] ; then
 if [[ ${JENKINS} == "true" ]] ; then

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -75,6 +75,9 @@ Release 2.8.0 - UNRELEASED
     HADOOP-11911. test-patch should allow configuration of default branch
     HADOOP-11911. test-patch should allow configuration of default branch
     (Sean Busbey via aw)
     (Sean Busbey via aw)
 
 
+    HADOOP-11917. test-patch.sh should work with ${BASEDIR}/patchprocess
+    setups (aw)
+
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
     HADOOP-11785. Reduce the number of listStatus operation in distcp
     HADOOP-11785. Reduce the number of listStatus operation in distcp

+ 11 - 10
pom.xml

@@ -253,6 +253,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
             <exclude>.git/**</exclude>
             <exclude>.git/**</exclude>
             <exclude>.idea/**</exclude>
             <exclude>.idea/**</exclude>
 	    <exclude>**/build/**</exclude>
 	    <exclude>**/build/**</exclude>
+            <exclude>**/patchprocess/**</exclude>
          </excludes>
          </excludes>
        </configuration>
        </configuration>
       </plugin>
       </plugin>
@@ -283,7 +284,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
       </plugin>
       </plugin>
     </plugins>
     </plugins>
   </build>
   </build>
-  
+
   <reporting>
   <reporting>
     <excludeDefaults>true</excludeDefaults>
     <excludeDefaults>true</excludeDefaults>
     <plugins>
     <plugins>
@@ -329,15 +330,15 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
                 </docletArtifact>
                 </docletArtifact>
               </docletArtifacts>
               </docletArtifacts>
               <useStandardDocletOptions>true</useStandardDocletOptions>
               <useStandardDocletOptions>true</useStandardDocletOptions>
-    
+
               <!-- switch on dependency-driven aggregation -->
               <!-- switch on dependency-driven aggregation -->
               <includeDependencySources>false</includeDependencySources>
               <includeDependencySources>false</includeDependencySources>
-    
+
               <dependencySourceIncludes>
               <dependencySourceIncludes>
                 <!-- include ONLY dependencies I control -->
                 <!-- include ONLY dependencies I control -->
                 <dependencySourceInclude>org.apache.hadoop:hadoop-annotations</dependencySourceInclude>
                 <dependencySourceInclude>org.apache.hadoop:hadoop-annotations</dependencySourceInclude>
               </dependencySourceIncludes>
               </dependencySourceIncludes>
-    
+
             </configuration>
             </configuration>
             <reports>
             <reports>
               <report>aggregate</report>
               <report>aggregate</report>
@@ -360,7 +361,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
       </plugin>
       </plugin>
     </plugins>
     </plugins>
   </reporting>
   </reporting>
-  
+
   <profiles>
   <profiles>
     <profile>
     <profile>
       <id>src</id>
       <id>src</id>
@@ -475,12 +476,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
       <properties>
       <properties>
         <cloverLicenseLocation>${user.home}/.clover.license</cloverLicenseLocation>
         <cloverLicenseLocation>${user.home}/.clover.license</cloverLicenseLocation>
         <cloverDatabase>${project.build.directory}/clover/hadoop-coverage.db</cloverDatabase>
         <cloverDatabase>${project.build.directory}/clover/hadoop-coverage.db</cloverDatabase>
-        <!-- NB: This additional parametrization is made in order 
+        <!-- NB: This additional parametrization is made in order
              to be able to re-define these properties with "-Dk=v" maven options.
              to be able to re-define these properties with "-Dk=v" maven options.
-             By some reason the expressions declared in clover 
-             docs like "${maven.clover.generateHtml}" do not work in that way. 
-             However, the below properties are confirmed to work: e.g. 
-             -DcloverGenHtml=false switches off the Html generation.  
+             By some reason the expressions declared in clover
+             docs like "${maven.clover.generateHtml}" do not work in that way.
+             However, the below properties are confirmed to work: e.g.
+             -DcloverGenHtml=false switches off the Html generation.
              The default values provided here exactly correspond to Clover defaults, so
              The default values provided here exactly correspond to Clover defaults, so
              the behavior is 100% backwards compatible. -->
              the behavior is 100% backwards compatible. -->
         <cloverAlwaysReport>true</cloverAlwaysReport>
         <cloverAlwaysReport>true</cloverAlwaysReport>