Add jenkins job for testapi mongodb backup 17/27417/11
authorrohitsakala <rohitsakala@gmail.com>
Mon, 23 Jan 2017 20:56:53 +0000 (02:26 +0530)
committerrohitsakala <rohitsakala@gmail.com>
Wed, 25 Jan 2017 11:00:09 +0000 (16:30 +0530)
Mongodb backup will run every week and will get pushed into
artifacts.opnfv.org/testing/

JIRA: FUNCTEST-701

Change-Id: I3a6fee59a1b8b5bdc46f07f6f6e9f5a60b77f24f
Signed-off-by: rohitsakala <rohitsakala@gmail.com>
jjb/releng/testapi-automate.yml
jjb/releng/testapi-backup-mongodb.sh [new file with mode: 0644]

index 24e9b86..5102083 100644 (file)
 
     project: 'releng'
 
+- job:
+    name: 'testapi-mongodb-backup'
+
+    slave-label: 'testresults'
+
+    scm:
+        - git-scm
+
+    triggers:
+        - timed: '@weekly'
+
+    builders:
+        - mongodb-backup
+
 - job-template:
     name: 'testapi-verify-{stream}'
 
 ################################
 # job builders
 ################################
+- builder:
+    name: mongodb-backup
+    builders:
+        - shell: |
+            bash ./jjb/releng/testapi-backup-mongodb.sh
 
 - builder:
     name: run-unit-tests
diff --git a/jjb/releng/testapi-backup-mongodb.sh b/jjb/releng/testapi-backup-mongodb.sh
new file mode 100644 (file)
index 0000000..52957ab
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+set -e
+
+# Run MongoDB backup
+python $WORKSPACE/utils/test/testapi/update/templates/backup_mongodb.py -o $WORKSPACE/
+
+# Compressing the dump
+now=$(date +"%m_%d_%Y_%H_%M_%S")
+echo $now
+
+file_name="testapi_mongodb_"$now".tar.gz"
+echo $file_name
+
+tar cvfz "$file_name" test_results_collection*
+
+rm -rf test_results_collection*
+
+artifact_dir="testapibackup"
+workspace="$WORKSPACE"
+
+set +e
+/usr/local/bin/gsutil &>/dev/null
+if [ $? != 0 ]; then
+    echo "Not possible to push results to artifact: gsutil not installed"
+    exit 1
+else
+    echo "Uploading mongodump to artifact $artifact_dir"
+    /usr/local/bin/gsutil cp -r "$workspace"/"$file_name" gs://testingrohit/"$artifact_dir"/
+    echo "MongoDump can be found at http://artifacts.opnfv.org/$artifact_dir"
+fi