04e44b37cc
This PR update PySpark to support Python 3 (tested with 3.4). Known issue: unpickle array from Pyrolite is broken in Python 3, those tests are skipped. TODO: ec2/spark-ec2.py is not fully tested with python3. Author: Davies Liu <davies@databricks.com> Author: twneale <twneale@gmail.com> Author: Josh Rosen <joshrosen@databricks.com> Closes #5173 from davies/python3 and squashes the following commits: d7d6323 [Davies Liu] fix tests 6c52a98 [Davies Liu] fix mllib test 99e334f [Davies Liu] update timeout b716610 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 cafd5ec [Davies Liu] adddress comments from @mengxr bf225d7 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 179fc8d [Davies Liu] tuning flaky tests 8c8b957 [Davies Liu] fix ResourceWarning in Python 3 5c57c95 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 4006829 [Davies Liu] fix test 2fc0066 [Davies Liu] add python3 path 71535e9 [Davies Liu] fix xrange and divide 5a55ab4 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 125f12c [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 ed498c8 [Davies Liu] fix compatibility with python 3 820e649 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 e8ce8c9 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 ad7c374 [Davies Liu] fix mllib test and warning ef1fc2f [Davies Liu] fix tests 4eee14a [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 20112ff [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 59bb492 [Davies Liu] fix tests 1da268c [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 ca0fdd3 [Davies Liu] fix code style 9563a15 [Davies Liu] add imap back for python 2 0b1ec04 [Davies Liu] make python examples work with Python 3 d2fd566 [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 a716d34 [Davies Liu] test with python 3.4 f1700e8 [Davies Liu] fix test in python3 671b1db [Davies Liu] fix test in python3 692ff47 [Davies Liu] fix flaky test 7b9699f [Davies Liu] invalidate import cache for Python 3.3+ 9c58497 [Davies Liu] fix kill worker 309bfbf [Davies Liu] keep compatibility 5707476 [Davies Liu] cleanup, fix hash of string in 3.3+ 8662d5b [Davies Liu] Merge branch 'master' of github.com:apache/spark into python3 f53e1f0 [Davies Liu] fix tests 70b6b73 [Davies Liu] compile ec2/spark_ec2.py in python 3 a39167e [Davies Liu] support customize class in __main__ 814c77b [Davies Liu] run unittests with python 3 7f4476e [Davies Liu] mllib tests passed d737924 [Davies Liu] pass ml tests 375ea17 [Davies Liu] SQL tests pass 6cc42a9 [Davies Liu] rename 431a8de [Davies Liu] streaming tests pass 78901a7 [Davies Liu] fix hash of serializer in Python 3 24b2f2e [Davies Liu] pass all RDD tests 35f48fe [Davies Liu] run future again 1eebac2 [Davies Liu] fix conflict in ec2/spark_ec2.py 6e3c21d [Davies Liu] make cloudpickle work with Python3 2fb2db3 [Josh Rosen] Guard more changes behind sys.version; still doesn't run 1aa5e8f [twneale] Turned out `pickle.DictionaryType is dict` == True, so swapped it out 7354371 [twneale] buffer --> memoryview I'm not super sure if this a valid change, but the 2.7 docs recommend using memoryview over buffer where possible, so hoping it'll work. b69ccdf [twneale] Uses the pure python pickle._Pickler instead of c-extension _pickle.Pickler. It appears pyspark 2.7 uses the pure python pickler as well, so this shouldn't degrade pickling performance (?). f40d925 [twneale] xrange --> range e104215 [twneale] Replaces 2.7 types.InstsanceType with 3.4 `object`....could be horribly wrong depending on how types.InstanceType is used elsewhere in the package--see http://bugs.python.org/issue8206 79de9d0 [twneale] Replaces python2.7 `file` with 3.4 _io.TextIOWrapper 2adb42d [Josh Rosen] Fix up some import differences between Python 2 and 3 854be27 [Josh Rosen] Run `futurize` on Python code: 7c5b4ce [Josh Rosen] Remove Python 3 check in shell.py.
242 lines
7.9 KiB
Bash
Executable file
242 lines
7.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
#
|
|
# 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.
|
|
#
|
|
|
|
# Wrapper script that runs the Spark tests then reports QA results
|
|
# to github via its API.
|
|
# Environment variables are populated by the code here:
|
|
#+ https://github.com/jenkinsci/ghprb-plugin/blob/master/src/main/java/org/jenkinsci/plugins/ghprb/GhprbTrigger.java#L139
|
|
|
|
# Go to the Spark project root directory
|
|
FWDIR="$(cd `dirname $0`/..; pwd)"
|
|
cd "$FWDIR"
|
|
|
|
source "$FWDIR/dev/run-tests-codes.sh"
|
|
|
|
COMMENTS_URL="https://api.github.com/repos/apache/spark/issues/$ghprbPullId/comments"
|
|
PULL_REQUEST_URL="https://github.com/apache/spark/pull/$ghprbPullId"
|
|
|
|
# Important Environment Variables
|
|
# ---
|
|
# $ghprbActualCommit
|
|
#+ This is the hash of the most recent commit in the PR.
|
|
#+ The merge-base of this and master is the commit from which the PR was branched.
|
|
# $sha1
|
|
#+ If the patch merges cleanly, this is a reference to the merge commit hash
|
|
#+ (e.g. "origin/pr/2606/merge").
|
|
#+ If the patch does not merge cleanly, it is equal to $ghprbActualCommit.
|
|
#+ The merge-base of this and master in the case of a clean merge is the most recent commit
|
|
#+ against master.
|
|
|
|
COMMIT_URL="https://github.com/apache/spark/commit/${ghprbActualCommit}"
|
|
# GitHub doesn't auto-link short hashes when submitted via the API, unfortunately. :(
|
|
SHORT_COMMIT_HASH="${ghprbActualCommit:0:7}"
|
|
|
|
TESTS_TIMEOUT="150m" # format: http://linux.die.net/man/1/timeout
|
|
|
|
# Array to capture all tests to run on the pull request. These tests are held under the
|
|
#+ dev/tests/ directory.
|
|
#
|
|
# To write a PR test:
|
|
#+ * the file must reside within the dev/tests directory
|
|
#+ * be an executable bash script
|
|
#+ * accept three arguments on the command line, the first being the Github PR long commit
|
|
#+ hash, the second the Github SHA1 hash, and the final the current PR hash
|
|
#+ * and, lastly, return string output to be included in the pr message output that will
|
|
#+ be posted to Github
|
|
PR_TESTS=(
|
|
"pr_merge_ability"
|
|
"pr_public_classes"
|
|
"pr_new_dependencies"
|
|
)
|
|
|
|
function post_message () {
|
|
local message=$1
|
|
local data="{\"body\": \"$message\"}"
|
|
local HTTP_CODE_HEADER="HTTP Response Code: "
|
|
|
|
echo "Attempting to post to Github..."
|
|
|
|
local curl_output=$(
|
|
curl `#--dump-header -` \
|
|
--silent \
|
|
--user x-oauth-basic:$GITHUB_OAUTH_KEY \
|
|
--request POST \
|
|
--data "$data" \
|
|
--write-out "${HTTP_CODE_HEADER}%{http_code}\n" \
|
|
--header "Content-Type: application/json" \
|
|
"$COMMENTS_URL" #> /dev/null #| "$FWDIR/dev/jq" .id #| head -n 8
|
|
)
|
|
local curl_status=${PIPESTATUS[0]}
|
|
|
|
if [ "$curl_status" -ne 0 ]; then
|
|
echo "Failed to post message to GitHub." >&2
|
|
echo " > curl_status: ${curl_status}" >&2
|
|
echo " > curl_output: ${curl_output}" >&2
|
|
echo " > data: ${data}" >&2
|
|
# exit $curl_status
|
|
fi
|
|
|
|
local api_response=$(
|
|
echo "${curl_output}" \
|
|
| grep -v -e "^${HTTP_CODE_HEADER}"
|
|
)
|
|
|
|
local http_code=$(
|
|
echo "${curl_output}" \
|
|
| grep -e "^${HTTP_CODE_HEADER}" \
|
|
| sed -r -e "s/^${HTTP_CODE_HEADER}//g"
|
|
)
|
|
|
|
if [ -n "$http_code" ] && [ "$http_code" -ne "201" ]; then
|
|
echo " > http_code: ${http_code}." >&2
|
|
echo " > api_response: ${api_response}" >&2
|
|
echo " > data: ${data}" >&2
|
|
fi
|
|
|
|
if [ "$curl_status" -eq 0 ] && [ "$http_code" -eq "201" ]; then
|
|
echo " > Post successful."
|
|
fi
|
|
}
|
|
|
|
function send_archived_logs () {
|
|
echo "Archiving unit tests logs..."
|
|
|
|
local log_files=$(
|
|
find .\
|
|
-name "unit-tests.log" -o\
|
|
-path "./sql/hive/target/HiveCompatibilitySuite.failed" -o\
|
|
-path "./sql/hive/target/HiveCompatibilitySuite.hiveFailed" -o\
|
|
-path "./sql/hive/target/HiveCompatibilitySuite.wrong"
|
|
)
|
|
|
|
if [ -z "$log_files" ]; then
|
|
echo "> No log files found." >&2
|
|
else
|
|
local log_archive="unit-tests-logs.tar.gz"
|
|
echo "$log_files" | xargs tar czf ${log_archive}
|
|
|
|
local jenkins_build_dir=${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}
|
|
local scp_output=$(scp ${log_archive} amp-jenkins-master:${jenkins_build_dir}/${log_archive})
|
|
local scp_status="$?"
|
|
|
|
if [ "$scp_status" -ne 0 ]; then
|
|
echo "Failed to send archived unit tests logs to Jenkins master." >&2
|
|
echo "> scp_status: ${scp_status}" >&2
|
|
echo "> scp_output: ${scp_output}" >&2
|
|
else
|
|
echo "> Send successful."
|
|
fi
|
|
|
|
rm -f ${log_archive}
|
|
fi
|
|
}
|
|
|
|
# post start message
|
|
{
|
|
start_message="\
|
|
[Test build ${BUILD_DISPLAY_NAME} has started](${BUILD_URL}consoleFull) for \
|
|
PR $ghprbPullId at commit [\`${SHORT_COMMIT_HASH}\`](${COMMIT_URL})."
|
|
|
|
post_message "$start_message"
|
|
}
|
|
|
|
# Environment variable to capture PR test output
|
|
pr_message=""
|
|
# Ensure we save off the current HEAD to revert to
|
|
current_pr_head="`git rev-parse HEAD`"
|
|
|
|
echo "HEAD: `git rev-parse HEAD`"
|
|
echo "GHPRB: $ghprbActualCommit"
|
|
echo "SHA1: $sha1"
|
|
|
|
# Run pull request tests
|
|
for t in "${PR_TESTS[@]}"; do
|
|
this_test="${FWDIR}/dev/tests/${t}.sh"
|
|
# Ensure the test can be found and is a file
|
|
if [ -f "${this_test}" ]; then
|
|
echo "Running test: $t"
|
|
this_mssg="$(bash "${this_test}" "${ghprbActualCommit}" "${sha1}" "${current_pr_head}")"
|
|
# Check if this is the merge test as we submit that note *before* and *after*
|
|
# the tests run
|
|
[ "$t" == "pr_merge_ability" ] && merge_note="${this_mssg}"
|
|
pr_message="${pr_message}\n${this_mssg}"
|
|
# Ensure, after each test, that we're back on the current PR
|
|
git checkout -f "${current_pr_head}" &>/dev/null
|
|
else
|
|
echo "Cannot find test ${this_test}."
|
|
fi
|
|
done
|
|
|
|
# run tests
|
|
{
|
|
timeout "${TESTS_TIMEOUT}" ./dev/run-tests
|
|
test_result="$?"
|
|
|
|
if [ "$test_result" -eq "124" ]; then
|
|
fail_message="**[Test build ${BUILD_DISPLAY_NAME} timed out](${BUILD_URL}consoleFull)** \
|
|
for PR $ghprbPullId at commit [\`${SHORT_COMMIT_HASH}\`](${COMMIT_URL}) \
|
|
after a configured wait of \`${TESTS_TIMEOUT}\`."
|
|
|
|
post_message "$fail_message"
|
|
exit $test_result
|
|
elif [ "$test_result" -eq "0" ]; then
|
|
test_result_note=" * This patch **passes all tests**."
|
|
else
|
|
if [ "$test_result" -eq "$BLOCK_GENERAL" ]; then
|
|
failing_test="some tests"
|
|
elif [ "$test_result" -eq "$BLOCK_RAT" ]; then
|
|
failing_test="RAT tests"
|
|
elif [ "$test_result" -eq "$BLOCK_SCALA_STYLE" ]; then
|
|
failing_test="Scala style tests"
|
|
elif [ "$test_result" -eq "$BLOCK_PYTHON_STYLE" ]; then
|
|
failing_test="Python style tests"
|
|
elif [ "$test_result" -eq "$BLOCK_BUILD" ]; then
|
|
failing_test="to build"
|
|
elif [ "$test_result" -eq "$BLOCK_MIMA" ]; then
|
|
failing_test="MiMa tests"
|
|
elif [ "$test_result" -eq "$BLOCK_SPARK_UNIT_TESTS" ]; then
|
|
failing_test="Spark unit tests"
|
|
elif [ "$test_result" -eq "$BLOCK_PYSPARK_UNIT_TESTS" ]; then
|
|
failing_test="PySpark unit tests"
|
|
elif [ "$test_result" -eq "$BLOCK_SPARKR_UNIT_TESTS" ]; then
|
|
failing_test="SparkR unit tests"
|
|
else
|
|
failing_test="some tests"
|
|
fi
|
|
|
|
test_result_note=" * This patch **fails $failing_test**."
|
|
fi
|
|
|
|
send_archived_logs
|
|
}
|
|
|
|
# post end message
|
|
{
|
|
result_message="\
|
|
[Test build ${BUILD_DISPLAY_NAME} has finished](${BUILD_URL}consoleFull) for \
|
|
PR $ghprbPullId at commit [\`${SHORT_COMMIT_HASH}\`](${COMMIT_URL})."
|
|
|
|
result_message="${result_message}\n${test_result_note}"
|
|
result_message="${result_message}${pr_message}"
|
|
|
|
post_message "$result_message"
|
|
}
|
|
|
|
exit $test_result
|