Updated voltha-patch-test master jobs to use periodic-bbsim-tests pipeline

Change-Id: I98d4012433510aed5763bc245864c816b485e3b3
diff --git a/jjb/pipeline/voltha/master/bbsim-tests.groovy b/jjb/pipeline/voltha/master/bbsim-tests.groovy
old mode 100644
new mode 100755
index e38bc9a..82a27ec
--- a/jjb/pipeline/voltha/master/bbsim-tests.groovy
+++ b/jjb/pipeline/voltha/master/bbsim-tests.groovy
@@ -1,4 +1,4 @@
-// Copyright 2017-present Open Networking Foundation
+// Copyright 2021-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.
@@ -12,103 +12,155 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// voltha-2.x e2e tests
+// voltha-2.x e2e tests for openonu-go
 // uses bbsim to simulate OLT/ONUs
 
-// NOTE we are importing the library even if it's global so that it's
-// easier to change the keywords during a replay
 library identifier: 'cord-jenkins-libraries@master',
     retriever: modernSCM([
       $class: 'GitSCMSource',
       remote: 'https://gerrit.opencord.org/ci-management.git'
 ])
 
-def test_workflow(name) {
-  timeout(time: 5, unit: 'MINUTES') {
-    stage('Deploy - '+ name + ' workflow') {
-        def extraHelmFlags = "${extraHelmFlags} --set global.log_level=DEBUG,onu=1,pon=1 " +
+def clusterName = "kind-ci"
+
+def execute_test(testTarget, workflow, teardown, testSpecificHelmFlags = "") {
+  def infraNamespace = "default"
+  def volthaNamespace = "voltha"
+  def robotLogsDir = "RobotLogs"
+  stage('Cleanup') {
+    if (teardown) {
+      timeout(15) {
+        script {
+          helmTeardown(["default", infraNamespace, volthaNamespace])
+        }
+        timeout(1) {
+          sh returnStdout: false, script: '''
+          # 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') {
+    if (teardown) {
+      timeout(20) {
+        script {
+
+          sh """
+          mkdir -p $WORKSPACE/${testTarget}-components
+          _TAG=kail-startup kail -n infra -n voltha > $WORKSPACE/${testTarget}-components/onos-voltha-startup-combined.log &
+          """
+
+          // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
+          def localCharts = false
+          if (volthaHelmChartsChange != "") {
+            localCharts = true
+          }
+
+          // NOTE temporary workaround expose ONOS node ports
+          def localHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel.toUpperCase()} " +
           " --set onos-classic.onosSshPort=30115 " +
-          "--set onos-classic.onosApiPort=30120 "
+          " --set onos-classic.onosApiPort=30120 " +
+          " --set onos-classic.onosOfPort=31653 " +
+          " --set onos-classic.individualOpenFlowNodePorts=true " + testSpecificHelmFlags
 
-        if (gerritProject != "") {
-          extraHelmFlags = extraHelmFlags + getVolthaImageFlags("${gerritProject}")
+          if (gerritProject != "") {
+            localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
+          }
+
+          volthaDeploy([
+            infraNamespace: infraNamespace,
+            volthaNamespace: volthaNamespace,
+            workflow: workflow.toLowerCase(),
+            extraHelmFlags: localHelmFlags,
+            localCharts: localCharts,
+            bbsimReplica: olts.toInteger(),
+            dockerRegistry: registry,
+            ])
         }
 
-        def localCharts = false
-        if (gerritProject == "voltha-helm-charts" || branch != "master") {
-          localCharts = true
-        }
-
-        volthaDeploy([
-          workflow: name,
-          extraHelmFlags:extraHelmFlags,
-          localCharts: localCharts,
-          dockerRegistry: "mirror.registry.opennetworking.org"
-        ])
-        // start logging
+        // stop logging
         sh """
-        mkdir -p $WORKSPACE/${name}
-        _TAG=kail-${name} kail -n infra -n voltha > $WORKSPACE/${name}/onos-voltha-combined.log &
+          P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
+          if [ -n "\$P_IDS" ]; then
+            echo \$P_IDS
+            for P_ID in \$P_IDS; do
+              kill -9 \$P_ID
+            done
+          fi
+          cd $WORKSPACE/${testTarget}-components/
+          gzip -k onos-voltha-startup-combined.log
+          rm onos-voltha-startup-combined.log
         """
-        // forward ONOS and VOLTHA ports
-        sh """
-        JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n voltha svc/voltha-voltha-api 55555:55555; done"&
-        """
+      }
+      sh """
+      JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
+      JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-etcd" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd 2379:2379; done"&
+      JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-kafka" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
+      bbsimDmiPortFwd=50075
+      for i in {0..${olts.toInteger() - 1}}; do
+        JENKINS_NODE_COOKIE="dontKillMe" _TAG="bbsim\${i}" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/bbsim\${i} \${bbsimDmiPortFwd}:50075; done"&
+        ((bbsimDmiPortFwd++))
+      done
+      ps aux | grep port-forward
+      """
     }
   }
-  stage('Test VOLTHA - '+ name + ' workflow') {
-    timeout(time: 10, unit: 'MINUTES') {
-      sh """
-      ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/${name.toUpperCase()}Workflow"
-      mkdir -p \$ROBOT_LOGS_DIR
-      export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -e PowerSwitch "
-      ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120"
+  stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow') {
+    // start logging
+    sh """
+    mkdir -p $WORKSPACE/${testTarget}-components
+    _TAG=kail-${workflow} kail -n infra -n voltha > $WORKSPACE/${testTarget}-components/onos-voltha-combined.log &
+    """
+    sh """
+    mkdir -p $WORKSPACE/${robotLogsDir}/${testTarget}-robot
+    export ROBOT_MISC_ARGS="-d $WORKSPACE/${robotLogsDir}/${testTarget}-robot "
+    ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120 -v INFRA_NAMESPACE:${infraNamespace}"
+    export KVSTOREPREFIX=voltha/voltha_voltha
 
-      # By default, all tests tagged 'sanity' are run.  This covers basic functionality
-      # like running through the ATT workflow for a single subscriber.
-      export TARGET=sanity-kind-${name}
-
-      # If the Gerrit comment contains a line with "functional tests" then run the full
-      # functional test suite.  This covers tests tagged either 'sanity' or 'functional'.
-      # Note: Gerrit comment text will be prefixed by "Patch set n:" and a blank line
-      REGEX="functional tests"
-      if [[ "\$GERRIT_EVENT_COMMENT_TEXT" =~ \$REGEX ]]; then
-        export TARGET=functional-single-kind-${name}
+    make -C $WORKSPACE/voltha-system-tests ${testTarget} || true
+    """
+    // stop logging
+    sh """
+      P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${workflow}" | grep -v grep | awk '{print \$1}')"
+      if [ -n "\$P_IDS" ]; then
+        echo \$P_IDS
+        for P_ID in \$P_IDS; do
+          kill -9 \$P_ID
+        done
       fi
-
-      if [[ "${gerritProject}" == "bbsim" ]]; then
-        echo "Running BBSim specific Tests"
-        export TARGET=sanity-bbsim-${name}
-      fi
-
-      export VOLTCONFIG=$HOME/.volt/config
-      export KUBECONFIG=$HOME/.kube/config
-
-      # Run the specified tests
-      make -C $WORKSPACE/voltha-system-tests \$TARGET || true
-      """
-      // stop logging
-      sh """
-        P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${name}" | grep -v grep | awk '{print \$1}')"
-        if [ -n "\$P_IDS" ]; then
-          echo \$P_IDS
-          for P_ID in \$P_IDS; do
-            kill -9 \$P_ID
-          done
-        fi
-      """
-      // remove port-forwarding
-      sh """
-        # 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
-      """
-      // collect pod details
-      getPodsInfo("$WORKSPACE/${name}")
-      helmTeardown(['infra', 'voltha'])
-    }
+      cd $WORKSPACE/${testTarget}-components/
+      gzip -k onos-voltha-combined.log
+      rm onos-voltha-combined.log
+    """
+    getPodsInfo("$WORKSPACE/${testTarget}-components")
   }
 }
 
+def collectArtifacts(exitStatus) {
+  getPodsInfo("$WORKSPACE/${exitStatus}")
+  sh """
+  kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log || true
+  """
+  archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html'
+  sh '''
+    sync
+    pkill kail || true
+    which voltctl
+    md5sum $(which voltctl)
+  '''
+  step([$class: 'RobotPublisher',
+    disableArchiveOutput: false,
+    logFileName: "RobotLogs/*/log*.html",
+    otherFiles: '',
+    outputFileName: "RobotLogs/*/output*.xml",
+    outputPath: '.',
+    passThreshold: 100,
+    reportFileName: "RobotLogs/*/report*.html",
+    unstableThreshold: 0]);
+}
+
 pipeline {
 
   /* no label, executor is determined by JJB */
@@ -116,14 +168,16 @@
     label "${params.buildNode}"
   }
   options {
-    timeout(time: 50, unit: 'MINUTES')
+    timeout(time: "${timeout}", unit: 'MINUTES')
   }
   environment {
-    PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
-    KUBECONFIG="$HOME/.kube/kind-config-${clusterName}"
+    KUBECONFIG="$HOME/.kube/kind-${clusterName}"
+    VOLTCONFIG="$HOME/.volt/config"
+    PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+    ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
+    DIAGS_PROFILE="VOLTHA_PROFILE"
   }
-
-  stages{
+  stages {
     stage('Download Code') {
       steps {
         getVolthaCode([
@@ -136,6 +190,12 @@
       }
     }
     stage('Build patch') {
+      // build the patch only if gerritProject is specified
+      when {
+        expression {
+          return !gerritProject.isEmpty()
+        }
+      }
       steps {
         // NOTE that the correct patch has already been checked out
         // during the getVolthaCode step
@@ -144,72 +204,53 @@
     }
     stage('Create K8s Cluster') {
       steps {
-        createKubernetesCluster([nodes: 3])
+        script {
+          def clusterExists = sh returnStdout: true, script: """
+          kind get clusters | grep ${clusterName} | wc -l
+          """
+          if (clusterExists.trim() == "0") {
+            createKubernetesCluster([nodes: 3, name: clusterName])
+          }
+        }
       }
     }
     stage('Load image in kind nodes') {
+      when {
+        expression {
+          return !gerritProject.isEmpty()
+        }
+      }
       steps {
         loadToKind()
       }
     }
-    stage('Replace voltctl') {
-      // if the project is voltctl override the downloaded one with the built one
-      when {
-        expression {
-          return gerritProject == "voltctl"
+    stage('Parse and execute tests') {
+        steps {
+          script {
+            def tests = readYaml text: testTargets
+
+            for(int i = 0;i<tests.size();i++) {
+              def test = tests[i]
+              def target = test["target"]
+              def workflow = test["workflow"]
+              def flags = test["flags"]
+              def teardown = test["teardown"].toBoolean()
+              println "Executing test ${target} on workflow ${workflow} with extra flags ${flags}"
+              execute_test(target, workflow, teardown, flags)
+            }
+          }
         }
-      }
-      steps{
-        sh """
-        mv `ls $WORKSPACE/voltctl/release/voltctl-*-linux-amd*` $WORKSPACE/bin/voltctl
-        chmod +x $WORKSPACE/bin/voltctl
-        """
-      }
-    }
-    stage('Run Test') {
-      steps {
-        // preload the venv so it's not included in the timeout for the first test execution
-        sh """
-        make -C $WORKSPACE/voltha-system-tests vst_venv || true
-        """
-        test_workflow("att")
-        test_workflow("dt")
-        test_workflow("tt")
-      }
     }
   }
-
   post {
     aborted {
-      getPodsInfo("$WORKSPACE/failed")
-      sh """
-      kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log || true
-      """
-      archiveArtifacts artifacts: '**/*.log,**/*.txt,**/*.html'
+      collectArtifacts("aborted")
     }
     failure {
-      getPodsInfo("$WORKSPACE/failed")
-      sh """
-      kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.logs || true
-      """
-      archiveArtifacts artifacts: '**/*.log,**/*.txt,**/*.html'
+      collectArtifacts("failed")
     }
     always {
-      sh '''
-      gzip $WORKSPACE/att/onos-voltha-combined.log || true
-      gzip $WORKSPACE/dt/onos-voltha-combined.log || true
-      gzip $WORKSPACE/tt/onos-voltha-combined.log || true
-      '''
-      step([$class: 'RobotPublisher',
-         disableArchiveOutput: false,
-         logFileName: 'RobotLogs/*/log*.html',
-         otherFiles: '',
-         outputFileName: 'RobotLogs/*/output*.xml',
-         outputPath: '.',
-         passThreshold: 100,
-         reportFileName: 'RobotLogs/*/report*.html',
-         unstableThreshold: 0]);
-      archiveArtifacts artifacts: '*.log,**/*.log,**/*.gz,*.gz,*.txt,**/*.txt'
+      collectArtifacts("always")
     }
   }
 }
diff --git a/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy b/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy
deleted file mode 100755
index 82a27ec..0000000
--- a/jjb/pipeline/voltha/master/periodic-bbsim-tests.groovy
+++ /dev/null
@@ -1,256 +0,0 @@
-// Copyright 2021-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.
-
-// voltha-2.x e2e tests for openonu-go
-// uses bbsim to simulate OLT/ONUs
-
-library identifier: 'cord-jenkins-libraries@master',
-    retriever: modernSCM([
-      $class: 'GitSCMSource',
-      remote: 'https://gerrit.opencord.org/ci-management.git'
-])
-
-def clusterName = "kind-ci"
-
-def execute_test(testTarget, workflow, teardown, testSpecificHelmFlags = "") {
-  def infraNamespace = "default"
-  def volthaNamespace = "voltha"
-  def robotLogsDir = "RobotLogs"
-  stage('Cleanup') {
-    if (teardown) {
-      timeout(15) {
-        script {
-          helmTeardown(["default", infraNamespace, volthaNamespace])
-        }
-        timeout(1) {
-          sh returnStdout: false, script: '''
-          # 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') {
-    if (teardown) {
-      timeout(20) {
-        script {
-
-          sh """
-          mkdir -p $WORKSPACE/${testTarget}-components
-          _TAG=kail-startup kail -n infra -n voltha > $WORKSPACE/${testTarget}-components/onos-voltha-startup-combined.log &
-          """
-
-          // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
-          def localCharts = false
-          if (volthaHelmChartsChange != "") {
-            localCharts = true
-          }
-
-          // NOTE temporary workaround expose ONOS node ports
-          def localHelmFlags = extraHelmFlags + " --set global.log_level=${logLevel.toUpperCase()} " +
-          " --set onos-classic.onosSshPort=30115 " +
-          " --set onos-classic.onosApiPort=30120 " +
-          " --set onos-classic.onosOfPort=31653 " +
-          " --set onos-classic.individualOpenFlowNodePorts=true " + testSpecificHelmFlags
-
-          if (gerritProject != "") {
-            localHelmFlags = "${localHelmFlags} " + getVolthaImageFlags("${gerritProject}")
-          }
-
-          volthaDeploy([
-            infraNamespace: infraNamespace,
-            volthaNamespace: volthaNamespace,
-            workflow: workflow.toLowerCase(),
-            extraHelmFlags: localHelmFlags,
-            localCharts: localCharts,
-            bbsimReplica: olts.toInteger(),
-            dockerRegistry: registry,
-            ])
-        }
-
-        // stop logging
-        sh """
-          P_IDS="\$(ps e -ww -A | grep "_TAG=kail-startup" | grep -v grep | awk '{print \$1}')"
-          if [ -n "\$P_IDS" ]; then
-            echo \$P_IDS
-            for P_ID in \$P_IDS; do
-              kill -9 \$P_ID
-            done
-          fi
-          cd $WORKSPACE/${testTarget}-components/
-          gzip -k onos-voltha-startup-combined.log
-          rm onos-voltha-startup-combined.log
-        """
-      }
-      sh """
-      JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-voltha-api" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
-      JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-etcd" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd 2379:2379; done"&
-      JENKINS_NODE_COOKIE="dontKillMe" _TAG="voltha-infra-kafka" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
-      bbsimDmiPortFwd=50075
-      for i in {0..${olts.toInteger() - 1}}; do
-        JENKINS_NODE_COOKIE="dontKillMe" _TAG="bbsim\${i}" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/bbsim\${i} \${bbsimDmiPortFwd}:50075; done"&
-        ((bbsimDmiPortFwd++))
-      done
-      ps aux | grep port-forward
-      """
-    }
-  }
-  stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow') {
-    // start logging
-    sh """
-    mkdir -p $WORKSPACE/${testTarget}-components
-    _TAG=kail-${workflow} kail -n infra -n voltha > $WORKSPACE/${testTarget}-components/onos-voltha-combined.log &
-    """
-    sh """
-    mkdir -p $WORKSPACE/${robotLogsDir}/${testTarget}-robot
-    export ROBOT_MISC_ARGS="-d $WORKSPACE/${robotLogsDir}/${testTarget}-robot "
-    ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120 -v INFRA_NAMESPACE:${infraNamespace}"
-    export KVSTOREPREFIX=voltha/voltha_voltha
-
-    make -C $WORKSPACE/voltha-system-tests ${testTarget} || true
-    """
-    // stop logging
-    sh """
-      P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${workflow}" | grep -v grep | awk '{print \$1}')"
-      if [ -n "\$P_IDS" ]; then
-        echo \$P_IDS
-        for P_ID in \$P_IDS; do
-          kill -9 \$P_ID
-        done
-      fi
-      cd $WORKSPACE/${testTarget}-components/
-      gzip -k onos-voltha-combined.log
-      rm onos-voltha-combined.log
-    """
-    getPodsInfo("$WORKSPACE/${testTarget}-components")
-  }
-}
-
-def collectArtifacts(exitStatus) {
-  getPodsInfo("$WORKSPACE/${exitStatus}")
-  sh """
-  kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log || true
-  """
-  archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html'
-  sh '''
-    sync
-    pkill kail || true
-    which voltctl
-    md5sum $(which voltctl)
-  '''
-  step([$class: 'RobotPublisher',
-    disableArchiveOutput: false,
-    logFileName: "RobotLogs/*/log*.html",
-    otherFiles: '',
-    outputFileName: "RobotLogs/*/output*.xml",
-    outputPath: '.',
-    passThreshold: 100,
-    reportFileName: "RobotLogs/*/report*.html",
-    unstableThreshold: 0]);
-}
-
-pipeline {
-
-  /* no label, executor is determined by JJB */
-  agent {
-    label "${params.buildNode}"
-  }
-  options {
-    timeout(time: "${timeout}", unit: 'MINUTES')
-  }
-  environment {
-    KUBECONFIG="$HOME/.kube/kind-${clusterName}"
-    VOLTCONFIG="$HOME/.volt/config"
-    PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-    ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
-    DIAGS_PROFILE="VOLTHA_PROFILE"
-  }
-  stages {
-    stage('Download Code') {
-      steps {
-        getVolthaCode([
-          branch: "${branch}",
-          gerritProject: "${gerritProject}",
-          gerritRefspec: "${gerritRefspec}",
-          volthaSystemTestsChange: "${volthaSystemTestsChange}",
-          volthaHelmChartsChange: "${volthaHelmChartsChange}",
-        ])
-      }
-    }
-    stage('Build patch') {
-      // build the patch only if gerritProject is specified
-      when {
-        expression {
-          return !gerritProject.isEmpty()
-        }
-      }
-      steps {
-        // NOTE that the correct patch has already been checked out
-        // during the getVolthaCode step
-        buildVolthaComponent("${gerritProject}")
-      }
-    }
-    stage('Create K8s Cluster') {
-      steps {
-        script {
-          def clusterExists = sh returnStdout: true, script: """
-          kind get clusters | grep ${clusterName} | wc -l
-          """
-          if (clusterExists.trim() == "0") {
-            createKubernetesCluster([nodes: 3, name: clusterName])
-          }
-        }
-      }
-    }
-    stage('Load image in kind nodes') {
-      when {
-        expression {
-          return !gerritProject.isEmpty()
-        }
-      }
-      steps {
-        loadToKind()
-      }
-    }
-    stage('Parse and execute tests') {
-        steps {
-          script {
-            def tests = readYaml text: testTargets
-
-            for(int i = 0;i<tests.size();i++) {
-              def test = tests[i]
-              def target = test["target"]
-              def workflow = test["workflow"]
-              def flags = test["flags"]
-              def teardown = test["teardown"].toBoolean()
-              println "Executing test ${target} on workflow ${workflow} with extra flags ${flags}"
-              execute_test(target, workflow, teardown, flags)
-            }
-          }
-        }
-    }
-  }
-  post {
-    aborted {
-      collectArtifacts("aborted")
-    }
-    failure {
-      collectArtifacts("failed")
-    }
-    always {
-      collectArtifacts("always")
-    }
-  }
-}
diff --git a/jjb/verify/bbsim-sadis-server.yaml b/jjb/verify/bbsim-sadis-server.yaml
index 2ce60d3..9ca6e61 100644
--- a/jjb/verify/bbsim-sadis-server.yaml
+++ b/jjb/verify/bbsim-sadis-server.yaml
@@ -38,7 +38,6 @@
     name: 'verify-bbsim-sadis-server-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/bbsim.yaml b/jjb/verify/bbsim.yaml
index 37dfbae..45b6707 100644
--- a/jjb/verify/bbsim.yaml
+++ b/jjb/verify/bbsim.yaml
@@ -39,8 +39,20 @@
     name: 'verify-bbsim-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
+          testTargets: |
+            - target: sanity-bbsim-att
+              workflow: att
+              flags: ""
+              teardown: true
+            - target: sanity-bbsim-dt
+              workflow: dt
+              flags: ""
+              teardown: true
+            - target: sanity-bbsim-tt
+              workflow: tt
+              flags: ""
+              teardown: true
 
 - job-group:
     name: 'publish-bbsim-jobs'
diff --git a/jjb/verify/ofagent-go.yaml b/jjb/verify/ofagent-go.yaml
index 9483d6e..09dac06 100644
--- a/jjb/verify/ofagent-go.yaml
+++ b/jjb/verify/ofagent-go.yaml
@@ -40,7 +40,6 @@
     name: 'verify-ofagent-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/voltctl.yaml b/jjb/verify/voltctl.yaml
index 220e0ce..e4821de 100644
--- a/jjb/verify/voltctl.yaml
+++ b/jjb/verify/voltctl.yaml
@@ -25,7 +25,6 @@
           unit-test-keep-going: 'true'
           dependency-jobs: 'verify_voltctl_tag-collision'
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/voltha-go.yaml b/jjb/verify/voltha-go.yaml
index e4a4576..8a808a6 100644
--- a/jjb/verify/voltha-go.yaml
+++ b/jjb/verify/voltha-go.yaml
@@ -48,7 +48,6 @@
     name: 'verify-voltha-go-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/voltha-helm-charts.yaml b/jjb/verify/voltha-helm-charts.yaml
index ebe7c50..e947800 100644
--- a/jjb/verify/voltha-helm-charts.yaml
+++ b/jjb/verify/voltha-helm-charts.yaml
@@ -33,5 +33,4 @@
 - job-group:
     name: 'verify-voltha-helm-charts-jobs-master'
     jobs:
-      - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
+      - 'voltha-patch-test'
diff --git a/jjb/verify/voltha-onos.yaml b/jjb/verify/voltha-onos.yaml
index d708a43..d85f8ef 100644
--- a/jjb/verify/voltha-onos.yaml
+++ b/jjb/verify/voltha-onos.yaml
@@ -34,7 +34,6 @@
     name: 'verify-voltha-onos-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/voltha-openolt-adapter.yaml b/jjb/verify/voltha-openolt-adapter.yaml
index ff3587b..7bb77c8 100644
--- a/jjb/verify/voltha-openolt-adapter.yaml
+++ b/jjb/verify/voltha-openolt-adapter.yaml
@@ -48,7 +48,6 @@
     name: 'verify-voltha-openolt-adapter-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/voltha-openonu-adapter-go.yaml b/jjb/verify/voltha-openonu-adapter-go.yaml
index e4e67e3..258ec5e 100644
--- a/jjb/verify/voltha-openonu-adapter-go.yaml
+++ b/jjb/verify/voltha-openonu-adapter-go.yaml
@@ -47,8 +47,24 @@
     name: 'verify-voltha-openonu-adapter-go-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
+          testTargets: |
+            - target: sanity-kind-att
+              workflow: att
+              flags: ""
+              teardown: true
+            - target: sanity-kind-dt
+              workflow: dt
+              flags: ""
+              teardown: true
+            - target: sanity-kind-tt
+              workflow: tt
+              flags: ""
+              teardown: true
+            - target: 1t4gem-openonu-go-adapter-test
+              workflow: att
+              flags: ""
+              teardown: true
 
 - job-group:
     name: 'publish-voltha-openonu-adapter-go-jobs'
diff --git a/jjb/verify/voltha-openonu-adapter.yaml b/jjb/verify/voltha-openonu-adapter.yaml
index 21a1968..1388ae0 100644
--- a/jjb/verify/voltha-openonu-adapter.yaml
+++ b/jjb/verify/voltha-openonu-adapter.yaml
@@ -45,7 +45,6 @@
     name: 'verify-voltha-openonu-adapter-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
 
 - job-group:
diff --git a/jjb/verify/voltha-system-tests.yaml b/jjb/verify/voltha-system-tests.yaml
index b385e2f..c068b55 100644
--- a/jjb/verify/voltha-system-tests.yaml
+++ b/jjb/verify/voltha-system-tests.yaml
@@ -39,5 +39,4 @@
     name: 'verify-voltha-system-tests-jobs-master'
     jobs:
       - 'voltha-patch-test':
-          pipeline-script: 'voltha/master/bbsim-tests.groovy'
           extraHelmFlags: '--set global.image_tag=master --set onos-classic.image.tag=master'
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index 7ba6eb5..1c73837 100755
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -526,7 +526,7 @@
 - job-template:
     id: 'voltha-periodic-test'
     name: '{name}'
-    pipeline-script: 'voltha/master/periodic-bbsim-tests.groovy'
+    pipeline-script: 'voltha/master/bbsim-tests.groovy'
     build-node: 'ubuntu18.04-basebuild-8c-15g'
     robot-args: ''
     gerrit-project: ''
@@ -831,6 +831,7 @@
     id: 'voltha-patch-test'
     name: 'verify_{project}_sanity-test{name-extension}'
     build-node: 'ubuntu18.04-basebuild-4c-8g'
+    pipeline-script: 'voltha/master/bbsim-tests.groovy'
     override-branch: '$GERRIT_BRANCH'
     sandbox: true
     build-timeout: 20
@@ -838,6 +839,19 @@
     volthaHelmChartsChange: ''
     extraHelmFlags: ''
     branch-regexp: '{all-branches-regexp}'
+    testTargets: |
+      - target: sanity-kind-att
+        workflow: att
+        flags: ""
+        teardown: true
+      - target: sanity-kind-dt
+        workflow: dt
+        flags: ""
+        teardown: true
+      - target: sanity-kind-tt
+        workflow: tt
+        flags: ""
+        teardown: true
     kindVolthaChange: '' # this is only needed to test kind-voltha patches
 
     description: |
@@ -891,6 +905,20 @@
           default: '{override-branch}'
           description: 'Name of the branch to use'
 
+      # test configuration
+      # this is a parameter to drive the test execution, VOLTHA is redeployed each time with
+      # the provided configuration and then the make target is invoked,
+      # example value (has to be valid YAML):
+      # testTargets: |
+      #   - target: 1t1gem-openonu-go-adapter-test
+      #     workflow: att
+      #     flags: ""
+      #     teardown: true
+      - text:
+          name: testTargets
+          default: '{testTargets}'
+          description: 'Test configuration, see the ci-management job definition for more info'
+
       # Used in the 2.7 based pipeline, can be removed after 2.8
       - string:
           name: kindVolthaChange