Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-7018][BUILD] Refactor dev/run-tests-jenkins into Python #9161

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
31b51de
initial cut of refactored run-tests-jenkins script into python
Jul 13, 2015
f2a1dc6
fixed pep8 issues
Jul 14, 2015
d202c42
fixed list bug when finding log files
Jul 14, 2015
3ae1d49
correctly escape newlines for long strings
Jul 14, 2015
2a3d67d
fixed numerous bugs, updated to use urllib2 over curl, removed 'find'…
Jul 15, 2015
d83c535
fixed typos, style, and linting issues
Jul 15, 2015
3acac90
fixed indenting with list
Jul 15, 2015
395928d
fixed typo
Jul 15, 2015
30f90bc
fixed merge conflicts
Jul 15, 2015
4765dc8
added variables to remove indents, fixed ' : ' => ': ' in maps
Jul 15, 2015
e90fdeb
moved if statement for urllib2 into the try block
Jul 15, 2015
64c13c1
updated token passing for github oauth
Jul 15, 2015
85aaf76
added subprocess_check_call() as backport from python 2.7, moved subp…
Jul 15, 2015
f756098
removed unnecessary escapes
Jul 15, 2015
39f6a1f
changed test process to only return the returncode
Jul 15, 2015
7b11665
fixed serialization error between int and string, created an error re…
Jul 15, 2015
cf110bc
fixed reference error and pep8 bugs
Jul 15, 2015
c9e5c5f
commented out tests and fixed test result output
Jul 16, 2015
5272381
printing of the pr results
Jul 16, 2015
528279a
fixed strip issue with PR results, from strip => rstrip
Jul 16, 2015
6a9ed32
run-tests-jenkins now properly runs the tests, removed license from f…
Jul 16, 2015
22f9be8
reverted license
Jul 16, 2015
5d63bc5
removed mima to fail binary compatibility checks
Jul 16, 2015
33e3143
reverted mima excludes
Jul 16, 2015
d82567a
set accumulator test suite to fail
Jul 16, 2015
2117c64
reverted accumulator test in favor of graphx test to only trigger 'gr…
Jul 16, 2015
831376e
fixed scala style check
Jul 16, 2015
d76f559
fixed scala style checks
Jul 16, 2015
05d9ef4
reverted scala test failure, added pyspark failure
Jul 16, 2015
0ad51b4
updated to add --absolute-names with tar command for archiving logs
Jul 27, 2015
a218baf
reverting python test
Aug 4, 2015
2853b60
fixed merge conflicts
Oct 16, 2015
fe397fb
updated to account for PR #7883
Oct 16, 2015
206930e
removed 'send_archived_logs' function
Oct 16, 2015
e96ad6c
Merge 206930e5fcccc239485c092d0fb4d418fbbb0178 into 8d4449c7f5d528410…
Oct 18, 2015
0e56bbc
Merge remote-tracking branch 'origin/master' into run-tests-jenkins-r…
JoshRosen Oct 18, 2015
c5891f4
Increase build timeout to new limit
JoshRosen Oct 18, 2015
27f215d
Port changes from #7878.
JoshRosen Oct 18, 2015
ca9f49b
use 'in' instead of contains()
JoshRosen Oct 18, 2015
43123d7
Inject R style failures
JoshRosen Oct 18, 2015
c6ca012
Revert "Inject R style failures"
JoshRosen Oct 19, 2015
f93a62a
Link to full console logs intead of preview
JoshRosen Oct 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/lint-python
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
SPARK_ROOT_DIR="$(dirname "$SCRIPT_DIR")"
PATHS_TO_CHECK="./python/pyspark/ ./ec2/spark_ec2.py ./examples/src/main/python/ ./dev/sparktestsupport"
PATHS_TO_CHECK="$PATHS_TO_CHECK ./dev/run-tests.py ./python/run-tests.py"
PATHS_TO_CHECK="$PATHS_TO_CHECK ./dev/run-tests.py ./python/run-tests.py ./dev/run-tests-jenkins.py"
PEP8_REPORT_PATH="$SPARK_ROOT_DIR/dev/pep8-report.txt"
PYLINT_REPORT_PATH="$SPARK_ROOT_DIR/dev/pylint-report.txt"
PYLINT_INSTALL_INFO="$SPARK_ROOT_DIR/dev/pylint-info.txt"
Expand Down
30 changes: 0 additions & 30 deletions dev/run-tests-codes.sh

This file was deleted.

204 changes: 2 additions & 202 deletions dev/run-tests-jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -22,207 +22,7 @@
# 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)"
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}"

# format: http://linux.die.net/man/1/timeout
# must be less than the timeout configured on Jenkins (currently 300m)
TESTS_TIMEOUT="250m"

# 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"
# DISABLED (pwendell) "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
}

# 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 "\$ghprbActualCommit: $ghprbActualCommit"
echo "\$sha1: $sha1"
echo "\$ghprbPullTitle: $ghprbPullTitle"

# 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
{
# Marks this build is a pull request build.
export AMP_JENKINS_PRB=true
if [[ $ghprbPullTitle == *"test-maven"* ]]; then
export AMPLAB_JENKINS_BUILD_TOOL="maven"
fi
if [[ $ghprbPullTitle == *"test-hadoop1.0"* ]]; then
export AMPLAB_JENKINS_BUILD_PROFILE="hadoop1.0"
elif [[ $ghprbPullTitle == *"test-hadoop2.0"* ]]; then
export AMPLAB_JENKINS_BUILD_PROFILE="hadoop2.0"
elif [[ $ghprbPullTitle == *"test-hadoop2.2"* ]]; then
export AMPLAB_JENKINS_BUILD_PROFILE="hadoop2.2"
elif [[ $ghprbPullTitle == *"test-hadoop2.3"* ]]; then
export AMPLAB_JENKINS_BUILD_PROFILE="hadoop2.3"
fi

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}console)** \
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_R_STYLE" ]; then
failing_test="R style tests"
elif [ "$test_result" -eq "$BLOCK_DOCUMENTATION" ]; then
failing_test="to generate documentation"
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
}

# post end message
{
result_message="\
[Test build ${BUILD_DISPLAY_NAME} has finished](${BUILD_URL}console) 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
exec python -u ./dev/run-tests-jenkins.py "$@"
Loading