Merge "Disabling SR at scale"
diff --git a/jjb/pipeline/voltha-tt-physical-functional-tests.groovy b/jjb/pipeline/voltha-tt-physical-functional-tests.groovy
index 88ed9e1..cfc6d46 100644
--- a/jjb/pipeline/voltha-tt-physical-functional-tests.groovy
+++ b/jjb/pipeline/voltha-tt-physical-functional-tests.groovy
@@ -196,12 +196,14 @@
       steps {
         sh """
         mkdir -p $ROBOT_LOGS_DIR
-        if ( ${powerSwitch} ); then
-             export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
-        else
-             export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
+        if [ ${params.enableMultiUni} = false ]; then
+          if ( ${powerSwitch} ); then
+               export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
+          else
+               export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
+          fi
+          make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
         fi
-        make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
         """
       }
     }
@@ -217,12 +219,14 @@
         sh """
         mkdir -p $ROBOT_LOGS_DIR
         if [ "${params.branch}" == "master" ]; then
-           if ( ${powerSwitch} ); then
+          if [ ${params.enableMultiUni} = false ]; then
+            if ( ${powerSwitch} ); then
               export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE"
-           else
+            else
               export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE"
-           fi
-          make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
+            fi
+            make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
+          fi
         fi
         """
       }
diff --git a/jjb/pipeline/voltha/master/physical-build.groovy b/jjb/pipeline/voltha/master/physical-build.groovy
index 4db22f9..a8bed62 100644
--- a/jjb/pipeline/voltha/master/physical-build.groovy
+++ b/jjb/pipeline/voltha/master/physical-build.groovy
@@ -101,6 +101,9 @@
             }
             if (workFlow.toLowerCase() == "tt") {
               localHelmFlags += " --set radius.enabled=false --set global.incremental_evto_update=true "
+                if (enableMultiUni.toBoolean()) {
+                    localHelmFlags += " --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=${uniPortMask} "
+                }
             }
 
             // NOTE temporary workaround expose ONOS node ports (pod-config needs to be updated to contain these values)
@@ -155,14 +158,25 @@
                 export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                 etcd_container=\$(kubectl get pods -n ${infraNamespace} | grep etcd | awk 'NR==1{print \$1}')
                 if [[ "${workFlow}" == "TT" ]]; then
-                   kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
-                   kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64'
-                   kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
-                   kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65'
-                   kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
-                   kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_none.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66'
-                   kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
-                   kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_na.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/67'
+                   if [[ "${params.enableMultiUni}" == "true" ]]; then
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-HSIA.json \$etcd_container:/tmp/hsia.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64'
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-VoIP.json \$etcd_container:/tmp/voip.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65'
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_none.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66'
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-multi-uni-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_na.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/67'
+                   else
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64'
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65'
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-None.json \$etcd_container:/tmp/mcast_additionalBW_none.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_none.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66'
+                      kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST-AdditionalBW-NA.json \$etcd_container:/tmp/mcast_additionalBW_na.json
+                      kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast_additionalBW_na.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/67'
+                   fi
                 else
                    kubectl cp -n ${infraNamespace} $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
                    kubectl exec -n ${infraNamespace} -it \$etcd_container -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64'
@@ -241,7 +255,7 @@
                 return sr_active_out == 0
               }
             }
-            timeout(5) {
+            timeout(7) {
               for(int i=0; i < deployment_config.hosts.src.size(); i++) {
                 for(int j=0; j < deployment_config.olts.size(); j++) {
                   def aggPort = -1
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index d719a05..08a7a78 100755
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -68,6 +68,45 @@
               flags: ""
               teardown: false
 
+      - 'voltha-periodic-test':
+          name: 'periodic-voltha-multi-uni-test-bbsim'
+          code-branch: 'master'
+          extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=0x00FF'
+          time-trigger: "H H/23 * * *"
+          testTargets: |
+            - target: functional-single-kind-multiuni-att
+              workflow: att
+              flags: ""
+              teardown: true
+            - target: bbsim-multiuni-failurescenarios-att
+              workflow: att
+              flags: ""
+              teardown: false
+            - target: bbsim-multiuni-errorscenarios-att
+              workflow: att
+              flags: ""
+              teardown: false
+
+      - 'voltha-periodic-test':
+          name: 'periodic-voltha-multi-uni-multiple-olts-test-bbsim'
+          code-branch: 'master'
+          olts: 2
+          extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master --set onu=2,pon=2 --set voltha-adapter-openonu.adapter_open_onu.uni_port_mask=0x00FF'
+          time-trigger: "H H/23 * * *"
+          testTargets: |
+            - target: functional-multiuni-multiolt-att
+              workflow: att
+              flags: ""
+              teardown: true
+            - target: bbsim-multiuni-multiolt-failurescenarios-att
+              workflow: att
+              flags: ""
+              teardown: false
+            - target: bbsim-multiuni-multiolt-errorscenarios-att
+              workflow: att
+              flags: ""
+              teardown: false
+
       - 'voltha-periodic-test-kind-voltha-based':
           name: 'periodic-voltha-multiple-olts-test-bbsim-2.7'
           pipeline-script: 'voltha/voltha-2.7/voltha-nightly-tests-bbsim.groovy'
diff --git a/jjb/voltha-test/voltha-nightly-jobs.yaml b/jjb/voltha-test/voltha-nightly-jobs.yaml
index f819d1f..0a92aad 100644
--- a/jjb/voltha-test/voltha-nightly-jobs.yaml
+++ b/jjb/voltha-test/voltha-nightly-jobs.yaml
@@ -93,6 +93,16 @@
           default: '{num-of-onos}'
           description: 'Installs the specified Number of ONOS instances'
 
+      - bool:
+          name: enableMultiUni
+          default: '{enableMultiUni}'
+          description: "Enables the Multi UNI feature"
+
+      - string:
+          name: uniPortMask
+          default: '{uniPortMask}'
+          description: 'Open ONU adapter uni_port_mask, used when enableMultiUni is set to True, values: 0x0001-0x00FF'
+
       # installBBSim is not used in the master branch pipeline, remove after 2.8
       - bool:
           name: installBBSim
@@ -224,6 +234,8 @@
     volthaHelmChartsChange: ''
     profile: 'Default'
     logLevel: 'DEBUG'
+    enableMultiUni: false
+    uniPortMask: '0x0001'
     # installBBSim is not used in the master branch pipeline, remove after 2.8
     installBBSim: false
     bbsimReplicas: 0
@@ -265,6 +277,8 @@
     volthaHelmChartsChange: ''
     profile: 'Default'
     logLevel: 'DEBUG'
+    enableMultiUni: false
+    uniPortMask: '0x0001'
     # installBBSim is not used in the master branch pipeline, remove after 2.8
     installBBSim: false
     bbsimReplicas: 0
@@ -301,6 +315,8 @@
     branch: 'voltha-2.7'
     volthaHelmChartsChange: '' # this is not supported in the VOLTHA-2.7 build, but the parameters are shared, ideally we should split them
     logLevel: 'DEBUG'
+    enableMultiUni: false
+    uniPortMask: '0x0001'
     installBBSim: false
     # bbsimReplicas is not applicable for 2.7 Jobs
     bbsimReplicas: 0
@@ -345,6 +361,7 @@
     manifest-branch: 'master'
 
     oltAdapterAppLabel: 'adapter-open-olt'
+    enableMultiUni: false
 
     parameters:
       - string:
@@ -413,6 +430,11 @@
           description: 'Installs and uses the specified work flow on the POD'
 
       - bool:
+          name: enableMultiUni
+          default: '{enableMultiUni}'
+          description: "Enables the Multi UNI feature"
+
+      - bool:
           name: powerSwitch
           default: '{power-switch}'
           description: "Indicate whether POD has power switch to reboot ONUs/OLT remotely"
@@ -590,6 +612,7 @@
     manifest-branch: 'master'
 
     oltAdapterAppLabel: 'adapter-open-olt'
+    enableMultiUni: false
 
     parameters:
       - string:
@@ -662,6 +685,11 @@
           default: '{power-switch}'
           description: "Indicate whether POD has power switch to reboot ONUs/OLT remotely"
 
+      - bool:
+          name: enableMultiUni
+          default: '{enableMultiUni}'
+          description: "Enables the Multi UNI feature"
+
       - string:
           name: oltAdapterAppLabel
           default: '{oltAdapterAppLabel}'
diff --git a/jjb/voltha-test/voltha.yaml b/jjb/voltha-test/voltha.yaml
index 993b33a..8144d4b 100644
--- a/jjb/voltha-test/voltha.yaml
+++ b/jjb/voltha-test/voltha.yaml
@@ -76,7 +76,7 @@
           build-node: 'qa-testvm-pod'
           config-pod: 'flex-ocp-cord'
           profile: 'Default'
-          time: '4'
+          time: '5'
           VolthaEtcdPort: 9999
           num-of-onos: '3'
           num-of-atomix: '3'
@@ -121,6 +121,7 @@
       - 'build_voltha_pod_release_legacy':
           build-node: 'qa-testvm-pod'
           config-pod: 'flex-ocp-cord'
+          disable-job: true
           release: '2.7'
           branch: 'voltha-2.7'
           num-of-openonu: '1'
@@ -132,13 +133,15 @@
           Jenkinsfile: 'Jenkinsfile-voltha-build'
           configurePod: true
           profile: 'TP'
-          time: '22'
+          # Update this value while enabling the job
+          time: ''
           VolthaEtcdPort: 9999
 
       # flex pod1 test job - released versions: uses tech profile on voltha branch
       - 'build_voltha_pod_test':
           build-node: 'qa-testvm-pod'
           config-pod: 'flex-ocp-cord'
+          disable-job: true
           release: '2.7'
           branch: 'voltha-2.7'
           name-extension: '_TT'
@@ -157,7 +160,7 @@
           name-extension: '_TT'
           work-flow: 'TT'
           profile: 'TP'
-          time: '9'
+          time: '10'
           VolthaEtcdPort: 9999
           num-of-onos: '3'
           num-of-atomix: '3'
@@ -175,6 +178,37 @@
           test-repo: 'voltha-system-tests'
           profile: 'TP'
 
+    # flex OCP pod with olt/onu - Released versions Default tech profile and timer based job
+      - 'build_voltha_pod_release_timer':
+          build-node: 'qa-testvm-pod'
+          config-pod: 'flex-ocp-cord-multi-uni'
+          release: 'master'
+          branch: 'master'
+          name-extension: '_TT'
+          work-flow: 'TT'
+          profile: 'TP'
+          time: '15'
+          VolthaEtcdPort: 9999
+          num-of-onos: '3'
+          num-of-atomix: '3'
+          reinstall-olt: true
+          enableMultiUni: true
+          uniPortMask: '0x0003'
+
+      # flex pod1 test job - released versions: uses tech profile on voltha branch
+      - 'build_voltha_pod_test':
+          build-node: 'qa-testvm-pod'
+          config-pod: 'flex-ocp-cord-multi-uni'
+          release: 'master'
+          branch: 'master'
+          name-extension: '_TT'
+          work-flow: 'TT'
+          power-switch: True
+          pipeline-script: 'voltha-tt-physical-functional-tests.groovy'
+          test-repo: 'voltha-system-tests'
+          profile: 'TP'
+          enableMultiUni: true
+
       # Menlo pod with olt/onu - 1T4GEM tech profile and timer based job
       - 'build_voltha_pod_release_timer':
           build-node: 'menlo-demo-pod'