Merge "Pipeline for LWC is running"
diff --git a/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy b/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy
index 3f66376..43e8e23 100644
--- a/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy
+++ b/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy
@@ -20,6 +20,12 @@
       remote: 'https://gerrit.opencord.org/ci-management.git'
 ])
 
+def lwc_helm_chart_path="/home/jenkins/Radisys_LWC_helm_charts"
+def value_file="/home/jenkins/lwc-values.yaml"
+def pon_count=16
+def onu_count=32
+def workflow="dt"
+
 pipeline {
 
   /* no label, executor is determined by JJB */
@@ -59,6 +65,7 @@
               // if we don't ONOS might get stuck because of all the events when BBSim goes down
               sh returnStdout: false, script: '''
               set +x
+              helm del -n infra voltha-infra || true
               helm del voltha-infra || true
               echo -ne "\nWaiting for ONOS to be removed..."
               onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l)
@@ -98,9 +105,18 @@
         }
       }
     }
+    stage('Download Code') {
+      steps {
+        getVolthaCode([
+          branch: "${release}",
+          volthaSystemTestsChange: "${volthaSystemTestsChange}",
+          volthaHelmChartsChange: "${volthaHelmChartsChange}",
+        ])
+      }
+    }
     stage('Deploy Voltha') {
       steps {
-        timeout(time: 10, unit: 'MINUTES') {
+        timeout(time: 5, unit: 'MINUTES') {
           installVoltctl("${release}")
           script {
             startComponentsLogs([
@@ -116,7 +132,95 @@
             ])
           }
         }
+        timeout(time: 10, unit: 'MINUTES') {
+          sh """
+          cd /home/jenkins/Radisys_LWC_helm_charts
+
+          helm dep update ${lwc_helm_chart_path}/voltha-infra
+          helm upgrade --install --create-namespace -n infra voltha-infra ${lwc_helm_chart_path}/voltha-infra -f examples/${workflow}-values.yaml \
+            -f ${value_file} --wait
+
+          # helm dep update ${lwc_helm_chart_path}/voltha-stack
+          helm upgrade --install --create-namespace -n voltha1 voltha1 onf/voltha-stack \
+          --set voltha.ingress.enabled=true --set voltha.ingress.enableVirtualHosts=true --set voltha.fullHostnameOverride=voltha.scale1.dev \
+          -f ${value_file} --wait
+
+          helm upgrade --install -n voltha1 bbsim0 onf/bbsim --set olt_id=10 -f examples/${workflow}-values.yaml --set pon=${pon_count},onu=${onu_count} --version 4.6.0 --set oltRebootDelay=5 --wait
+          """
+        }
       }
     }
+    stage('Load MIB Template') {
+      when {
+        expression {
+          return params.withMibTemplate
+        }
+      }
+      steps {
+        sh """
+        # load MIB template
+        wget ${mibTemplateUrl} -O mibTemplate.json
+        cat mibTemplate.json | kubectl exec -it -n infra \$(kubectl get pods -n infra |grep etcd-0 | awk 'NR==1{print \$1}') -- etcdctl put service/voltha/omci_mibs/go_templates/BBSM/12345123451234512345/BBSM_IMG_00001
+        """
+      }
+    }
+    stage('Run Test') {
+      steps {
+        sh """
+          mkdir -p $WORKSPACE/RobotLogs
+          cd $WORKSPACE/voltha-system-tests
+          make vst_venv
+
+          daemonize -E JENKINS_NODE_COOKIE="dontKillMe" /usr/local/bin/kubectl port-forward -n infra svc/lwc 8182:8181 --address 0.0.0.0
+
+          source ./vst_venv/bin/activate
+          robot -d $WORKSPACE/RobotLogs \
+          --exitonfailure \
+          -v pon:${pon_count} -v onu:${onu_count} \
+          tests/scale/Voltha_Scale_Tests_lwc.robot
+
+          python tests/scale/collect-result.py -r $WORKSPACE/RobotLogs/output.xml -p $WORKSPACE/plots > $WORKSPACE/execution-time.txt || true
+          cat $WORKSPACE/execution-time.txt
+        """
+      }
+    }
+  }
+  post {
+    always {
+      stopComponentsLogs()
+      script {
+        try {
+          step([$class: 'RobotPublisher',
+            disableArchiveOutput: false,
+            logFileName: '**/log*.html',
+            otherFiles: '',
+            outputFileName: '**/output*.xml',
+            outputPath: 'RobotLogs',
+            passThreshold: 100,
+            reportFileName: '**/report*.html',
+            onlyCritical: true,
+            unstableThreshold: 0]);
+        } catch (Exception e) {
+            println "Cannot archive Robot Logs: ${e.toString()}"
+        }
+      }
+      plot([
+        csvFileName: 'scale-test.csv',
+        csvSeries: [
+          [file: 'plots/plot-lwc-olts.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-voltha-onus.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-lwc-ports.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-voltha-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-voltha-openolt-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-lwc-flows-before.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-voltha-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-voltha-openolt-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+          [file: 'plots/plot-lwc-flows-after.txt', displayTableFlag: false, exclusionValues: '', inclusionFlag: 'OFF', url: ''],
+        ],
+        group: 'Voltha-Scale-Numbers', numBuilds: '20', style: 'line', title: "Scale Test (OLTs: ${olts}, PONs: ${pons}, ONUs: ${onus}, UNIs: ${unis})", yaxis: 'Time (s)', useDescr: true
+      ])
+      getPodsInfo("$LOG_FOLDER")
+      archiveArtifacts artifacts: 'execution-time.txt,logs/*,logs/pprof/*,RobotLogs/**/*,plots/*,etcd-metrics/*'
+    }
   }
 }
diff --git a/jjb/pipeline/voltha/master/voltha-scale-test.groovy b/jjb/pipeline/voltha/master/voltha-scale-test.groovy
index 2ac6094..43b5248 100644
--- a/jjb/pipeline/voltha/master/voltha-scale-test.groovy
+++ b/jjb/pipeline/voltha/master/voltha-scale-test.groovy
@@ -87,7 +87,7 @@
           }
           timeout(time: 10, unit: 'MINUTES') {
             script {
-              helmTeardown(["default"])
+              helmTeardown(["default", "voltha1", "infra"])
             }
             sh returnStdout: false, script: '''
               helm repo add onf https://charts.opencord.org
diff --git a/jjb/voltha-scale.yaml b/jjb/voltha-scale.yaml
index eb40623..968f4e3 100644
--- a/jjb/voltha-scale.yaml
+++ b/jjb/voltha-scale.yaml
@@ -521,6 +521,7 @@
           withIgmp: false
           extraHelmFlags: '--set authRetry=false,dhcpRetry=false'
           workflow: dt
+          volthaSystemTestsChange: refs/changes/10/31810/6
 
 
 # list of parameters for the VOLTHA Jobs,