[VOL-2127] new files required for testing BAL3.1 and techprofiles on pod1

Change-Id: I68fe1d534ef0bd62a1de31ffd1d6d2bd850a03b1
diff --git a/Jenkinsfile-voltha-bal31-build b/Jenkinsfile-voltha-bal31-build
new file mode 100644
index 0000000..a2d8323
--- /dev/null
+++ b/Jenkinsfile-voltha-bal31-build
@@ -0,0 +1,170 @@
+// Copyright 2017-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.
+
+node ("${TestNodeName}") {
+    timeout (100) {
+        try {
+            stage ("Parse deployment configuration file") {
+                sh returnStdout: true, script: "rm -rf helm-repo-tools ${configBaseDir} voltha-system-tests kind-voltha"
+                sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/helm-repo-tools"
+                sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
+                sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/voltha-system-tests"
+                sh returnStdout: true, script: "git clone https://github.com/ciena/kind-voltha.git"
+                deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
+            }
+            stage('Clean up') {
+                timeout(10) {
+                    sh returnStdout: true, script: """
+                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
+                    for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
+                    do
+                        echo "Purging chart: \${hchart}"
+                        helm delete --purge "\${hchart}"
+                    done
+                    """
+                    timeout(5) {
+                        waitUntil {
+                            helm_deleted = sh returnStdout: true, script: """
+                            export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
+                            helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
+                            """
+                            return helm_deleted.toInteger() == 0
+                        }
+                    }
+                    timeout(5) {
+                        waitUntil {
+                            kubectl_deleted = sh returnStdout: true, script: """
+                            export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
+                            kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
+                            """
+                            return kubectl_deleted.toInteger() == 0
+                        }
+                    }
+                }
+            }
+            stage('Install Voltha') {
+                timeout(10) {
+                    sh returnStdout: true, script: """
+                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
+                    cd kind-voltha/
+                    EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml' VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_RADIUS=y WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no FANCY=0 ONOS_TAG=voltha-2.1 ./voltha up
+                    """
+                }
+            }
+            if ( params.configurePod )
+                stage('Push Tech-Profile') {
+                    timeout(1) {
+                        out_push_tp = sh returnStatus: true, script: """
+                        export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
+                        etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
+                        kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/tp.json
+                        put_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/tp.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/XGS-PON/64')
+                        """
+                        return out_push_tp == 0
+                    }
+                    timeout(1) {
+                        out_get_tp = sh returnStatus: true, script: """
+                        etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
+                        get_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/XGS-PON/64')
+                        """
+                        return out_get_tp == 0
+                    }
+                }
+                stage('Push Sadis-config') {
+                    timeout(1) {
+                        sadis_out = sh returnStatus: true, script: """
+                        curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis.json
+                        """
+                        return sadis_out == 0
+                    }
+                }
+
+            if ( params.reinstallOlt ) {
+                stage('Reinstall OLT software') {
+                    for(int i=0; i < deployment_config.olts.size(); i++) {
+                        sh returnStdout: true, script: """
+                        sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${oltDebVersion}"
+                        sleep 10
+                        """
+                        timeout(5) {
+                            waitUntil {
+                                olt_sw_present = sh returnStdout: true, script: """
+                                sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
+                                sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
+                                """
+                                return olt_sw_present.toInteger() == 1
+                            }
+                        }
+                    }
+                }
+               stage('Restart OLT processes') {
+                    for(int i=0; i < deployment_config.olts.size(); i++) {
+                        timeout(5) {
+                            sh returnStdout: true, script: """
+                            ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
+                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true
+                            sleep 120
+                            """
+                        }
+                        timeout(15) {
+                            waitUntil {
+                                devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
+                                return devprocess.toInteger() > 0
+                            }
+                        }
+                        timeout(15) {
+                            waitUntil {
+                                openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep openolt | wc -l'"
+                                return openoltprocess.toInteger() > 0
+                            }
+                        }
+                    }
+                }
+            }
+            if ( deployment_config.fabric_switches.size() > 0 ) {
+                stage('Switch Configurations in ONOS') {
+                    timeout(1) {
+                        netcfg_out = sh returnStatus: true, script: """
+                        curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json
+                        curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
+                        """
+                        return netcfg_out == 0
+                    }
+                    timeout(1) {
+                        waitUntil {
+                            sr_active_out = sh returnStatus: true, script: """
+                            curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
+                            """
+                            return sr_active_out == 0
+                        }
+                    }
+                    timeout(1) {
+                        // FIXME support multiple OLTs
+                        for(int i=0; i < deployment_config.hosts.src.size(); i++) {
+                            xconnect_out = sh returnStatus: true, script: """
+                            curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "ports": [${deployment_config.fabric_switches[0].bngPort},${deployment_config.fabric_switches[0].oltPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
+                            """
+                        }
+                    }
+                }
+            }
+            currentBuild.result = 'SUCCESS'
+        } catch (err) {
+            currentBuild.result = 'FAILURE'
+            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
+            throw err
+        }
+        echo "RESULT: ${currentBuild.result}"
+    }
+}
diff --git a/tests/data/TechProfile-1T4GEM-bal31.json b/tests/data/TechProfile-1T4GEM-bal31.json
new file mode 100644
index 0000000..1a6d3fc
--- /dev/null
+++ b/tests/data/TechProfile-1T4GEM-bal31.json
@@ -0,0 +1,141 @@
+{ 
+   "name":"4QueueHybridProfileMap1",
+   "profile_type":"XPON",
+   "version":1,
+   "num_gem_ports":4,
+   "instance_control":{ 
+      "onu":"multi-instance",
+      "uni":"single-instance",
+      "max_gem_payload_size":"auto"
+   },
+   "us_scheduler":{ 
+      "additional_bw":"AdditionalBW_BestEffort",
+      "direction":"UPSTREAM",
+      "priority":0,
+      "weight":0,
+      "q_sched_policy":"hybrid"
+   },
+   "ds_scheduler":{ 
+      "additional_bw":"AdditionalBW_BestEffort",
+      "direction":"DOWNSTREAM",
+      "priority":0,
+      "weight":0,
+      "q_sched_policy":"hybrid"
+   },
+   "upstream_gem_port_attribute_list":[ 
+      { 
+         "pbit_map":"0b00000101",
+         "aes_encryption":"True",
+         "scheduling_policy":"WRR",
+         "priority_q":4,
+         "weight":25,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "max_threshold":0,
+            "min_threshold":0,
+            "max_probability":0
+         }
+      },
+      { 
+         "pbit_map":"0b00011010",
+         "aes_encryption":"True",
+         "scheduling_policy":"WRR",
+         "priority_q":3,
+         "weight":75,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      },
+      { 
+         "pbit_map":"0b00100000",
+         "aes_encryption":"True",
+         "scheduling_policy":"StrictPriority",
+         "priority_q":2,
+         "weight":0,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      },
+      { 
+         "pbit_map":"0b11000000",
+         "aes_encryption":"True",
+         "scheduling_policy":"StrictPriority",
+         "priority_q":1,
+         "weight":25,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      }
+   ],
+   "downstream_gem_port_attribute_list":[ 
+      { 
+         "pbit_map":"0b00000101",
+         "aes_encryption":"True",
+         "scheduling_policy":"WRR",
+         "priority_q":4,
+         "weight":10,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      },
+      { 
+         "pbit_map":"0b00011010",
+         "aes_encryption":"True",
+         "scheduling_policy":"WRR",
+         "priority_q":3,
+         "weight":90,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      },
+      { 
+         "pbit_map":"0b00100000",
+         "aes_encryption":"True",
+         "scheduling_policy":"StrictPriority",
+         "priority_q":2,
+         "weight":0,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      },
+      { 
+         "pbit_map":"0b11000000",
+         "aes_encryption":"True",
+         "scheduling_policy":"StrictPriority",
+         "priority_q":1,
+         "weight":25,
+         "discard_policy":"TailDrop",
+         "max_q_size":"auto",
+         "discard_config":{ 
+            "min_threshold":0,
+            "max_threshold":0,
+            "max_probability":0
+         }
+      }
+   ]
+}
diff --git a/tests/data/onlab-pod1-sadis.json b/tests/data/onlab-pod1-sadis.json
new file mode 100644
index 0000000..64d9f90
--- /dev/null
+++ b/tests/data/onlab-pod1-sadis.json
@@ -0,0 +1,114 @@
+{
+  "devices": {
+    "of:000000000a5a0072": {
+      "basic": {
+        "driver": "voltha"
+      }
+    }
+  },
+  "apps": {
+    "org.opencord.sadis": {
+      "sadis": {
+        "integration": {
+          "cache": {
+            "enabled": false,
+            "maxsize": 50,
+            "ttl": "PT0m"
+          }
+        },
+        "entries": [
+          {
+            "id": "ALPHe3d1cfde-1",
+            "cTag": 112,
+            "sTag": 111,
+            "nasPortId": "",
+            "circuitId": "",
+            "remoteId": "",
+            "technologyProfileId": 64,
+            "upstreamBandwidthProfile": "Default",
+            "downstreamBandwidthProfile": "Default"
+          },
+          {
+            "id": "ALPHe3d1cfde-2",
+            "cTag": 902,
+            "sTag": 111,
+            "nasPortId": "",
+            "circuitId": "",
+            "remoteId": "",
+            "technologyProfileId": 64,
+            "upstreamBandwidthProfile": "Default",
+            "downstreamBandwidthProfile": "Default"
+          },
+          {
+            "id": "ALPHe3d1cfde-3",
+            "cTag": 903,
+            "sTag": 111,
+            "nasPortId": "",
+            "circuitId": "",
+            "remoteId": "",
+            "technologyProfileId": 64,
+            "upstreamBandwidthProfile": "Default",
+            "downstreamBandwidthProfile": "Default"
+          },
+          {
+            "id": "ALPHe3d1cfde-4",
+            "cTag": 904,
+            "sTag": 111,
+            "nasPortId": "",
+            "circuitId": "",
+            "remoteId": "",
+            "technologyProfileId": 64,
+            "upstreamBandwidthProfile": "Default",
+            "downstreamBandwidthProfile": "Default"
+          },
+          {
+            "id": "ALPHe3d1cfde-5",
+            "cTag": 905,
+            "sTag": 111,
+            "nasPortId": "",
+            "circuitId": "",
+            "remoteId": "",
+            "technologyProfileId": 64,
+            "upstreamBandwidthProfile": "Default",
+            "downstreamBandwidthProfile": "Default"
+          },
+          {
+            "id": "EC1838000853",
+            "hardwareIdentifier": "aa:bb:cc:dd:ee:ff",
+            "ipAddress": "10.192.20.206",
+            "nasId": "EC1838000853",
+            "uplinkPort": 65536
+          }
+        ]
+      },
+      "bandwidthprofile":{
+          "integration":{
+              "cache":{
+                  "enabled":true,
+                  "maxsize":40,
+                  "ttl":"PT1m"
+              }
+          },
+          "entries":[
+              {
+                  "id": "Default",
+                  "air": 100000,
+                  "cbs": 30,
+                  "cir": 600,
+                  "ebs": 30,
+                  "eir": 400
+              },
+              {
+                  "id": "User_Bandwidth1",
+                  "air": 100000,
+                  "cbs": 10000,
+                  "cir": 5000,
+                  "ebs": 1000,
+                  "eir": 5000
+              }
+
+          ]
+      }
+    }
+  }
+}