Merge "WIP creating structure for LWC scale pipeline"
diff --git a/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy b/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy
new file mode 100644
index 0000000..3f66376
--- /dev/null
+++ b/jjb/pipeline/voltha/master/voltha-scale-lwc-test.groovy
@@ -0,0 +1,122 @@
+// Copyright 2019-present Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// deploy VOLTHA and performs a scale test with the LWC controller
+
+library identifier: 'cord-jenkins-libraries@master',
+    retriever: modernSCM([
+      $class: 'GitSCMSource',
+      remote: 'https://gerrit.opencord.org/ci-management.git'
+])
+
+pipeline {
+
+  /* no label, executor is determined by JJB */
+  agent {
+    label "${params.buildNode}"
+  }
+  options {
+      timeout(time: 60, unit: 'MINUTES')
+  }
+  environment {
+    JENKINS_NODE_COOKIE="dontKillMe" // do not kill processes after the build is done
+    KUBECONFIG="$HOME/.kube/config"
+    VOLTCONFIG="$HOME/.volt/config"
+    SSHPASS="karaf"
+    VOLTHA_LOG_LEVEL="${logLevel}"
+    NUM_OF_BBSIM="${olts}"
+    NUM_OF_OPENONU="${openonuAdapterReplicas}"
+    NUM_OF_ONOS="${onosReplicas}"
+    NUM_OF_ATOMIX="${atomixReplicas}"
+    EXTRA_HELM_FLAGS=" "
+    LOG_FOLDER="$WORKSPACE/logs"
+    GERRIT_PROJECT="${GERRIT_PROJECT}"
+    PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
+  }
+
+  stages {
+    stage ('Cleanup') {
+      steps {
+        script {
+          try {
+            timeout(time: 5, unit: 'MINUTES') {
+              sh returnStdout: false, script: '''
+              cd $WORKSPACE
+              rm -rf $WORKSPACE/*
+              '''
+              // removing the voltha-infra chart first
+              // 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 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)
+              while [[ $onos != 0 ]]; do
+                onos=$(kubectl get pod -n default -l app=onos-classic --no-headers | wc -l)
+                sleep 5
+                echo -ne "."
+              done
+              '''
+            }
+          } catch(org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
+            // if we have a timeout in the Cleanup fase most likely ONOS got stuck somewhere, thuse force remove the pods
+            sh '''
+              kubectl get pods | grep Terminating | awk '{print $1}' | xargs kubectl delete pod --force --grace-period=0
+            '''
+          }
+          timeout(time: 10, unit: 'MINUTES') {
+            script {
+              helmTeardown(["default", "voltha1", "voltha-infra"])
+            }
+            sh returnStdout: false, script: '''
+              helm repo add onf https://charts.opencord.org
+              helm repo update
+
+              # remove all persistent volume claims
+              kubectl delete pvc --all-namespaces --all
+              PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l)
+              while [[ \$PVCS != 0 ]]; do
+                sleep 5
+                PVCS=\$(kubectl get pvc --all-namespaces --no-headers | wc -l)
+              done
+
+              # remove orphaned port-forward from different namespaces
+              ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 || true
+            '''
+          }
+        }
+      }
+    }
+    stage('Deploy Voltha') {
+      steps {
+        timeout(time: 10, unit: 'MINUTES') {
+          installVoltctl("${release}")
+          script {
+            startComponentsLogs([
+              appsToLog: [
+                'app.kubernetes.io/name=etcd',
+                'app.kubernetes.io/name=kafka',
+                'app=lwc',
+                'app=adapter-open-onu',
+                'app=adapter-open-olt',
+                'app=rw-core',
+                'app=bbsim',
+              ]
+            ])
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/jjb/voltha-scale.yaml b/jjb/voltha-scale.yaml
index 32f090a..eb40623 100644
--- a/jjb/voltha-scale.yaml
+++ b/jjb/voltha-scale.yaml
@@ -502,6 +502,26 @@
           name: 'voltha-scale-measurements-master-dev'
           build-node: 'voltha-scale'
 
+      # LWC pipeline
+      - 'voltha-scale-measurements':
+          name: 'voltha-scale-measurements-lwc'
+          pipeline-script: 'voltha/master/voltha-scale-lwc-test.groovy'
+          build-node: 'voltha-scale-1'
+          'disable-job': false
+          # trigger on Feb 29th (a.k.a only trigger it manually)
+          time-trigger: "H 0 29 2 *"
+          withMonitoring: true
+          olts: 1
+          pons: 16
+          onus: 32
+          withFlows: true
+          provisionSubscribers: true
+          withEapol: false
+          withDhcp: false
+          withIgmp: false
+          extraHelmFlags: '--set authRetry=false,dhcpRetry=false'
+          workflow: dt
+
 
 # list of parameters for the VOLTHA Jobs,
 # used as anchor so that can be shared across multiple jobs