Merge "Using custom chart in multi-stack scale pipeline Escaping $bbsim variable when collecting logs Running the multi-stack with 512 ONU x 2 OLTs x 2 stacks"
diff --git a/jjb/cord-test/voltha.yaml b/jjb/cord-test/voltha.yaml
index 1434069..cc6874c 100644
--- a/jjb/cord-test/voltha.yaml
+++ b/jjb/cord-test/voltha.yaml
@@ -412,7 +412,8 @@
           Jenkinsfile: 'Jenkinsfile-voltha-test'
           profile: '1T4GEM'
 
-     # Demo pod with xgs-pon olt/onu - master 1T8GEM tech profile and openonu go and timer based job
+     # Demo pod with xgs-pon olt/onu - master 1T4GEM tech profile and openonu go and timer based job
+     # Name extension says DT but is actually an ATT test, dont' want to change all the file names
       - 'build_voltha_pod_release_timer':
           build-node: 'menlo-demo-pod'
           config-pod: 'onf-demo-pod-openonugo'
@@ -421,28 +422,27 @@
           num-of-onos: '3'
           num-of-atomix: '3'
           name-extension: '_DT_openonugo'
-          work-flow: 'DT'
           test-repo: 'voltha-system-tests'
           Jenkinsfile: 'Jenkinsfile-voltha-build'
           configurePod: true
-          profile: '1T8GEM'
+          profile: '1T4GEM'
           in-band-management: true
           time: '10'
 
 
-      # Demo POD test job - master versions, uses 1T8GEM tech profile and openonu go on voltha branch
+      # Demo POD test job - master versions, uses 1T4GEM tech profile and openonu go on voltha branch
+      # Name extension says DT but is actually an ATT test, dont' want to change all the file names
       - 'build_voltha_pod_test':
           build-node: 'menlo-demo-pod'
           config-pod: 'onf-demo-pod-openonugo'
           name-extension: '_DT_openonugo'
-          work-flow: 'DT'
           release: 'master'
           branch: 'master'
           test-repo: 'voltha-system-tests'
-          profile: '1T8GEM'
+          profile: '1T4GEM'
           in-band-management: true
           power-switch: True
-          pipeline-script: 'voltha-dt-physical-functional-tests-openonu-go.groovy'
+          pipeline-script: 'voltha-physical-functional-tests-openonu-go.groovy'
 
       # Menlo DEMO-POD - Default TechProfile - manual build job
       - 'build_pod_manual':
diff --git a/jjb/pipeline/voltha-physical-functional-tests-openonu-go.groovy b/jjb/pipeline/voltha-physical-functional-tests-openonu-go.groovy
new file mode 100644
index 0000000..6850bc2
--- /dev/null
+++ b/jjb/pipeline/voltha-physical-functional-tests-openonu-go.groovy
@@ -0,0 +1,273 @@
+// 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 {
+  // Need this so that deployment_config has global scope when it's read later
+  deployment_config = null
+}
+
+pipeline {
+  /* no label, executor is determined by JJB */
+  agent {
+    label "${params.buildNode}"
+  }
+  options {
+    timeout(time: 380, unit: 'MINUTES')
+  }
+
+  environment {
+    KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
+    VOLTCONFIG="$HOME/.volt/config-minimal"
+    PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+  }
+  stages {
+    stage('Clone kind-voltha') {
+      steps {
+        step([$class: 'WsCleanup'])
+        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('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('Clone cord-tester') {
+      steps {
+        checkout([
+          $class: 'GitSCM',
+          userRemoteConfigs: [[
+            url: "https://gerrit.opencord.org/cord-tester",
+            refspec: "${cordTesterChange}"
+          ]],
+          branches: [[ name: "master", ]],
+          extensions: [
+            [$class: 'WipeWorkspace'],
+            [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"],
+            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
+          ],
+        ])
+      }
+    }
+    stage('Download All the VOLTHA repos') {
+      when {
+        expression {
+          return "${branch}" == 'master';
+        }
+      }
+      steps {
+       checkout(changelog: true,
+         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]
+         )
+      }
+    }
+    stage ('Initialize') {
+      steps {
+        sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
+        script {
+          deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
+        }
+        sh returnStdout: false, script: """
+        mkdir -p $WORKSPACE/bin
+        bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
+        cd $WORKSPACE
+        if [ "${params.branch}" != "master" ]; then
+           cd $WORKSPACE/kind-voltha
+           source releases/${params.branch}
+        else
+           VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
+        fi
+
+        HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
+        HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
+        if [ \$HOSTARCH == "x86_64" ]; then
+            HOSTARCH="amd64"
+        fi
+        curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH}
+        chmod 755 $WORKSPACE/bin/voltctl
+        voltctl version --clientonly
+
+        if [ "${params.branch}" == "master" ]; then
+        # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
+        # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
+        # We should change this. In the meantime here is a workaround.
+           set +e
+
+        # Remove noise from voltha-core logs
+           voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
+           voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
+        # Remove noise from openolt logs
+           voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
+           voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
+           voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
+        fi
+        """
+      }
+    }
+
+    stage('Functional Tests') {
+      environment {
+        ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
+        ROBOT_FILE="Voltha_PODTests.robot"
+        ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests"
+      }
+      steps {
+        sh """
+        cd $WORKSPACE/kind-voltha/scripts
+        ./log-collector.sh > /dev/null &
+        ./log-combine.sh > /dev/null &
+
+        mkdir -p $ROBOT_LOGS_DIR
+        if ( ${powerSwitch} ); then
+             export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanity -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
+        else
+             export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanity -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
+        fi
+        make -C $WORKSPACE/voltha-system-tests voltha-test || true
+        """
+      }
+    }
+
+    stage('Dataplane Tests') {
+      environment {
+        ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
+        ROBOT_FILE="Voltha_PODTests.robot"
+        ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DataplaneTests"
+      }
+      steps {
+        sh """
+        mkdir -p $ROBOT_LOGS_DIR
+        export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplane -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-system-tests voltha-test || true
+        """
+      }
+    }
+
+  }
+  post {
+    always {
+      sh returnStdout: false, script: '''
+      set +e
+      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
+      kubectl get pods -n voltha -o wide
+      kubectl get pods -o wide
+
+      sleep 60 # Wait for log-collector and log-combine to complete
+
+      # Clean up "announcer" pod used by the tests if present
+      kubectl delete pod announcer || true
+
+      ## Pull out errors from log files
+      extract_errors_go() {
+        echo
+        echo "Error summary for $1:"
+        grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
+        echo
+      }
+
+      extract_errors_python() {
+        echo
+        echo "Error summary for $1:"
+        grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
+        echo
+      }
+
+      extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
+      extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
+      extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
+      extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
+      extract_errors_python onos >> $WORKSPACE/error-report.log
+
+      gzip error-report.log || true
+      rm error-report.log || true
+
+      cd $WORKSPACE/kind-voltha/scripts/logger/combined/
+      tar czf $WORKSPACE/container-logs.tgz *
+      rm * || true
+
+      cd $WORKSPACE
+      gzip *-combined.log || true
+      rm *-combined.log || true
+
+      # collect ETCD cluster logs
+      mkdir -p $WORKSPACE/etcd
+      printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I% bash -c "kubectl logs % > $WORKSPACE/etcd/%.log"
+      '''
+      script {
+        deployment_config.olts.each { olt ->
+          sh returnStdout: false, script: """
+          sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
+          sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log  # Remove escape sequences
+          sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
+          sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log  # Remove escape sequences
+          sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/startup.log $WORKSPACE/startup-${olt.sship}.log || true
+          sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
+          sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt_process_watchdog.log $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true
+          sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
+          """
+        }
+      }
+      step([$class: 'RobotPublisher',
+        disableArchiveOutput: false,
+        logFileName: '**/log*.html',
+        otherFiles: '',
+        outputFileName: '**/output*.xml',
+        outputPath: 'RobotLogs',
+        passThreshold: 100,
+        reportFileName: '**/report*.html',
+        unstableThreshold: 0
+        ]);
+      archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
+    }
+    unstable {
+      step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
+    }
+  }
+}
diff --git a/jjb/verify/ntt-workflow-driver.yaml b/jjb/verify/ntt-workflow-driver.yaml
new file mode 100644
index 0000000..ad0f9e3
--- /dev/null
+++ b/jjb/verify/ntt-workflow-driver.yaml
@@ -0,0 +1,29 @@
+---
+# verification jobs for 'ntt-workflow-driver' repo
+
+- project:
+    name: ntt-workflow-driver
+    project: '{name}'
+
+    jobs:
+      - 'verify-ntt-workflow-driver-jobs':
+          branch-regexp: '{all-branches-regexp}'
+      - 'publish-ntt-workflow-driver-jobs'
+
+- job-group:
+    name: 'verify-ntt-workflow-driver-jobs'
+    jobs:
+      - 'verify-licensed'
+      - 'tag-collision-reject':
+          dependency-jobs: 'verify_ntt-workflow-driver_licensed'
+      - 'xos-unit-test':
+          dependency-jobs: 'verify_ntt-workflow-driver_tag-collision'
+      - 'xos-service-upgrade':
+          dependency-jobs: 'verify_ntt-workflow-driver-unit-test'
+
+- job-group:
+    name: 'publish-ntt-workflow-driver-jobs'
+    jobs:
+      - 'docker-publish':
+          docker-repo: 'xosproject'
+          dependency-jobs: 'version-tag'
diff --git a/jjb/verify/voltha-epononu-adapter.yaml b/jjb/verify/voltha-epononu-adapter.yaml
new file mode 100644
index 0000000..f0e8cda
--- /dev/null
+++ b/jjb/verify/voltha-epononu-adapter.yaml
@@ -0,0 +1,30 @@
+---
+# verification jobs for 'voltha-epononu-adapter' repo
+
+- project:
+    name: voltha-epononu-adapter
+    project: '{name}'
+
+    jobs:
+      - 'verify-voltha-epononu-adapter-jobs':
+          branch-regexp: '{all-branches-regexp}'
+      - 'publish-voltha-epononu-adapter-jobs':
+          branch-regexp: '{all-branches-regexp}'
+
+- job-group:
+    name: 'verify-voltha-epononu-adapter-jobs'
+    jobs:
+      - 'verify-licensed'
+      - 'tag-collision-reject':
+          dependency-jobs: 'verify_voltha-epononu-adapter_licensed'
+      - 'make-unit-test':
+          unit-test-targets: 'test'
+          unit-test-keep-going: 'true'
+
+- job-group:
+    name: 'publish-voltha-epononu-adapter-jobs'
+    jobs:
+      - 'docker-publish':
+          build-timeout: 30
+          docker-repo: 'voltha'
+          dependency-jobs: 'version-tag'