KVMFORNFV: Uploading logs to artifacts for debugging. 91/27991/3
authorkalyanreddy <reddyx.gundarapu@intel.com>
Fri, 3 Feb 2017 11:16:20 +0000 (16:46 +0530)
committerKalyan reddy Gundarapu <reddyx.gundarapu@intel.com>
Tue, 7 Feb 2017 17:21:28 +0000 (17:21 +0000)
This patch includes updated scripts for uploading kvmfornfv test
logs(example:ftrace logs) to artifacts for future debugging if needed.

Change-Id: I078169fc777de93cb2706bb07d77520da7527d73
Signed-off-by: Gundarapu Kalyan Reddy <reddyx.gundarapu@intel.com>
jjb/kvmfornfv/kvmfornfv-upload-artifact.sh
jjb/kvmfornfv/kvmfornfv.yml

index 6f8fff3..c6b8005 100755 (executable)
@@ -11,16 +11,17 @@ fi
 
 case "$JOB_TYPE" in
     verify)
-        OPNFV_ARTIFACT_VERSION="gerrit-$GERRIT_CHANGE_NUMBER"
-        GS_UPLOAD_LOCATION="gs://artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
-        echo "Removing outdated artifacts produced for the previous patch for the change $GERRIT_CHANGE_NUMBER"
-        gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1 && gsutil rm -r $GS_UPLOAD_LOCATION
-        echo "Uploading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
-        ;;
+       OPNFV_ARTIFACT_VERSION="gerrit-$GERRIT_CHANGE_NUMBER"
+       GS_UPLOAD_LOCATION="gs://artifacts.opnfv.org/$PROJECT/review/$GERRIT_CHANGE_NUMBER"
+       echo "Removing outdated artifacts produced for the previous patch for the change $GERRIT_CHANGE_NUMBER"
+       gsutil ls $GS_UPLOAD_LOCATION > /dev/null 2>&1 && gsutil rm -r $GS_UPLOAD_LOCATION
+       echo "Uploading artifacts for the change $GERRIT_CHANGE_NUMBER. This could take some time..."
+       ;;
     daily)
         echo "Uploading daily artifacts This could take some time..."
         OPNFV_ARTIFACT_VERSION=$(date -u +"%Y-%m-%d_%H-%M-%S")
         GS_UPLOAD_LOCATION="gs://$GS_URL/$OPNFV_ARTIFACT_VERSION"
+        GS_LOG_LOCATION="gs://$GS_URL/logs-$(date -u +"%Y-%m-%d")/
         ;;
     *)
         echo "Artifact upload is not enabled for $JOB_TYPE jobs"
@@ -38,10 +39,23 @@ esac
 source $WORKSPACE/opnfv.properties
 
 # upload artifacts
-gsutil cp -r $WORKSPACE/build_output/* $GS_UPLOAD_LOCATION > $WORKSPACE/gsutil.log 2>&1
-gsutil -m setmeta -r \
-    -h "Cache-Control:private, max-age=0, no-transform" \
-    $GS_UPLOAD_LOCATION > /dev/null 2>&1
+if [[ "$PHASE" == "build" ]]; then
+    gsutil cp -r $WORKSPACE/build_output/* $GS_UPLOAD_LOCATION > $WORKSPACE/gsutil.log 2>&1
+    gsutil -m setmeta -r \
+        -h "Cache-Control:private, max-age=0, no-transform" \
+        $GS_UPLOAD_LOCATION > /dev/null 2>&1
+else
+    if [[ "$JOB_TYPE" == "daily" ]]; then
+        log_dir=$WORKSPACE/build_output/log
+        if [[ -d "$log_dir" ]]; then
+            #Uploading logs to artifacts
+            echo "Uploading artifacts for future debugging needs...."
+            gsutil cp -r $WORKSPACE/build_output/log-*.tar.gz $GS_LOG_LOCATION > $WORKSPACE/gsutil.log 2>&1
+        else
+            echo "No test logs/artifacts available for uploading"
+        fi
+    fi
+fi
 
 # upload metadata file for the artifacts built by daily job
 if [[ "$JOB_TYPE" == "daily" ]]; then
index 2d1ab57..9857f6a 100644 (file)
             name: TEST_NAME
             default: '{testname}'
             description: "Daily job to execute kvmfornfv '{testname}' testcase."
+        - string:
+            name: PHASE
+            default: '{phase}'
+            description: "Execution of kvmfornfv daily '{phase}' job ."
 
     builders:
         - description-setter:
             !include-raw: ./kvmfornfv-download-artifact.sh
         - shell:
             !include-raw: ./kvmfornfv-test.sh
+        - shell:
+            !include-raw: ./kvmfornfv-upload-artifact.sh
 - builder:
     name: 'kvmfornfv-packet_forward-daily-build-macro'
     builders: