Github user brennonyork commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5694#discussion_r29163677
  
    --- Diff: dev/run-tests.py ---
    @@ -0,0 +1,413 @@
    +#!/usr/bin/env python
    +
    +#
    +# 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.
    +#
    +
    +import os
    +import re
    +import sys
    +import shutil
    +import subprocess
    +
    +SPARK_PROJ_ROOT = \
    +    os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
    +USER_HOME_DIR = os.environ.get("HOME")
    +
    +SBT_MAVEN_PROFILE_ARGS_ENV = "SBT_MAVEN_PROFILES_ARGS"
    +AMPLAB_JENKINS_BUILD_TOOL = os.environ.get("AMPLAB_JENKINS_BUILD_TOOL")
    +AMPLAB_JENKINS = os.environ.get("AMPLAB_JENKINS")
    +
    +SBT_OUTPUT_FILTER = re.compile("^.*[info].*Resolving" + "|" + 
    +                               "^.*[warn].*Merging" + "|" +
    +                               "^.*[info].*Including")
    +
    +
    +def get_error_codes(err_code_file):
    +    """Function to retrieve all block numbers from the `run-tests-codes.sh`
    +    file to maintain backwards compatibility with the `run-tests-jenkins` 
    +    script"""
    +    
    +    with open(err_code_file, 'r') as f:
    +        err_codes = [e.split()[1].strip().split('=') 
    +                     for e in f if e.startswith("readonly")]
    +        return dict(err_codes)
    +
    +
    +def rm_r(path):
    +    """Given an arbitrary path properly remove it with the correct python
    +    construct if it exists
    +    - from: http://stackoverflow.com/a/9559881""";
    +
    +    if os.path.isdir(path):
    +        shutil.rmtree(path)
    +    elif os.path.exists(path):
    +        os.remove(path)
    +
    +
    +def lineno():
    +    """Returns the current line number in our program
    +    - from: http://stackoverflow.com/a/3056059""";
    +
    +    return inspect.currentframe().f_back.f_lineno
    +
    +
    +def run_cmd(cmd):
    +    """Given a command as a list of arguments will attempt to execute the
    +    command and, on failure, print an error message"""
    +
    +    if not isinstance(cmd, list):
    +        cmd = cmd.split()
    +    try:
    +        subprocess.check_call(cmd)
    +    except subprocess.CalledProcessError as e:
    +        print "[error] running", e.cmd, "; received return code", 
e.returncode
    +        sys.exit(e.returncode)
    +
    +
    +def set_sbt_maven_profile_args():
    +    """Properly sets the SBT environment variable arguments with additional
    +    checks to determine if this is running on an Amplab Jenkins machine"""
    +
    +    # base environment values for SBT_MAVEN_PROFILE_ARGS_ENV which will be 
appended on
    +    sbt_maven_profile_args_base = ["-Pkinesis-asl"]
    +
    +    sbt_maven_profile_arg_dict = {
    +        "hadoop1.0" : ["-Dhadoop.version=1.0.4"],
    +        "hadoop2.0" : ["-Dhadoop.version=2.0.0-mr1-cdh4.1.1"],
    +        "hadoop2.2" : ["-Pyarn", "-Phadoop-2.2", "-Dhadoop.version=2.2.0"],
    +        "hadoop2.3" : ["-Pyarn", "-Phadoop-2.3", "-Dhadoop.version=2.3.0"],
    +    }
    +
    +    # set the SBT maven build profile argument environment variable and 
ensure
    +    # we build against the right version of Hadoop
    +    if os.environ.get("AMPLAB_JENKINS_BUILD_PROFILE"):
    +        os.environ[SBT_MAVEN_PROFILE_ARGS_ENV] = \
    +            " ".join(sbt_maven_profile_arg_dict.get(ajbp, []) 
    +                     + sbt_maven_profile_args_base)
    +    else:
    +        os.environ[SBT_MAVEN_PROFILE_ARGS_ENV] = \
    +            " ".join(sbt_maven_profile_arg_dict.get("hadoop2.3", [])
    +                     + sbt_maven_profile_args_base)
    +
    +
    +def is_exe(path):
    +    """Check if a given path is an executable file
    +    - from: http://stackoverflow.com/a/377028""";
    +
    +    return os.path.isfile(path) and os.access(path, os.X_OK)
    +
    +
    +def which(program):
    +    """Find and return the given program by its absolute path or 'None'
    +    - from: http://stackoverflow.com/a/377028""";
    +
    +    fpath, fname = os.path.split(program)
    +
    +    if fpath:
    +        if is_exe(program):
    +            return program
    +    else:
    +        for path in os.environ.get("PATH").split(os.pathsep):
    +            path = path.strip('"')
    +            exe_file = os.path.join(path, program)
    +            if is_exe(exe_file):
    +                return exe_file
    +    return None
    +
    +
    +def determine_java_executable():
    +    """Will return the *best* path possible for a 'java' executable or 
`None`"""
    +
    +    java_home = os.environ.get("JAVA_HOME")
    +
    +    # check if there is an executable at $JAVA_HOME/bin/java
    +    java_exe = which(os.path.join(java_home, "bin/java"))
    +    # if the java_exe wasn't set, check for a `java` version on the $PATH
    +    return java_exe if java_exe else which("java")
    +
    +
    +def determine_java_version(java_exe):
    +    """Given a valid java executable will return its version in tuple 
format as:
    +    [<major-version>, <minor-version>, <patch-version>, 
<update-version>]"""
    +
    +    raw_output = subprocess.check_output([java_exe, "-version"], 
stderr=subprocess.STDOUT)
    +    raw_version_str = raw_output.split('\n')[0] # eg 'java version 
"1.8.0_25"'
    +    version_str = raw_version_str.split()[-1].strip('"') # eg '1.8.0_25'
    +    version, update = version_str.split('_') # eg ['1.8.0', '25']
    +
    +    # map over the values and convert them to integers
    +    return map(lambda x: int(x), version.split('.') + [update])
    --- End diff --
    
    :+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to