Merge "Adding ONOS HA test to physical pod tests"
diff --git a/jjb/cord-test/voltha.yaml b/jjb/cord-test/voltha.yaml
index a8fbf45..b3025e2 100644
--- a/jjb/cord-test/voltha.yaml
+++ b/jjb/cord-test/voltha.yaml
@@ -372,11 +372,11 @@
           branch: 'master'
           release: 'master'
           work-flow: 'DT'
-          name-extension: '_soak_func'
+          name-extension: '_DT_soak_Func'
           test-type: 'Functional'
           test-repo: 'voltha-system-tests'
           pipeline-script: 'voltha-physical-soak-dt-tests.groovy'
-          time-trigger: "H H 20 * *"
+          time-trigger: "H H 2 * *"
 
       # ONF Menlo Soak POD test job - voltha-master branch
       # Run tests every three days
@@ -387,10 +387,25 @@
           branch: 'master'
           release: 'master'
           work-flow: 'DT'
-          name-extension: '_soak_fail'
+          name-extension: '_DT_soak_Fail'
           test-type: 'Failure'
           test-repo: 'voltha-system-tests'
           pipeline-script: 'voltha-physical-soak-dt-tests.groovy'
+          time-trigger: "H H */2 * *"
+
+      # ONF Menlo Soak POD test job - voltha-master branch
+      # Run dataplane tests every three days
+      - 'build_voltha_pod_soak_test':
+          build-node: 'menlo-soak-pod'
+          config-pod: 'onf-soak-pod'
+          profile: '1T8GEM'
+          branch: 'master'
+          release: 'master'
+          work-flow: 'DT'
+          name-extension: '_DT_soak_DP'
+          test-type: 'Dataplane'
+          test-repo: 'voltha-system-tests'
+          pipeline-script: 'voltha-physical-soak-dt-tests.groovy'
           time-trigger: "H H */3 * *"
 
       # Infosys pod with olt/onu - Default tech profile and timer based job
diff --git a/jjb/pipeline/voltha-bbsim-tests.groovy b/jjb/pipeline/voltha-bbsim-tests.groovy
index 2fa0279..cbf9e81 100644
--- a/jjb/pipeline/voltha-bbsim-tests.groovy
+++ b/jjb/pipeline/voltha-bbsim-tests.groovy
@@ -26,7 +26,7 @@
     timeout(time: 90, unit: 'MINUTES')
   }
   environment {
-    PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+    PATH="$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
     VOLTHA_LOG_LEVEL="DEBUG"
     FANCY=0
     WITH_SIM_ADAPTERS="n"
@@ -36,37 +36,61 @@
   }
 
   stages {
-
-    stage('Repo') {
+    stage('Clone kind-voltha') {
       steps {
-        step([$class: 'WsCleanup'])
-        checkout(changelog: false, \
-          poll: false,
-          scm: [$class: 'RepoScm', \
-            manifestRepositoryUrl: "${params.manifestUrl}", \
-            manifestBranch: "${params.branch}", \
-            currentBranch: true, \
-            destinationDir: 'voltha', \
-            forceSync: true,
-            resetFirst: true, \
-            quiet: true, \
-            jobs: 4, \
-            showAllChanges: true] \
-          )
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/kind-voltha",
+            refspec: "${kindVolthaChange}"
+          ]],
+          branches: [[ name: "master", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
       }
     }
-    stage('Patch') {
+    stage('Clone voltha-system-tests') {
       steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/voltha-system-tests",
+            refspec: "${volthaSystemTestsChange}"
+          ]],
+          branches: [[ name: "${branch}", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
+      }
+    }
+    stage('Download Patch') {
+      steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/${gerritProject}",
+            refspec: "${gerritRefspec}"
+          ]],
+          branches: [[ name: "${branch}", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "${gerritProject}"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
         sh """
-           pushd voltha
-           if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ]
-           then
-             repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
-           else
-             echo "No patchset to download!"
-           fi
-           popd
-           """
+          pushd $WORKSPACE/${gerritProject}
+          echo "Currently on commit: \n"
+          git log -1 --oneline
+          popd
+          """
       }
     }
     stage('Create K8s Cluster') {
@@ -74,14 +98,14 @@
         sh """
            if [ "${branch}" != "master" ]; then
              echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
-             source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
            else
              echo "on master, using default settings for kind-voltha"
            fi
 
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            JUST_K8S=y ./voltha up
-           bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin"
+           bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/kind-voltha/bin"
            """
       }
     }
@@ -90,20 +114,20 @@
       steps {
         sh """
            make-local () {
-             make -C $WORKSPACE/voltha/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
+             make -C $WORKSPACE/\$1 DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
            }
            if [ "${gerritProject}" = "pyvoltha" ]; then
-             make -C $WORKSPACE/voltha/pyvoltha/ dist
-             export LOCAL_PYVOLTHA=$WORKSPACE/voltha/pyvoltha/
+             make -C $WORKSPACE/pyvoltha/ dist
+             export LOCAL_PYVOLTHA=$WORKSPACE/pyvoltha/
              make-local voltha-openonu-adapter
            elif [ "${gerritProject}" = "voltha-lib-go" ]; then
-             make -C $WORKSPACE/voltha/voltha-lib-go/ build
-             export LOCAL_LIB_GO=$WORKSPACE/voltha/voltha-lib-go/
+             make -C $WORKSPACE/voltha-lib-go/ build
+             export LOCAL_LIB_GO=$WORKSPACE/voltha-lib-go/
              make-local voltha-go
              make-local voltha-openolt-adapter
            elif [ "${gerritProject}" = "voltha-protos" ]; then
-             make -C $WORKSPACE/voltha/voltha-protos/ build
-             export LOCAL_PROTOS=$WORKSPACE/voltha/voltha-protos/
+             make -C $WORKSPACE/voltha-protos/ build
+             export LOCAL_PROTOS=$WORKSPACE/voltha-protos/
              make-local voltha-go
              make-local voltha-openolt-adapter
              make-local voltha-openonu-adapter
@@ -112,7 +136,7 @@
              # Set and handle GOPATH and PATH
              export GOPATH=\${GOPATH:-$WORKSPACE/go}
              export PATH=\$PATH:/usr/lib/go-1.12/bin:/usr/local/go/bin:\$GOPATH/bin
-             make -C $WORKSPACE/voltha/voltctl/ build
+             make -C $WORKSPACE/voltctl/ build
            elif ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests|kind-voltha)\$ ]]; then
              make-local ${gerritProject}
            fi
@@ -125,7 +149,7 @@
         sh '''
            if [ "${branch}" != "master" ]; then
              echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
-             source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
            else
              echo "on master, using default settings for kind-voltha"
            fi
@@ -148,7 +172,7 @@
         sh '''
            if [ "${branch}" != "master" ]; then
              echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
-             source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
+             source "$WORKSPACE/kind-voltha/releases/${branch}"
            else
              echo "on master, using default settings for kind-voltha"
            fi
@@ -196,7 +220,7 @@
            done
 
            if [ "${gerritProject}" = "voltha-helm-charts" ]; then
-             export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
+             export CHART_PATH=$WORKSPACE/voltha-helm-charts
              export VOLTHA_CHART=\$CHART_PATH/voltha
              export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
              export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
@@ -206,15 +230,15 @@
            fi
 
            if [ "${gerritProject}" = "voltctl" ]; then
-             export VOLTCTL_VERSION=$(cat $WORKSPACE/voltha/voltctl/VERSION)
-             cp $WORKSPACE/voltha/voltctl/voltctl $WORKSPACE/voltha/kind-voltha/bin/voltctl
-             md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
+             export VOLTCTL_VERSION=$(cat $WORKSPACE/voltctl/VERSION)
+             cp $WORKSPACE/voltctl/voltctl $WORKSPACE/kind-voltha/bin/voltctl
+             md5sum $WORKSPACE/kind-voltha/bin/voltctl
            fi
 
            printenv
            kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
 
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            ./voltha up
 
            # $NAME-env.sh contains the environment we used
@@ -236,7 +260,7 @@
              TARGET=functional-single-kind
            fi
 
-           make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
+           make -C $WORKSPACE/voltha-system-tests \$TARGET || true
            '''
       }
     }
@@ -247,7 +271,7 @@
       }
       steps {
         sh '''
-           cd $WORKSPACE/voltha/kind-voltha/
+           cd $WORKSPACE/kind-voltha/
            source $NAME-env.sh
            WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
 
@@ -276,7 +300,47 @@
              TARGET=functional-single-kind-dt
            fi
 
-           make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
+           make -C $WORKSPACE/voltha-system-tests \$TARGET || true
+           '''
+      }
+    }
+
+    stage('TT workflow') {
+      environment {
+        ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/TTWorkflow"
+      }
+      steps {
+        sh '''
+           cd $WORKSPACE/kind-voltha/
+           source $NAME-env.sh
+           WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down
+
+           # Workflow-specific flags
+           export WITH_RADIUS=no
+           export WITH_EAPOL=no
+           export WITH_DHCP=yes
+           export WITH_IGMP=yes
+           export CONFIG_SADIS="external"
+           export BBSIM_CFG="configs/bbsim-sadis-tt.yaml"
+
+           DEPLOY_K8S=n ./voltha up
+
+           mkdir -p $ROBOT_LOGS_DIR
+           export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR -e PowerSwitch"
+
+           # By default, all tests tagged 'sanityTt' are run.  This covers basic functionality
+           # like running through the TT workflow for a single subscriber.
+           export TARGET=sanity-kind-tt
+
+           # If the Gerrit comment contains a line with "functional tests" then run the full
+           # functional test suite.  This covers tests tagged either 'sanityTt' or 'functionalTt'.
+           # 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
+             TARGET=functional-single-kind-tt
+           fi
+
+           make -C $WORKSPACE/voltha-system-tests \$TARGET || true
            '''
       }
     }
@@ -286,7 +350,7 @@
     always {
       sh '''
          set +e
-         cp $WORKSPACE/voltha/kind-voltha/install-$NAME.log $WORKSPACE/
+         cp $WORKSPACE/kind-voltha/install-$NAME.log $WORKSPACE/
          kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
          kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
          kubectl get nodes -o wide
@@ -295,7 +359,7 @@
 
          sync
          pkill kail || true
-         md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
+         md5sum $WORKSPACE/kind-voltha/bin/voltctl
 
          ## Pull out errors from log files
          extract_errors_go() {
diff --git a/jjb/pipeline/voltha-go-multi-tests.groovy b/jjb/pipeline/voltha-go-multi-tests.groovy
index 2c49f4c..9b099d7 100644
--- a/jjb/pipeline/voltha-go-multi-tests.groovy
+++ b/jjb/pipeline/voltha-go-multi-tests.groovy
@@ -23,7 +23,7 @@
     label "${params.buildNode}"
   }
   options {
-      timeout(time: 40, unit: 'MINUTES')
+      timeout(time: 60, unit: 'MINUTES')
   }
   environment {
     KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
@@ -36,7 +36,8 @@
     WITH_BBSIM="y"
     DEPLOY_K8S="y"
     VOLTHA_LOG_LEVEL="DEBUG"
-    CONFIG_SADIS="n"
+    CONFIG_SADIS="external"
+    BBSIM_CFG="configs/bbsim-sadis-att.yaml"
     ROBOT_MISC_ARGS="${params.extraRobotArgs} -d $WORKSPACE/RobotLogs -e PowerSwitch"
   }
   stages {
diff --git a/jjb/pipeline/voltha-go-tests.groovy b/jjb/pipeline/voltha-go-tests.groovy
index f54af86..d1de2e9 100644
--- a/jjb/pipeline/voltha-go-tests.groovy
+++ b/jjb/pipeline/voltha-go-tests.groovy
@@ -23,7 +23,7 @@
     label "${params.buildNode}"
   }
   options {
-      timeout(time: 40, unit: 'MINUTES')
+      timeout(time: 60, unit: 'MINUTES')
   }
   environment {
     KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
@@ -36,7 +36,8 @@
     WITH_BBSIM="yes"
     DEPLOY_K8S="yes"
     VOLTHA_LOG_LEVEL="DEBUG"
-    CONFIG_SADIS="no"
+    CONFIG_SADIS="external"
+    BBSIM_CFG="configs/bbsim-sadis-att.yaml"
     ROBOT_MISC_ARGS="${params.extraRobotArgs} -d $WORKSPACE/RobotLogs -e PowerSwitch"
     KARAF_HOME="${params.karafHome}"
     DIAGS_PROFILE="VOLTHA_PROFILE"
@@ -90,6 +91,7 @@
              export WITH_IGMP=no
              export WITH_EAPOL=no
              export WITH_RADIUS=no
+             export BBSIM_CFG="configs/bbsim-sadis-dt.yaml"
            fi
 
            EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags} "
diff --git a/jjb/pipeline/voltha-nightly-tests-bbsim.groovy b/jjb/pipeline/voltha-nightly-tests-bbsim.groovy
index 7a9b72a..ee337e8 100644
--- a/jjb/pipeline/voltha-nightly-tests-bbsim.groovy
+++ b/jjb/pipeline/voltha-nightly-tests-bbsim.groovy
@@ -23,7 +23,7 @@
     label "${params.buildNode}"
   }
   options {
-      timeout(time: 60, unit: 'MINUTES')
+      timeout(time: 90, unit: 'MINUTES')
   }
   environment {
     KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
diff --git a/jjb/pipeline/voltha-physical-soak-dt-tests.groovy b/jjb/pipeline/voltha-physical-soak-dt-tests.groovy
index c91a5fd..e08e92f 100644
--- a/jjb/pipeline/voltha-physical-soak-dt-tests.groovy
+++ b/jjb/pipeline/voltha-physical-soak-dt-tests.groovy
@@ -151,7 +151,7 @@
       steps {
         sh """
         mkdir -p $ROBOT_LOGS_DIR
-        if [ "${params.testType}" == "Failure" ]; then
+        if [ "${params.testType}" == "Dataplane" ]; then
            export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
            make -C $WORKSPACE/voltha/voltha-system-tests voltha-dt-test || true
         fi
diff --git a/jjb/pipeline/voltha-scale-test.groovy b/jjb/pipeline/voltha-scale-test.groovy
index ad25bde..ee224d4 100644
--- a/jjb/pipeline/voltha-scale-test.groovy
+++ b/jjb/pipeline/voltha-scale-test.groovy
@@ -106,7 +106,10 @@
       steps {
         checkout([
           $class: 'GitSCM',
-          userRemoteConfigs: [[ url: "https://gerrit.opencord.org/kind-voltha", ]],
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/kind-voltha",
+            refspec: "${kindVolthaChange}"
+          ]],
           branches: [[ name: "master", ]],
           extensions: [
             [$class: 'WipeWorkspace'],
@@ -114,21 +117,16 @@
             [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
           ],
         ])
-        script {
-          sh(script:"""
-          if [ '${kindVolthaChange}' != '' ] ; then
-          cd $WORKSPACE/kind-voltha;
-          git fetch https://gerrit.opencord.org/kind-voltha ${kindVolthaChange} && git checkout FETCH_HEAD
-          fi
-          """)
-        }
       }
     }
     stage('Clone voltha-system-tests') {
       steps {
         checkout([
           $class: 'GitSCM',
-          userRemoteConfigs: [[ url: "https://gerrit.opencord.org/voltha-system-tests", ]],
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/voltha-system-tests",
+            refspec: "${volthaSystemTestsChange}"
+          ]],
           branches: [[ name: "${release}", ]],
           extensions: [
             [$class: 'WipeWorkspace'],
@@ -136,14 +134,6 @@
             [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
           ],
         ])
-        script {
-          sh(script:"""
-            if [ '${volthaSystemTestsChange}' != '' ] ; then
-              cd $WORKSPACE/voltha-system-tests;
-              git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
-            fi
-            """)
-        }
       }
     }
     stage('Deploy common infrastructure') {
diff --git a/jjb/pipeline/voltha-system-test-bbsim.groovy b/jjb/pipeline/voltha-system-test-bbsim.groovy
index 7c4ceba..b81f670 100644
--- a/jjb/pipeline/voltha-system-test-bbsim.groovy
+++ b/jjb/pipeline/voltha-system-test-bbsim.groovy
@@ -37,7 +37,8 @@
     WITH_BBSIM="y"
     DEPLOY_K8S="y"
     VOLTHA_LOG_LEVEL="DEBUG"
-    CONFIG_SADIS="y"
+    CONFIG_SADIS="external"
+    BBSIM_CFG="configs/bbsim-sadis-att.yaml"
     ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
   }
 
diff --git a/jjb/voltha-e2e.yaml b/jjb/voltha-e2e.yaml
index bf2ed71..26690cb 100644
--- a/jjb/voltha-e2e.yaml
+++ b/jjb/voltha-e2e.yaml
@@ -230,6 +230,8 @@
     name: 'verify_{project}_sanity-test{name-extension}'
     override-branch: '$GERRIT_BRANCH'
     sandbox: true
+    volthaSystemTestsChange: ''
+    kindVolthaChange: ''
 
     description: |
       <!-- Managed by Jenkins Job Builder -->
@@ -253,11 +255,6 @@
           description: 'Name of the Jenkins node to run the job on'
 
       - string:
-          name: manifestUrl
-          default: '{gerrit-server-url}/{voltha-test-manifest-repo}'
-          description: 'URL to the repo manifest'
-
-      - string:
           name: branch
           default: '{override-branch}'
           description: 'Name of the branch to use'
@@ -268,20 +265,25 @@
           description: 'Name of the Gerrit project'
 
       - string:
-          name: gerritChangeNumber
-          default: '$GERRIT_CHANGE_NUMBER'
-          description: 'Changeset number in Gerrit'
-
-      - string:
-          name: gerritPatchsetNumber
-          default: '$GERRIT_PATCHSET_NUMBER'
-          description: 'PatchSet number in Gerrit'
+          name: gerritRefspec
+          default: '$GERRIT_REFSPEC'
+          description: 'PatchSet REFSPEC in Gerrit, example value: "refs/changes/79/18779/13"'
 
       - string:
           name: extraHelmFlags
           default: ''
           description: 'Helm flags to pass to ./voltha up'
 
+      - string:
+          name: volthaSystemTestsChange
+          default: '{volthaSystemTestsChange}'
+          description: 'Download a change for gerrit in the voltha-system-tests repo, example value: "refs/changes/79/18779/13"'
+
+      - string:
+          name: kindVolthaChange
+          default: '{kindVolthaChange}'
+          description: 'Download a change for gerrit in the kind-voltha repo, example value: "refs/changes/32/19132/1"'
+
     project-type: pipeline
     concurrent: true