Repository: spark
Updated Branches:
  refs/heads/master e595c8d08 -> a29c9bd61


[SPARK-4000][BUILD] Sends archived unit tests logs to Jenkins master

This PR sends archived unit tests logs to the build history directory in 
Jenkins master, so that we can serve it via HTTP later to help debugging 
Jenkins build failures.

pwendell JoshRosen Please help review, thanks!

Author: Cheng Lian <[email protected]>

Closes #2845 from liancheng/log-archive and squashes the following commits:

ac8d9d4 [Cheng Lian] Includes build number in messages posted to GitHub
68c7010 [Cheng Lian] Logs backup should be implemented in dev/run-tests-jenkins
4b912f7 [Cheng Lian] Sends archived unit tests logs to Jenkins master


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

Branch: refs/heads/master
Commit: a29c9bd614e6d8088f759ae39218b945604d0b5b
Parents: e595c8d
Author: Cheng Lian <[email protected]>
Authored: Thu Oct 23 22:15:03 2014 -0700
Committer: Josh Rosen <[email protected]>
Committed: Thu Oct 23 22:15:03 2014 -0700

----------------------------------------------------------------------
 dev/run-tests-jenkins | 53 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/a29c9bd6/dev/run-tests-jenkins
----------------------------------------------------------------------
diff --git a/dev/run-tests-jenkins b/dev/run-tests-jenkins
index 451f3b7..87c6715 100755
--- a/dev/run-tests-jenkins
+++ b/dev/run-tests-jenkins
@@ -53,9 +53,9 @@ 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 \
@@ -75,12 +75,12 @@ function post_message () {
       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}" \
@@ -92,12 +92,39 @@ function post_message () {
       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")
+
+  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
+}
+
 
 # We diff master...$ghprbActualCommit because that gets us changes introduced 
in the PR
 #+ and not anything else added to master since the PR was branched.
@@ -109,7 +136,7 @@ function post_message () {
   else
     merge_note=" * This patch merges cleanly."
   fi
-  
+
   source_files=$(
       git diff master...$ghprbActualCommit --name-only  `# diff patch against 
master from branch point` \
     | grep -v -e "\/test"                               `# ignore files in 
test directories` \
@@ -144,12 +171,12 @@ function post_message () {
 # post start message
 {
   start_message="\
-  [QA tests have started](${BUILD_URL}consoleFull) for \
+  [Test build ${BUILD_DISPLAY_NAME} has started](${BUILD_URL}consoleFull) for \
   PR $ghprbPullId at commit [\`${SHORT_COMMIT_HASH}\`](${COMMIT_URL})."
-  
+
   start_message="${start_message}\n${merge_note}"
   # start_message="${start_message}\n${public_classes_note}"
-  
+
   post_message "$start_message"
 }
 
@@ -159,7 +186,7 @@ function post_message () {
   test_result="$?"
 
   if [ "$test_result" -eq "124" ]; then
-    fail_message="**[Tests timed out](${BUILD_URL}consoleFull)** \
+    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}\`."
 
@@ -187,15 +214,17 @@ function post_message () {
     else
       failing_test="some tests"
     fi
-    
+
     test_result_note=" * This patch **fails $failing_test**."
   fi
+
+  send_archived_logs
 }
 
 # post end message
 {
   result_message="\
-  [QA tests have finished](${BUILD_URL}consoleFull) for \
+  [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}"


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

Reply via email to