Merge "VOL-2568 Sanity test on pyvoltha"
diff --git a/jjb/pipeline/voltha-scale-measurements.groovy b/jjb/pipeline/voltha-scale-measurements.groovy
index 025eb75..d7aad03 100644
--- a/jjb/pipeline/voltha-scale-measurements.groovy
+++ b/jjb/pipeline/voltha-scale-measurements.groovy
@@ -17,6 +17,7 @@
     VOLTHA_LOG_LEVEL="DEBUG"
     CONFIG_SADIS="n"
     ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs -v teardown_device:False"
+    SSHPASS="karaf"
   }
 
   stages {
@@ -45,7 +46,6 @@
           '''
       }
     }
-
     stage('deploy-voltha') {
       steps {
         sh '''
@@ -56,10 +56,32 @@
           '''
       }
     }
+    stage('MIB-template') {
+      steps {
+        sh '''
+          if [ "$withMibTemplate" = true ] ; then
+            git clone https://github.com/opencord/voltha-openonu-adapter.git
+            cat voltha-openonu-adapter/templates/BBSM-12345123451234512345-00000000000001-v1.json | kubectl exec -it -n voltha $(kubectl get pods -n voltha | grep etcd-cluster | awk 'NR==1{print $1}') etcdctl put service/voltha/omci_mibs/templates/BBSM/12345123451234512345/00000000000001
+            rm -rf voltha-openonu-adapter
+          fi
+        '''
+      }
+    }
+    stage('disable-ONOS-apps') {
+      steps {
+         sh '''
+          #Check withOnosApps and disable apps accordingly
+          if [ "$withOnosApps" = false ] ; then
+            sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost app deactivate org.opencord.olt
+            sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost app deactivate org.opencord.aaa
+            sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost app deactivate org.opencord.dhcpl2relay
+          fi
+         '''
+      }
+    }
     stage('activate-ONUs') {
       steps {
         sh '''
-          export SSHPASS=karaf
           if [ -z "$onuTarget" ]
           then
             echo -e "You need to set the target ONU number\n"
@@ -79,11 +101,26 @@
             i=$(voltctl device list | grep -v OLT | grep ACTIVE | wc -l)
           done
           echo "$onuTarget ONUs Activated in $SECONDS seconds (time: $SECONDS)"
-          exit 0
+          #exit 0
 
         '''
       }
     }
+    stage('ONOS-ports') {
+      steps {
+        sh '''    
+          # Check ports showed up in ONOS
+          z=$(sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost ports -e | grep BBSM | wc -l)
+          until [ $z -eq "$onuTarget" ]
+          do
+            echo "${z} enabled ports of "$onuTarget" expected (time: $SECONDS)"
+            sleep $pollInterval
+            z=$(sshpass -e ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost ports -e | grep BBSM | wc -l)
+          done
+          echo "$onuTarget ports enabled in $SECONDS seconds (time: $SECONDS)"
+        '''
+      }
+    }
   }
   post {
     cleanup {
diff --git a/jjb/voltha-scale.yaml b/jjb/voltha-scale.yaml
index 99bb9c2..db8bc45 100644
--- a/jjb/voltha-scale.yaml
+++ b/jjb/voltha-scale.yaml
@@ -57,6 +57,17 @@
           name: pollInterval
           default: 20
           description: 'Sleep time between ONU activation checks'
+      
+      - bool:
+          name: withOnosApps
+          default: false
+          description: 'Option to deactivate certain ONOS apps'
+
+      - bool:
+          name: withMibTemplate
+          default: false
+          description: 'Option to trigger MIB template command'
+    
 
     project-type: pipeline
     concurrent: true