yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [2/2] yetus git commit: Multiple docker fixes: (trial) * YETUS-76. Docker mode doesn't work for a local patch file * YETUS-123. Docker mode failing to enable plugins * YETUS-131. docker support should check that the docker command works * YETUS-148. Wro
Date Wed, 11 Nov 2015 19:00:17 GMT
Multiple docker fixes:  (trial)
* YETUS-76. Docker mode doesn't work for a local patch file
* YETUS-123. Docker mode failing to enable plugins
* YETUS-131. docker support should check that the docker command works
* YETUS-148. Wrong variable name ${TP_SHELL_SCRIPT_DEBUG}


Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/72645f46
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/72645f46
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/72645f46

Branch: refs/heads/YETUS-83
Commit: 72645f469d641576fab94aaac9428ef8c7e90824
Parents: d1ebe36
Author: Allen Wittenauer <aw@apache.org>
Authored: Mon Nov 9 13:28:36 2015 -0800
Committer: Allen Wittenauer <aw@apache.org>
Committed: Wed Nov 11 10:59:43 2015 -0800

----------------------------------------------------------------------
 .../documentation/latest/precommit-advanced.md  |  4 +-
 precommit/core.d/00-yetuslib.sh                 |  2 +-
 precommit/core.d/01-common.sh                   | 19 ++--
 precommit/core.d/patchfiles.sh                  |  5 +
 precommit/test-patch-docker/Dockerfile          | 99 ++++++++++++++++++++
 precommit/test-patch-docker/Dockerfile-endstub  |  2 +
 .../test-patch-docker/Dockerfile-startstub      | 91 ------------------
 .../test-patch-docker/launch-test-patch.sh      | 14 ++-
 .../test-patch-docker/test-patch-docker.sh      | 10 +-
 precommit/test-patch.sh                         | 87 ++++++++++++++---
 10 files changed, 214 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/asf-site-src/source/documentation/latest/precommit-advanced.md
----------------------------------------------------------------------
diff --git a/asf-site-src/source/documentation/latest/precommit-advanced.md b/asf-site-src/source/documentation/latest/precommit-advanced.md
index 638f7d2..dda9546 100644
--- a/asf-site-src/source/documentation/latest/precommit-advanced.md
+++ b/asf-site-src/source/documentation/latest/precommit-advanced.md
@@ -27,9 +27,9 @@ test-patch
 
 # Docker Support
 
-By default, test-patch runs in the same shell where it was launched.  It can alternatively
use Docker to launch itself into a container.  This is particularly useful if running under
a QA environment that does not provide all the necessary binaries. For example, if the patch
requires a newer version of Java.
+By default, test-patch runs in the same shell where it was launched.  It can alternatively
use Docker to launch itself in a container.  This is particularly useful if running under
a QA environment that does not provide all the necessary binaries. For example, if the patch
requires a newer version of Java than what is installed on a Jenkins instance.
 
-The `--docker` parameter tells test-patch to run in Docker mode. The `--dockerfile` parameter
allows one to provide a custom Dockerfile. The Dockerfile should contain all of the necessary
binaries and tooling needed to run the test.  However be aware that test-patch will copy this
file and append its necessary hooks to re-launch itself prior to executing docker.
+The `--docker` parameter tells test-patch to run in Docker mode. The `--dockerfile` parameter
allows one to provide a custom Dockerfile. The Dockerfile should contain all of the necessary
binaries and tooling needed to run the test.  test-patch will copy this file up until the
text "YETUS CUT HERE" to a different directory and then append its necessary hooks to re-launch
itself prior to executing docker.
 
 NOTE: If you are using Boot2Docker, you must use directories under /Users (OSX) or C:\Users
(Windows) as the base and patchprocess directories (specified by the --basedir and --patch-dir
options respectively), because automatically mountable directories are limited to them. See
[the Docker documentation](https://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume).
 

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/core.d/00-yetuslib.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/00-yetuslib.sh b/precommit/core.d/00-yetuslib.sh
index 69b7915..9b6185a 100755
--- a/precommit/core.d/00-yetuslib.sh
+++ b/precommit/core.d/00-yetuslib.sh
@@ -125,4 +125,4 @@ function yetus_abs
     return 0
   fi
   return 1
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/core.d/01-common.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/01-common.sh b/precommit/core.d/01-common.sh
index 2110f75..5e7cb60 100755
--- a/precommit/core.d/01-common.sh
+++ b/precommit/core.d/01-common.sh
@@ -45,6 +45,8 @@ function common_defaults
   PATCH_METHODS=("gitapply" "patchcmd")
   #shellcheck disable=SC2034
   PATCH_LEVEL=0
+  #shellcheck disable=SC2034
+  PATCH_SYSTEM=""
   PROJECT_NAME=yetus
   RESULT=0
   #shellcheck disable=SC2034
@@ -434,22 +436,19 @@ function importplugins
     files=("${files[@]}" ${USER_PLUGIN_DIR}/*.sh)
   fi
 
+  if [[ -n ${PERSONALITY} && ! -f ${PERSONALITY} ]]; then
+    yetus_error "ERROR: Can't find ${PERSONALITY} to import."
+    unset PERSONALITY
+  fi
+
   if [[ -z ${PERSONALITY}
       && -f "${BINDIR}/personality/${PROJECT_NAME}.sh"
       && ${LOAD_SYSTEM_PLUGINS} = "true" ]]; then
+    yetus_debug "Using project personality."
     PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
   fi
 
-  if [[ -n ${PERSONALITY} ]]; then
-    if [[ ! -f ${PERSONALITY} ]]; then
-      if [[ -f "${BINDIR}/personality/${PROJECT_NAME}.sh"
-         && ${LOAD_SYSTEM_PLUGINS} = "true" ]]; then
-        PERSONALITY="${BINDIR}/personality/${PROJECT_NAME}.sh"
-      else
-        yetus_debug "Can't find ${PERSONALITY} to import."
-        return
-      fi
-    fi
+  if [[ -n ${PERSONALITY} && -f ${PERSONALITY} ]]; then
     yetus_debug "Importing ${PERSONALITY}"
     # shellcheck disable=SC1090
     . "${PERSONALITY}"

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/core.d/patchfiles.sh
----------------------------------------------------------------------
diff --git a/precommit/core.d/patchfiles.sh b/precommit/core.d/patchfiles.sh
index 7bb2f8b..7154a58 100755
--- a/precommit/core.d/patchfiles.sh
+++ b/precommit/core.d/patchfiles.sh
@@ -97,6 +97,7 @@ function locate_patch
   # it's a declarely provided file
   if [[ -f ${PATCH_OR_ISSUE} ]]; then
     patchfile="${PATCH_OR_ISSUE}"
+    PATCH_SYSTEM=generic
   else
     # run through the bug systems.  maybe they know?
     for bugsys in ${BUGSYSTEMS}; do
@@ -104,6 +105,7 @@ function locate_patch
         "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"
         if [[ $? == 0 ]]; then
           gotit=true
+          PATCH_SYSTEM=${bugsys}
         fi
       fi
     done
@@ -115,9 +117,12 @@ function locate_patch
         yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
         cleanup_and_exit 1
       fi
+      PATCH_SYSTEM=generic
     fi
   fi
 
+  yetus_debug "Determined patch system to be ${PATCH_SYSTEM}"
+
   if [[ ! -f "${PATCH_DIR}/patch"
       && -f "${patchfile}" ]]; then
     cp "${patchfile}" "${PATCH_DIR}/patch"

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/test-patch-docker/Dockerfile
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/Dockerfile b/precommit/test-patch-docker/Dockerfile
new file mode 100644
index 0000000..a839057
--- /dev/null
+++ b/precommit/test-patch-docker/Dockerfile
@@ -0,0 +1,99 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+FROM ubuntu:trusty
+
+WORKDIR /root
+
+######
+# Install common dependencies from packages
+######
+RUN apt-get update && apt-get install --no-install-recommends -y \
+    git curl ant make maven \
+    cmake gcc g++ protobuf-compiler \
+    build-essential libtool \
+    zlib1g-dev pkg-config libssl-dev \
+    snappy libsnappy-dev \
+    bzip2 libbz2-dev \
+    libjansson-dev \
+    fuse libfuse-dev \
+    libcurl4-openssl-dev \
+    python python2.7 pylint \
+    ruby \
+    openjdk-7-jdk \
+    libperl-critic-perl
+
+# Fixing the Apache commons / Maven dependency problem under Ubuntu:
+# See http://wiki.apache.org/commons/VfsProblems
+RUN cd /usr/share/maven/lib && ln -s ../../java/commons-lang.jar .
+
+#######
+# Oracle Java
+#######
+
+RUN apt-get install -y software-properties-common
+RUN add-apt-repository -y ppa:webupd8team/java
+RUN apt-get update
+
+
+# Auto-accept the Oracle JDK license
+RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
+RUN apt-get install -y oracle-java7-installer
+
+# Auto-accept the Oracle JDK license
+RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
+RUN apt-get install -y oracle-java8-installer
+
+######
+# Install findbugs
+######
+RUN mkdir -p /opt/findbugs && \
+    curl -L https://sourceforge.net/projects/findbugs/files/findbugs/3.0.1/findbugs-noUpdateChecks-3.0.1.tar.gz/download
\
+         -o /opt/findbugs.tar.gz && \
+    tar xzf /opt/findbugs.tar.gz --strip-components 1 -C /opt/findbugs
+ENV FINDBUGS_HOME /opt/findbugs
+
+####
+# Install shellcheck
+####
+RUN apt-get install -y cabal-install
+RUN cabal update && cabal install shellcheck --global
+
+####
+# Install rubocop
+###
+RUN gem install rubocop
+
+####
+# Install ruby-lint
+###
+RUN gem install ruby-lint
+
+####
+# Install bats
+####
+RUN add-apt-repository -y ppa:duggan/bats
+RUN apt-get update
+RUN apt-get install -y bats
+
+###
+# Set the locale
+###
+RUN locale-gen en_US.UTF-8
+ENV LANG en_US.UTF-8
+ENV LANGUAGE en_US:en
+ENV LC_ALL en_US.UTF-8
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/test-patch-docker/Dockerfile-endstub
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/Dockerfile-endstub b/precommit/test-patch-docker/Dockerfile-endstub
index aa0463e..ce76491 100644
--- a/precommit/test-patch-docker/Dockerfile-endstub
+++ b/precommit/test-patch-docker/Dockerfile-endstub
@@ -15,5 +15,7 @@
 # limitations under the License.
 
 ADD launch-test-patch.sh /testptch/launch-test-patch.sh
+RUN mkdir /testptch/extras
+RUN chmod a+rwx /testptch/extras
 RUN chmod a+rx /testptch/launch-test-patch.sh
 CMD /testptch/launch-test-patch.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/test-patch-docker/Dockerfile-startstub
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/Dockerfile-startstub b/precommit/test-patch-docker/Dockerfile-startstub
deleted file mode 100644
index d191285..0000000
--- a/precommit/test-patch-docker/Dockerfile-startstub
+++ /dev/null
@@ -1,91 +0,0 @@
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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.
-
-FROM ubuntu:trusty
-
-WORKDIR /root
-
-######
-# Install common dependencies from packages
-######
-RUN apt-get update && apt-get install --no-install-recommends -y \
-    git curl ant make maven \
-    cmake gcc g++ protobuf-compiler \
-    build-essential libtool \
-    zlib1g-dev pkg-config libssl-dev \
-    snappy libsnappy-dev \
-    bzip2 libbz2-dev \
-    libjansson-dev \
-    fuse libfuse-dev \
-    libcurl4-openssl-dev \
-    python python2.7 pylint \
-    ruby \
-    openjdk-7-jdk \
-    libperl-critic-perl
-
-# Fixing the Apache commons / Maven dependency problem under Ubuntu:
-# See http://wiki.apache.org/commons/VfsProblems
-RUN cd /usr/share/maven/lib && ln -s ../../java/commons-lang.jar .
-
-#######
-# Oracle Java
-#######
-
-RUN apt-get install -y software-properties-common
-RUN add-apt-repository -y ppa:webupd8team/java
-RUN apt-get update
-
-
-# Auto-accept the Oracle JDK license
-RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
-RUN apt-get install -y oracle-java7-installer
-
-# Auto-accept the Oracle JDK license
-RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
-RUN apt-get install -y oracle-java8-installer
-
-######
-# Install findbugs
-######
-RUN mkdir -p /opt/findbugs && \
-    curl -L https://sourceforge.net/projects/findbugs/files/findbugs/3.0.1/findbugs-noUpdateChecks-3.0.1.tar.gz/download
\
-         -o /opt/findbugs.tar.gz && \
-    tar xzf /opt/findbugs.tar.gz --strip-components 1 -C /opt/findbugs
-ENV FINDBUGS_HOME /opt/findbugs
-
-####
-# Install shellcheck
-####
-RUN apt-get install -y cabal-install
-RUN cabal update && cabal install shellcheck --global
-
-####
-# Install rubocop
-###
-RUN gem install rubocop
-
-####
-# Install ruby-lint
-###
-RUN gem install ruby-lint
-
-####
-# Install bats
-####
-RUN add-apt-repository -y ppa:duggan/bats
-RUN apt-get update
-RUN apt-get install -y bats

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/test-patch-docker/launch-test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/launch-test-patch.sh b/precommit/test-patch-docker/launch-test-patch.sh
index ac976ad..67c7dfd 100755
--- a/precommit/test-patch-docker/launch-test-patch.sh
+++ b/precommit/test-patch-docker/launch-test-patch.sh
@@ -38,6 +38,16 @@ TESTPATCHMODE=${TESTPATCHMODE/--docker }
 cd "${BASEDIR}"
 PATCH_DIR=$(cd -P -- "${PATCH_DIR}" >/dev/null && pwd -P)
 
+# if patch system is generic, then it's either a local
+# patch file or was in some other way not pulled from a bug
+# system.  So we need to rescue it and then tell
+# test-patch where to find it.
+if [[ "${PATCH_SYSTEM}" = generic ]]; then
+  cp -p "${PATCH_DIR}/patch" /testptch/extras/patch
+  patchfile="/testptch/extras/patch"
+fi
+
+
 cd "${PATCH_DIR}/precommit/"
 #shellcheck disable=SC2086
 "${PATCH_DIR}/precommit/test-patch.sh" \
@@ -46,5 +56,5 @@ cd "${PATCH_DIR}/precommit/"
    --basedir="${BASEDIR}" \
    --patch-dir="${PATCH_DIR}" \
    --java-home="${JAVA_HOME}" \
-   --personality="${PATCH_DIR}/precommit/personality/provided.sh" \
-   --user-plugins="${PATCH_DIR}/precommit/user-plugins"
\ No newline at end of file
+   --user-plugins="${PATCH_DIR}/precommit/user-plugins" \
+   ${patchfile}

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/test-patch-docker/test-patch-docker.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch-docker/test-patch-docker.sh b/precommit/test-patch-docker/test-patch-docker.sh
index ca910ff..ae31556 100755
--- a/precommit/test-patch-docker/test-patch-docker.sh
+++ b/precommit/test-patch-docker/test-patch-docker.sh
@@ -37,7 +37,7 @@ function yetus_debug
 function dockercmd
 {
   yetus_debug "docker $*"
-  docker "$@"
+  "${DOCKERCMD}" "$@"
 }
 
 ## @description  Handle command line arguments
@@ -54,6 +54,9 @@ function parse_args
       --debug)
         YETUS_SHELL_SCRIPT_DEBUG=true
       ;;
+      --dockercmd=*)
+        DOCKERCMD=${i#*=}
+      ;;
       --dockerversion=*)
         DOCKER_VERSION=${i#*=}
       ;;
@@ -67,6 +70,9 @@ function parse_args
       --patch-dir=*)
         PATCH_DIR=${i#*=}
       ;;
+      --patchsystem=*)
+        PATCH_SYSTEM=${i#*=}
+      ;;
       --project=*)
         PROJECT_NAME=${i#*=}
       ;;
@@ -367,6 +373,7 @@ PatchSpecificDocker
       --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
       --env=JAVA_HOME="${JAVA_HOME}" \
       --env=PATCH_DIR=/testptch/patchprocess \
+      --env=PATCH_SYSTEM="${PATCH_SYSTEM}" \
       --env=PROJECT_NAME="${PROJECT_NAME}" \
       --env=TESTPATCHMODE="${TESTPATCHMODE}" \
       "test-patch-tp-${PROJECT_NAME}-${DID}"
@@ -380,6 +387,7 @@ PatchSpecificDocker
       --env=DOCKER_VERSION="${DOCKER_VERSION} Image:${baseimagename}" \
       --env=JAVA_HOME="${JAVA_HOME}" \
       --env=PATCH_DIR="${PATCH_DIR}" \
+      --env=PATCH_SYSTEM="${PATCH_SYSTEM}" \
       --env=PROJECT_NAME="${PROJECT_NAME}" \
       --env=TESTPATCHMODE="${TESTPATCHMODE}" \
       "test-patch-tp-${PROJECT_NAME}-${DID}"

http://git-wip-us.apache.org/repos/asf/yetus/blob/72645f46/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
index 1847848..cb3160a 100755
--- a/precommit/test-patch.sh
+++ b/precommit/test-patch.sh
@@ -56,7 +56,7 @@ function setup_defaults
 {
   common_defaults
 
-  DOCKERFILE="${BINDIR}/test-patch-docker/Dockerfile-startstub"
+  DOCKERFILE="${BINDIR}/test-patch-docker/Dockerfile"
   HOW_TO_CONTRIBUTE="https://yetus.apache.org/documentation/latest/precommit-patchnames"
   INSTANCE=${RANDOM}
   RELOCATE_PATCH_DIR=false
@@ -677,6 +677,7 @@ function yetus_usage
   echo "--debug                If set, then output some extra stuff to stderr"
   echo "--dirty-workspace      Allow the local git workspace to have uncommitted changes"
   echo "--docker               Spawn a docker container"
+  echo "--dockercmd=<file>     Command to use as docker executable (default: docker
from path)"
   echo "--dockerfile=<file>    Dockerfile fragment to use as the base"
   echo "--java-home=<path>     Set JAVA_HOME (In Docker mode, this should be local
to the image)"
   echo "--linecomments=<bug>   Only write line comments to this comma delimited list
(defaults to bugcomments)"
@@ -762,6 +763,9 @@ function parse_args
       --docker)
         DOCKERSUPPORT=true
       ;;
+      --dockercmd=*)
+        DOCKERCMD=${i#*=}
+      ;;
       --dockerfile=*)
         DOCKERFILE=${i#*=}
       ;;
@@ -912,6 +916,12 @@ function parse_args
   GITDIFFCONTENT="${PATCH_DIR}/gitdiffcontent.txt"
   GITUNIDIFFLINES="${PATCH_DIR}/gitdiffunilines.txt"
 
+  if [[ -n "${REEXECPERSONALITY}"
+     && -f "${PATCH_DIR}/precommit/personality/provided.sh" ]]; then
+    PERSONALITY="${PATCH_DIR}/precommit/personality/provided.sh"
+  fi
+
+  DOCKERFILE=$(yetus_abs "${DOCKERFILE}")
 }
 
 ## @description  Locate the build file for a given directory
@@ -1363,9 +1373,11 @@ function apply_patch_file
 ## @replaceable  no
 function copytpbits
 {
-  local dockerdir
-  local dockfile
-  local person
+  declare dockerdir
+  declare dockfile
+  declare person
+  declare lines
+
   # we need to copy/consolidate all the bits that might have changed
   # that are considered part of test-patch.  This *might* break
   # things that do off-path includes, but there isn't much we can
@@ -1416,10 +1428,16 @@ function copytpbits
     (
       echo "### TEST_PATCH_PRIVATE: dockerfile=${DOCKERFILE}"
       echo "### TEST_PATCH_PRIVATE: gitrev=${gitfilerev}"
-      cat "${DOCKERFILE}"
+      lines=$(${GREP} -n 'YETUS CUT HERE' ${DOCKERFILE} | cut -f1 -d:)
+      if [[ -z "${lines}" ]]; then
+        cat "${DOCKERFILE}"
+      else
+        head -n "${lines}" "${DOCKERFILE}"
+      fi
       # make sure we put some space between, just in case last
       # line isn't an empty line or whatever
       printf "\n\n"
+      echo "### TEST_PATCH_PRIVATE: start test-patch-bootstrap"
       cat "${BINDIR}/test-patch-docker/Dockerfile-endstub"
 
       printf "\n\n"
@@ -1430,6 +1448,34 @@ function copytpbits
   popd >/dev/null
 }
 
+## @description  Verify docker exists
+## @audience     private
+## @stability    evolving
+## @replaceable  no
+## @returns      1 if docker not found
+## @returns      0 if docker is found
+function dockerverify
+{
+  declare pathdocker
+
+  if [[ -z "${DOCKERCMD}" ]]; then
+    pathdocker=$(which docker 2>/dev/null)
+
+    if [[ ! -f "${pathdocker}" ]]; then
+      yetus_error "Docker cannot be found."
+      return 1
+    fi
+    DOCKERCMD="${pathdocker}"
+  fi
+
+  if [[ ! -x "${DOCKERCMD}" ]];then
+    yetus_error "Docker command ${DOCKERCMD} is not executable."
+    return 1
+  fi
+  return 0
+}
+
+
 ## @description  If this patches actually patches test-patch.sh, then
 ## @description  run with the patched version for the test.
 ## @audience     private
@@ -1450,6 +1496,10 @@ function check_reexec
     return
   fi
 
+  # determine if the patch hits
+  # any test-patch sensitive bits
+  # if so, we need to copy the universe
+  # after patching it (copy=true)
   for testdir in "${BINDIR}" \
       "${PERSONALITY}" \
       "${USER_PLUGIN_DIR}" \
@@ -1461,6 +1511,14 @@ function check_reexec
     fi
   done
 
+  if [[ "${DOCKERSUPPORT}" = true ]]; then
+    dockerverify
+    if [[ $? == 1 ]]; then
+      yetus_error "Docker not found or not executable. Disabling Docker mode."
+      DOCKERSUPPORT=false
+    fi
+  fi
+
   if [[ ${copy} == true ]]; then
     big_console_header "precommit patch detected"
 
@@ -1489,8 +1547,8 @@ function check_reexec
   fi
 
   if [[ ${DOCKERSUPPORT} == true
-      && ${copy} == false ]]; then
-    big_console_header "Re-execing under Docker"
+    && ${copy} == false ]]; then
+      big_console_header "Re-execing under Docker"
   fi
 
   # copy our universe
@@ -1513,17 +1571,21 @@ function check_reexec
     if [[ -n "${BUILD_URL}" ]]; then
       TESTPATCHMODE="--build-url=${BUILD_URL} ${TESTPATCHMODE}"
     fi
+
+    if [[ -f "${PERSONALITY}" ]]; then
+      TESTPATCHMODE="--tpperson=${PERSONALITY} ${TESTPATCHMODE}"
+    fi
+
     TESTPATCHMODE="--tpglobaltimer=${GLOBALTIMER} ${TESTPATCHMODE}"
     TESTPATCHMODE="--tpreexectimer=${TIMER} ${TESTPATCHMODE}"
     TESTPATCHMODE="--tpinstance=${INSTANCE} ${TESTPATCHMODE}"
-    TESTPATCHMODE="--tpperson=${PERSONALITY} ${TESTPATCHMODE}"
     TESTPATCHMODE="--plugins=${ENABLED_PLUGINS// /,} ${TESTPATCHMODE}"
     TESTPATCHMODE=" ${TESTPATCHMODE}"
     export TESTPATCHMODE
 
     patchdir=$(relative_dir "${PATCH_DIR}")
 
-    if [[ ${TP_SHELL_SCRIPT_DEBUG} = true ]]; then
+    if [[ "${YETUS_SHELL_SCRIPT_DEBUG}" = true ]]; then
       debugflag="--debug"
     fi
 
@@ -1531,11 +1593,12 @@ function check_reexec
     #shellcheck disable=SC2093
     exec bash "${PATCH_DIR}/precommit/test-patch-docker/test-patch-docker.sh" \
        ${debugflag} \
+       --dockercmd="${DOCKERCMD}" \
        --dockerversion="${dockerversion}" \
        --java-home="${JAVA_HOME}" \
        --patch-dir="${patchdir}" \
-       --project="${PROJECT_NAME}"
-
+       --patchsystem="${PATCH_SYSTEM}" \
+       --project="${PROJECT_NAME}" \
   else
 
     # if we aren't doing docker, then just call ourselves
@@ -2564,7 +2627,7 @@ function prechecks
   declare plugin
   declare result=0
 
-  for plugin in ${BUILDTOOL} ${TESTTYPES} ${TESTFORMATS}; do
+  for plugin in ${BUILDTOOL} ${NEEDEDTESTS} ${TESTFORMATS}; do
     verify_patchdir_still_exists
 
     if declare -f ${plugin}_precheck >/dev/null 2>&1; then


Mime
View raw message