Jenkins Pipeline Script for ONU Activation Testing: environment variable fix

Change-Id: If79245ecf4e09eac2c0033efc38859bff13638e0
diff --git a/jjb/pipeline/voltha-scale-measurements.groovy b/jjb/pipeline/voltha-scale-measurements.groovy
index 9059ad9..0239627 100644
--- a/jjb/pipeline/voltha-scale-measurements.groovy
+++ b/jjb/pipeline/voltha-scale-measurements.groovy
@@ -1,10 +1,24 @@
 /* voltha-scale-measurements pipeline */
 pipeline {
-
   /* no label, executor is determined by JJB */
   agent {
     label "${params.buildNode}"
   }
+  environment {
+    KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
+    VOLTCONFIG="$HOME/.volt/config-minimal"
+    PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+    TYPE="minimal"
+    FANCY=0
+    WITH_SIM_ADAPTERS="n"
+    WITH_RADIUS="y"
+    WITH_BBSIM="y"
+    DEPLOY_K8S="y"
+    VOLTHA_LOG_LEVEL="DEBUG"
+    CONFIG_SADIS="n"
+    ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs -v teardown_device:False"
+  }
+
   stages {
     stage('checkout') {
       steps {
@@ -14,29 +28,70 @@
           branches: [[ name: "master", ]],
           extensions: [
             [$class: 'WipeWorkspace'],
-            [$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.projectName}"],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
             [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
           ],
         ])
         script {
-          git_tags = sh(script:"cd $projectName; git tag -l --points-at HEAD", returnStdout: true).trim()
+          git_tags = sh(script:"cd kind-voltha; git tag -l --points-at HEAD", returnStdout: true).trim()
         }
       }
     }
     stage('start') {
       steps {
-        sh """
+        sh '''
           #!/usr/bin/env bash
           set -euo pipefail
+          '''
+      }
+    }
 
-          echo "DO SOMETHING"
-          """
+    stage('deploy-voltha') {
+      steps {
+        sh '''
+          cd kind-voltha
+
+          EXTRA_HELM_FLAGS="--set onu=${onuCount},pon=${ponCount}" ./voltha up
+
+          '''
+      }
+    }
+    stage('activate-ONUs') {
+      steps {
+        sh '''
+          export SSHPASS=karaf
+          if [ -z "$onuTarget" ]
+          then
+            echo -e "You need to set the target ONU number\n"
+            exit 1
+          fi
+
+          voltctl device create -t openolt -H bbsim:50060
+          voltctl device enable $(voltctl device list --filter Type~openolt -q)
+          SECONDS=0
+
+          # check ONUs reached Active State in VOLTHA
+          i=$(voltctl device list | grep -v OLT | grep ACTIVE | wc -l)
+          until [ $i -eq $onuTarget ]
+          do
+            echo "$i ONUs ACTIVE of $onuTarget expected (time: $SECONDS)"
+            sleep 20
+            i=$(voltctl device list | grep -v OLT | grep ACTIVE | wc -l)
+          done
+          echo "$onuTarget ONUs Activated in $SECONDS seconds (time: $SECONDS)"
+          exit 0
+
+        '''
       }
     }
   }
   post {
     cleanup {
       sh '''
+        #!/usr/bin/env bash
+        set -euo pipefail
+        cd $WORKSPACE/kind-voltha
+
         WAIT_ON_DOWN=y ./voltha down
         cd $WORKSPACE/
         rm -rf kind-voltha/ || true