[VOL-4590] Added support for enableMacLearning in TT bbsim jobs

Change-Id: I67d687b7cc579d065ce5f2019fd4f625442934c5
diff --git a/jjb/pipeline/voltha/master/bbsim-tests.groovy b/jjb/pipeline/voltha/master/bbsim-tests.groovy
index f039841..a164d55 100755
--- a/jjb/pipeline/voltha/master/bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/master/bbsim-tests.groovy
@@ -73,6 +73,7 @@
             infraNamespace: infraNamespace,
             volthaNamespace: volthaNamespace,
             workflow: workflow.toLowerCase(),
+            withMacLearning: enableMacLearning,
             extraHelmFlags: localHelmFlags,
             localCharts: localCharts,
             bbsimReplica: olts.toInteger(),
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index 5e84cb5..26c6257 100755
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -1314,6 +1314,20 @@
               teardown: true
               logging: true
 
+      - 'voltha-periodic-test':
+          name: 'periodic-voltha-tt-maclearner-sanity-test-bbsim'
+          code-branch: 'master'
+          extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master --set onos-classic.replicas=3,onos-classic.atomix.replicas=3 --set voltha.onos_classic.replicas=3 '
+          time-trigger: "H H/23 * * *"
+          logLevel: 'DEBUG'
+          enableMacLearning: true
+          testTargets: |
+            - target: sanity-kind-tt-maclearning
+              workflow: tt
+              flags: ""
+              teardown: true
+              logging: true
+
       # ATT Per-patchset Pod builds on Tucson pod (master)
       - 'verify_physical_voltha_patchset_auto':
           name: 'verify_physical_voltha_patchset_auto'
@@ -1382,6 +1396,7 @@
     olts: 1
     timeout: 130
     logLevel: 'INFO'
+    enableMacLearning: false
 
     trigger-comment: vv7CBoQQYYonvaN8xcru
     time-trigger: 0 0 29 2 *
@@ -1442,6 +1457,12 @@
           default: '{gerritRefspec}'
           description: 'PatchSet REFSPEC in Gerrit, example value: "refs/changes/79/18779/13"'
 
+      # applicable for voltha-2.9 (excluding) onwards
+      - bool:
+          name: enableMacLearning
+          default: '{enableMacLearning}'
+          description: "Deploy and test with ONOS Mac-Learning app"
+
       - string:
           name: extraRobotArgs
           default: '{robot-args}'
@@ -1519,6 +1540,7 @@
     volthaSystemTestsChange: ''
     volthaHelmChartsChange: ''
     extraHelmFlags: ''
+    enableMacLearning: false
     robot-args: ''
     branch-regexp: '{all-branches-regexp}'
     testTargets: |
@@ -1574,6 +1596,12 @@
           default: '{extraHelmFlags}'
           description: 'Helm flags to pass to every helm command'
 
+      # applicable for voltha-2.9 (excluding) onwards
+      - bool:
+          name: enableMacLearning
+          default: '{enableMacLearning}'
+          description: "Deploy and test with ONOS Mac-Learning app"
+
       - string:
           name: extraRobotArgs
           default: '{robot-args}'
diff --git a/vars/volthaDeploy.groovy b/vars/volthaDeploy.groovy
index d8d679f..7936e5a 100644
--- a/vars/volthaDeploy.groovy
+++ b/vars/volthaDeploy.groovy
@@ -14,6 +14,7 @@
       stackName: "voltha",
       stackId: 1,
       workflow: "att",
+      withMacLearning: false,
       extraHelmFlags: "",
       localCharts: false, // wether to use locally cloned charts or upstream one (for local we assume they are stored in $WORKSPACE/voltha-helm-charts)
       dockerRegistry: "", // use a different docker registry for all images, eg: "mirror.registry.opennetworking.org"
diff --git a/vars/volthaInfraDeploy.groovy b/vars/volthaInfraDeploy.groovy
index be2f759..fd03e51 100644
--- a/vars/volthaInfraDeploy.groovy
+++ b/vars/volthaInfraDeploy.groovy
@@ -18,6 +18,7 @@
       etcdReplica: 1,
       infraNamespace: "infra",
       workflow: "att",
+      withMacLearning: false,
       extraHelmFlags: "",
       localCharts: false,
       kubeconfig: null, // location of the kubernetes config file, if null we assume it's stored in the $KUBECONFIG environment variable
@@ -53,6 +54,11 @@
     kubectl create configmap -n ${cfg.infraNamespace} kube-config "--from-file=kube_config=${kubeconfig}"  || true
     """
 
+    def serviceConfigFile = cfg.workflow
+    if (cfg.withMacLearning && cfg.workflow == 'tt') {
+      serviceConfigFile = "tt-maclearner"
+    }
+
     // bitnamic/etch has change the replica format between the currently used 5.4.2 and the latest 6.2.5
     // for now put both values in the extra helm chart flags
     sh """
@@ -61,6 +67,6 @@
           --set kafka.replicaCount=${cfg.kafkaReplica},kafka.zookeeper.replicaCount=${cfg.kafkaReplica} \
           --set etcd.statefulset.replicaCount=${cfg.etcdReplica} \
           --set etcd.replicaCount=${cfg.etcdReplica} \
-          -f $WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml ${cfg.extraHelmFlags}
+          -f $WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml ${cfg.extraHelmFlags}
     """
 }
diff --git a/vars/volthaStackDeploy.groovy b/vars/volthaStackDeploy.groovy
index 0f96796..37a00d2 100644
--- a/vars/volthaStackDeploy.groovy
+++ b/vars/volthaStackDeploy.groovy
@@ -53,7 +53,11 @@
         """
         if (cfg.workflow == "att" || cfg.workflow == "tt") {
           def startingStag = 900
-          def bbsimCfg = readYaml file: "$WORKSPACE/voltha-helm-charts/examples/${cfg.workflow}-values.yaml"
+          def serviceConfigFile = cfg.workflow
+          if (cfg.withMacLearning && cfg.workflow == 'tt') {
+            serviceConfigFile = "tt-maclearner"
+          }
+          def bbsimCfg = readYaml file: "$WORKSPACE/voltha-helm-charts/examples/${serviceConfigFile}-values.yaml"
           // NOTE we assume that the only service that needs a different s_tag is the first one in the list
           bbsimCfg["servicesConfig"]["services"][0]["s_tag"] = startingStag + i
           println "Using BBSim Service config ${bbsimCfg['servicesConfig']}"