[ONOS-7346]ver.h

Change-Id: I464e79ab8a47ed0d027ff9f3cb44c79736559ac5
diff --git a/jjb/OnosSystemTest/cho-clean-up.sh b/jjb/OnosSystemTest/cho-clean-up.sh
index f466d10..a21a274 100644
--- a/jjb/OnosSystemTest/cho-clean-up.sh
+++ b/jjb/OnosSystemTest/cho-clean-up.sh
@@ -2,11 +2,21 @@
 
 source ./clean-up.sh
 
-{beforeClean}
+echo -e "\n Before clean up disk usage: \n"
+df -h
 
 cd /home/admin/OnosSystemTest/TestON/logs
 
-{cleaning}
+if [ $? -eq 0 ]
+then
+   echo "Checking if there are logs older than ${{DAYS_OLD}} days...."
+   for i in $(find . -mtime +${{DAYS_OLD}} -type d)
+   do
+   echo -e "DIRs older than $DAYS_OLD are: "
+   echo $i
+   rm -rf $i
+   done
+fi
 
 cd /var/lib/jenkins/workspace/OnosProdCHOpost
 
@@ -18,4 +28,5 @@
 rm -rf $i
 done
 
-{afterClean}
+echo -e "\n After clean up disk usage:\n"
+df -h
\ No newline at end of file
diff --git a/jjb/OnosSystemTest/onos-test-freestyle.yaml b/jjb/OnosSystemTest/onos-test-freestyle.yaml
index 773be89..bebdfbe 100644
--- a/jjb/OnosSystemTest/onos-test-freestyle.yaml
+++ b/jjb/OnosSystemTest/onos-test-freestyle.yaml
@@ -39,42 +39,6 @@
                           echo "WikiPrefix=$WikiPrefix" >> /var/jenkins/TestONOS.property
          override-build-parameters: true
 
-- builder:
-    name: clean-up-bash
-    beforeClean: |
-                  echo -e "\n Before clean up disk usage: \n"
-                  df -h
-    cleaning: |
-               cleaning{
-               if [ $? -eq 0 ]
-               then
-                   echo "Checking if there are logs older than ${{DAYS_OLD}} days...."
-                   for i in $(find . -mtime +${{DAYS_OLD}} -type d)
-                   do
-                   echo -e "DIRs older than $DAYS_OLD are: "
-                   echo $i
-                   rm -rf $i
-                   done
-               fi
-    afterClean: |
-                 echo -e "\n After clean up disk usage:\n"
-                 df -h
-    builders:
-      - shell: |
-                #!/bin/bash
-
-                source ./clean-up.sh
-
-                {beforeClean}
-
-                cd /home/{user}/OnosSystemTest/TestON/logs
-
-                {cleaning}
-
-                {additional}
-
-                {afterClean}
-
 # post_Job
 - job-template:
     name: postjob-{station-type}
@@ -98,15 +62,14 @@
 
     publishers:
 
-#      - image-gallery:
-#         - gallery-type: archived-images-gallery
-#           title: 'Test result'
-#           includes: '*.jpg'
+      - image-gallery:
+         - gallery-type: archived-images-gallery
+           title: 'Test result'
+           includes: '*.jpg'
 
       - archive:
          artifacts: '*.jpg'
 
-# cleanup_stations - TDOO: check if getting the directory works.
 - job-template:
     name: test-station-log-cleanup-VM
 
@@ -133,12 +96,9 @@
 
 #    triggers:
 #      - timed: '01 08 1,15 * *'
-
     builders:
 
-      - clean-up-bash:
-        user: 'sdn'
-        additional: ''
+      - shell: !include-raw-escape: vm-bm-clean-up.sh
 
 - job-template:
     name: test-station-log-cleanup-BM
@@ -169,9 +129,7 @@
 
     builders:
 
-      - clean-up-bash:
-        user: 'sdn'
-        additional: ''
+      - shell: !include-raw-escape: vm-bm-clean-up.sh
 
 - job-template:
     name: test-station-log-cleanup-CHO
@@ -199,23 +157,10 @@
 
 #    triggers:
 #      - timed: '@daily'
-
     builders:
 
-      - clean-up-bash:
-        user: 'admin'
-        additional: |
-                     cd /var/lib/jenkins/workspace/OnosProdCHOpost
+      - shell: !include-raw-escape: cho-clean-up.sh
 
-                     echo "Checking if there are jenkins-logs older than ${{DAYS_OLD}} days...."
-                     for i in $(find . -mtime +${{DAYS_OLD}})
-                     do
-                     echo -e "logs older than $DAYS_OLD are: "
-                     echo $i
-                     rm -rf $i
-                     done
-
-# haven't done this yet.
 - job-template:
     name: QA-check-style
 
@@ -260,6 +205,8 @@
                - branch-compare-type: ANT
                  branch-pattern:
                    -'**/master'
+               - branch-compare-type: ANT
+                 branch-pattern:
                    -'**/onos-1.[11-20]'
     wrappers:
       - lf-infra-wrappers:
@@ -270,11 +217,11 @@
 
       - shell: !include-raw-escape: check-style.sh
 
-#    publishers:
-#      - warnings:
-#         workspace-file-scanners:
-#           - file-pattern: pep8Result.txt
-#              scanner: Pep8
+    publishers:
+      - warnings:
+         workspace-file-scanners:
+           - file-pattern: pep8Result.txt
+             scanner: Pep8
 
 - job-template:
     name: delta-nightly
@@ -328,7 +275,17 @@
 
       - shell: !include-raw-escape: delta-script.sh
 
-    # Todo : add graph and confluence ( use pipeline for post build ..? )
+    publishers:
+      - plot:
+         - title: 'DELTA Test Results for master'
+           group: 'DELTA-nightly'
+           yaxis: 'Number of test cases'
+           style: line
+           series:
+             - file: 'DELTA-nightly.csv'
+               format: 'csv'
+
+    # Todo : add confluence ( use pipeline for post build ..? )
 
 - job-template:
     name: init-CHO
@@ -438,7 +395,35 @@
     builders:
 
       - shell: !include-raw-escape: cho-post.sh
-# plot data needed.
+    publishers:
+      - plot:
+         - title: 'Network, Application and ONOS Events (per hour)'
+           group: 'CHOTestMonkey'
+           num-builds: '72'
+           yaxis: 'Number of Events'
+           style: line
+           logarithmic-yaxis: true
+           series:
+             - file: 'event.csv'
+               format: 'csv'
+         - title: 'Failed Checks (per hour)'
+           group: 'CHOTestMonkey'
+           num-builds: '72'
+           yaxis: 'Number of Failed Checks'
+           style: line
+           logarithmic-yaxis: true
+           series:
+             - file: 'failure.csv'
+               format: 'csv'
+         - title: 'Warnings, Errors and Exceptions from Logs (per hour)'
+           group: 'CHOTestMonkey'
+           num-builds: '72'
+           yaxis: 'Number of Warnings or Errors'
+           style: line
+           logarithmic-yaxis: true
+           series:
+             - file: 'error.csv'
+               format: 'csv'
 
 - job-template:
     name: 'SR-log-{version}'
@@ -461,8 +446,69 @@
     publishers:
 
       - archive:
-         artifacts: '*.jpg'
-#TODO LIST : DELTA -> perhaps change into pipeline?? , CHO_jobs, Check_style, Personal stations : necessary?
+         artifacts: '*'
+
+- job-template:
+    name: test-HA
+
+    <<: *test-free-job-boiler-plate
+    properties:
+
+      - build-discarder:
+
+         days-to-keep: 5
+         num-to-keep: 100
+
+    parameters:
+
+      - string:
+         name: 'TEST_NAME'
+         default: 'HAbackupRecover'
+         description: 'The name of the TestON test suite'
+
+      - lf-infra-parameters:
+         project: '{project}'
+         branch: '{stream}'
+         stream: '{stream}'
+         lftools-version: '{lftools-version}'
+
+    node: 'TestStation-Jons'
+    triggers:
+      - reverse:
+         jobs: 'test-HA'
+         result: 'failure'
+
+    builders:
+
+      - shell: !include-raw-escape: test-ha.sh
+
+    publishers:
+      - plot:
+         - title: 'Test job results'
+           group: 'Test-HA'
+           yaxis: 'Number of test cases'
+           style: line
+           series:
+             - file: 'results.csv'
+               format: 'csv'
+
+         - title: 'Timers'
+           group: 'Test-HA'
+           yaxis: 'Time in seconds'
+           style: line
+           series:
+             - file: 'Timers.csv'
+               format: 'csv'
+
+      - post-tasks:
+         - escalate-status: true
+           script: |
+              if [ -e ${{WORKSPACE}}/${{TEST_NAME##*/}}Wiki.txt ] && ! grep -q "FAIL" ${{WORKSPACE}}/${{TEST_NAME##*/}}Wiki.txt
+              then
+                  exit 0
+              else
+                  exit 1
+              fi
 
 - project:
     name: post-result-jobs
@@ -522,3 +568,13 @@
 
     jobs:
       - 'SR-log-{version}'
+
+- project:
+    name: personnel-station
+
+    project-name: 'log-pipeline'
+
+    <<: *test-free-init-procedure-plate
+
+    jobs:
+      - 'test-HA'
diff --git a/jjb/OnosSystemTest/test-ha.sh b/jjb/OnosSystemTest/test-ha.sh
new file mode 100644
index 0000000..b17b41e
--- /dev/null
+++ b/jjb/OnosSystemTest/test-ha.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -i
+#set -u # Exit on unset variables
+shopt -s expand_aliases # expand alias in non-interactive mode
+source ~/.bash_profile
+export PYTHONUNBUFFERED=1
+
+
+
+echo "${USER} is the current user."
+echo "Test date: "
+date
+
+cd ~
+source ~/onos/tools/dev/bash_profile
+cell borrow 190 7+0 jhall hotel
+export OCN=localhost
+cell
+
+#o
+# TODO make this a build option
+#git pull --ff-only
+
+rm -rf ~/TestON/logs/HA*
+stc teardown
+
+cd ~/OnosSystemTest/TestON/bin
+./copy-key-to-cells.sh
+./cleanup.sh -f
+sudo pkill python
+./cli.py run ${TEST_NAME}
+taillog
+
+echo ${JOB_NAME##*/}
+echo ${WORKSPACE}/
+
+# remove any leftover files from previous tests
+sudo rm ${WORKSPACE}/*Wiki.txt
+sudo rm ${WORKSPACE}/*Summary.txt
+sudo rm ${WORKSPACE}/*.csv
+
+#copy files to workspace
+cd `ls -t ~/OnosSystemTest/TestON/logs/*/ | head -1 | sed 's/://'`
+sudo cp *.txt ${WORKSPACE}/
+sudo cp *.csv ${WORKSPACE}/
+ls -al ${WORKSPACE}
+cd ${WORKSPACE}
+mv ${TEST_NAME}.csv results.csv
+ls -al ${WORKSPACE}
+cd
+
+cd ~/OnosSystemTest/TestON/logs
+echo "Job Name is: ${JOB_NAME}"
+TestONlogDir=$(ls -t | grep ${TEST_NAME}_  |head -1)
+echo "########################################################################################"
+echo "/n#####  copying ONOS logs from all nodes to TestON/logs directory: ${TestONlogDir}#####"
+echo "########################################################################################"
+cd $TestONlogDir
+if [ $? -eq 1 ]
+then
+    echo "Job name does not match any test suite name to move log!"
+else
+    pwd
+    for i in $OC{1..7}; do onos-fetch-logs $i; done
+fi
\ No newline at end of file
diff --git a/jjb/OnosSystemTest/vm-bm-clean-up.sh b/jjb/OnosSystemTest/vm-bm-clean-up.sh
index d5567c0..5f0fd87 100644
--- a/jjb/OnosSystemTest/vm-bm-clean-up.sh
+++ b/jjb/OnosSystemTest/vm-bm-clean-up.sh
@@ -2,10 +2,20 @@
 
 source ./clean-up.sh
 
-{beforeClean}
+echo -e "\n Before clean up disk usage: \n"
+df -h
+cd /home/{user}/OnosSystemTest/TestON/logs
 
-cd /home/sdn/OnosSystemTest/TestON/logs
+if [ $? -eq 0 ]
+then
+   echo "Checking if there are logs older than ${{DAYS_OLD}} days...."
+   for i in $(find . -mtime +${{DAYS_OLD}} -type d)
+   do
+   echo -e "DIRs older than $DAYS_OLD are: "
+   echo $i
+   rm -rf $i
+   done
+fi
 
-{cleaning}
-
-{afterClean}
+echo -e "\n After clean up disk usage:\n"
+df -h
\ No newline at end of file