Merge "fixing xos-unit test jobs"
diff --git a/jjb/cord-test/mcord-build.yaml b/jjb/cord-test/mcord-build.yaml
index 0f01987..7500fde 100644
--- a/jjb/cord-test/mcord-build.yaml
+++ b/jjb/cord-test/mcord-build.yaml
@@ -17,6 +17,7 @@
          branch: 'cord-4.1'
          Jenkinsfile: 'Jenkinsfile.newBuildSystem'
 
+      # onf pod build job (mcord)
       - 'build_pod_manual':
          pod: 'onf-mcord-dev'
          pod_config: 'onlab-mcord-cavium-pod1.yml'
diff --git a/jjb/cord-test/rcord-build.yaml b/jjb/cord-test/rcord-build.yaml
index 20795d2..a81b76f 100644
--- a/jjb/cord-test/rcord-build.yaml
+++ b/jjb/cord-test/rcord-build.yaml
@@ -42,6 +42,14 @@
          Jenkinsfile: 'Jenkinsfile'
          fromBranch: 'cord-5.0'
 
+      # Flex POD1 build job for (rcord) - soak platform
+      - 'build_pod_manual':
+         pod: 'flex-pod1'
+         pod_config: 'flex-pod1.yml'
+         profile: 'rcord'
+         branch: 'cord-5.0'
+         Jenkinsfile: 'Jenkinsfile.newBuildSystem'
+
       # qct pod 1 test jobs
       - 'build_pod_test':
          pod: 'qct-pod1'
diff --git a/jjb/docs.yaml b/jjb/docs.yaml
index d3b6e05..17ae369 100644
--- a/jjb/docs.yaml
+++ b/jjb/docs.yaml
@@ -16,7 +16,6 @@
     # add repos that have documentation to the project list in both jobs
     jobs:
       - 'verify-documentation':
-          primary-docs-repo-regexp: '^docs$'
           other-docs-repos-regexp: '^(cord-tester|xos|xos-gui|xos-tosca)$'
           branch-regexp: '{modern-branches-regexp}'
 
@@ -76,20 +75,35 @@
     name: "verify-documentation"
 
     triggers:
-      # trigger on any change in docs repo
-      - cord-infra-gerrit-trigger-patchset:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: '{primary-docs-repo-regexp}'
-          branch-regexp: '{branch-regexp}'
-          file-include-regexp: '{all-files-regexp}'
+      - gerrit:
+          server-name: '{gerrit-server-name}'
           dependency-jobs: '{dependency-jobs}'
-      # trigger on only docs/* changes in other repos
-      - cord-infra-gerrit-trigger-patchset:
-          gerrit-server-name: '{gerrit-server-name}'
-          project-regexp: '{other-docs-repos-regexp}'
-          branch-regexp: '{branch-regexp}'
-          file-include-regexp: '{doc-files-regexp}'
-          dependency-jobs: '{dependency-jobs}'
+          silent-start: true
+          trigger-on:
+            - patchset-created-event:
+                exclude-drafts: true
+                exclude-trivial-rebase: false
+                exclude-no-code-change: true
+            - draft-published-event
+            - comment-added-contains-event:
+                comment-contains-value: '(?i)^.*recheck$'
+          projects:
+            - project-compare-type: PLAIN
+              project-pattern: 'docs'
+              branches:
+                - branch-compare-type: REG_EXP
+                  branch-pattern: '{branch-regexp}'
+              file-paths:
+                - compare-type: REG_EXP
+                  pattern: '{all-files-regexp}'
+            - project-compare-type: REG_EXP
+              project-pattern: '{other-docs-repos-regexp}'
+              branches:
+                - branch-compare-type: REG_EXP
+                  branch-pattern: '{branch-regexp}'
+              file-paths:
+                - compare-type: REG_EXP
+                  pattern: '{doc-files-regexp}'
 
     properties:
       - cord-infra-properties:
diff --git a/jjb/helm-api-test.yaml b/jjb/helm-api-test.yaml
index a9ec6a8..1e32c00 100644
--- a/jjb/helm-api-test.yaml
+++ b/jjb/helm-api-test.yaml
@@ -41,6 +41,21 @@
          default: '$GERRIT_BRANCH'
          description: 'Name of the repo branch to use'
 
+      - string:
+         name: gerritProject
+         default: '$GERRIT_PROJECT'
+         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'
+
     project-type: pipeline
     concurrent: true
 
diff --git a/jjb/lint.yaml b/jjb/lint.yaml
index 171c469..754f1fc 100644
--- a/jjb/lint.yaml
+++ b/jjb/lint.yaml
@@ -7,7 +7,6 @@
     id: verify-licensed
     name: 'verify_{project}_licensed'
     description: |
-      <!-- Managed by Jenkins Job Builder -->
       Created by verify-licensed job-template from ci-management/jjb/lint.yaml
 
     triggers:
@@ -50,7 +49,6 @@
     id: verify-ansible-lint
     name: 'verify_{project}_ansible-lint'
     description: |
-      <!-- Managed by Jenkins Job Builder -->
       Created by verify-ansible-lint job-template from ci-management/jjb/lint.yaml
 
     triggers:
@@ -93,7 +91,6 @@
     id: verify-helm-lint
     name: 'verify_{project}_helm-lint'
     description: |
-      <!-- Managed by Jenkins Job Builder -->
       Created by verify-helm-lint job-template from ci-management/jjb/lint.yaml
 
     triggers:
@@ -128,4 +125,8 @@
     concurrent: true
 
     builders:
+      - shell: |
+          helm init --client-only
+          helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
+
       - shell: !include-raw-escape: shell/helmlint.sh
diff --git a/jjb/pipeline/helm-api-test.groovy b/jjb/pipeline/helm-api-test.groovy
index c776510..3a31332 100644
--- a/jjb/pipeline/helm-api-test.groovy
+++ b/jjb/pipeline/helm-api-test.groovy
@@ -2,26 +2,20 @@
 
 pipeline {
 
-  parameters {
-    string(name:'executorNode', defaultValue:'invalid', description:'Name of the Jenkins node to run the job on')
-    string(name:'manifestUrl', defaultValue:'invalid', description:'URL to the repo manifest')
-    string(name:'manifestBranch', defaultValue:'master', description:'Name of the repo branch to use')
-  }
-
   /* no label, executor is determined by JJB */
   agent {
-    label '${params.executorNode}'
+    label "${params.executorNode}"
   }
 
   stages {
 
-    stage('checkout') {
+    stage('repo') {
       steps {
         checkout(changelog: false, \
           poll: false,
           scm: [$class: 'RepoScm', \
-            manifestRepositoryUrl: '${params.manifestUrl}', \
-            manifestBranch: '${params.manifestBranch}', \
+            manifestRepositoryUrl: "${params.manifestUrl}", \
+            manifestBranch: "${params.manifestBranch}", \
             currentBranch: true, \
             destinationDir: 'cord', \
             forceSync: true,
@@ -33,13 +27,27 @@
       }
     }
 
+    stage('patch') {
+      steps {
+        sh """
+           pushd cord
+           PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
+           repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
+           popd
+           """
+      }
+    }
+
     stage('prep') {
       parallel {
 
         stage('images') {
           steps {
-            sh 'cd cord/build; ./scripts/imagebuilder.py -f helm-charts/examples/test-images.yaml'
-
+            sh '''
+               pushd cord/build
+               ./scripts/imagebuilder.py -f ../helm-charts/examples/test-images.yaml
+               popd
+               '''
           }
         }
 
@@ -47,26 +55,24 @@
           steps {
             /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
             sh '''
-               export MINIKUBE_WANTUPDATENOTIFICATION=false;
-               export MINIKUBE_WANTREPORTERRORPROMPT=false;
-               export CHANGE_MINIKUBE_NONE_USER=true;
-               export MINIKUBE_HOME=$HOME;
-               mkdir -p $HOME/.kube || true;
-               touch $HOME/.kube/config;
-               export KUBECONFIG=$HOME/.kube/config;
-               minikube start --vm-driver=none;
-
-               chown -R $USER $HOME/.minikube;
-               chgrp -R $(id -g) $HOME/.minikube;
-
-               for i in {1..150}; do # timeout for 5 minutes
-                   ./kubectl get po &> /dev/null
-                   if [ $? -ne 1 ]; then
-                      break
-                  fi
-                  sleep 2
-               done
+               export MINIKUBE_WANTUPDATENOTIFICATION=false
+               export MINIKUBE_WANTREPORTERRORPROMPT=false
+               export CHANGE_MINIKUBE_NONE_USER=true
+               export MINIKUBE_HOME=$HOME
+               mkdir -p $HOME/.kube || true
+               touch $HOME/.kube/config
+               export KUBECONFIG=$HOME/.kube/config
+               sudo -E /usr/bin/minikube start --vm-driver=none
                '''
+            script {
+              timeout(3) {
+                waitUntil {
+                  sleep 5
+                  def kc_ret = sh script: "kubectl get po", returnStatus: true
+                  return (kc_ret == 0);
+                }
+              }
+            }
           }
         }
       }
@@ -74,39 +80,57 @@
 
     stage('helm') {
       steps {
-        sh 'helm init && sleep 60'
+        sh '''
+           helm init
+           sleep 60
+           helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
+           '''
       }
     }
 
     stage('xos') {
       steps {
         sh '''
-           cd cord/build/helm-charts;
-           helm dep up xos-core;
-           helm install -f examples/test-values.yaml -f examples/candidate-tag-values.yaml xos-core -n xos-core;
+           pushd cord/helm-charts
+           helm dep up xos-core
+           helm install -f examples/test-values.yaml -f examples/candidate-tag-values.yaml xos-core -n xos-core
            sleep 60
+           helm status xos-core
+           popd
            '''
       }
     }
 
     stage('test'){
       steps {
-        sh 'helm test xos-core'
-        sh 'kubectl logs xos-core-api-test'
-      }
-      post {
-        always {
-          archive '/tmp/helm_test_xos_core_logs_*/**'
+        sh '''
+           helm test xos-core
+           mkdir -p ./RobotLogs;
+           cp /tmp/helm_test_xos_core_logs_*/* ./RobotLogs
+           '''
 
-        }
+        step([$class: 'RobotPublisher',
+             disableArchiveOutput: false,
+             logFileName: 'RobotLogs/log*.html',
+             otherFiles: '',
+             outputFileName: 'RobotLogs/output*.xml',
+             outputPath: '.',
+             passThreshold: 100,
+             reportFileName: 'RobotLogs/report*.html',
+             unstableThreshold: 0]);
       }
     }
   }
 
   post {
     always {
-      sh 'kubectl delete pod xos-core-api-test'
-      sh 'helm delete --purge xos-core'
+      sh '''
+         kubectl get pods --all-namespaces
+         helm list
+         kubectl logs xos-core-api-test
+         kubectl delete pod xos-core-api-test
+         helm delete --purge xos-core
+         '''
       deleteDir()
     }
   }
diff --git a/jjb/shell/helmlint.sh b/jjb/shell/helmlint.sh
index 16184c2..27cf676 100755
--- a/jjb/shell/helmlint.sh
+++ b/jjb/shell/helmlint.sh
@@ -34,7 +34,7 @@
   chartdir=$(dirname "${chart}")
 
   # update requirements if it exists. Skip voltha as it has non-clean reqirements
-  if [ "${chartdir}" != "./voltha" ] && [ -f "${chartdir}/requirements.yaml" ]; then
+  if [[ ! $chartdir =~ voltha$ ]] && [ -f "${chartdir}/requirements.yaml" ]; then
     helm dependency update "${chartdir}"
   fi
 
diff --git a/jjb/verify/xos.yaml b/jjb/verify/xos.yaml
index 5f3e911..235d1fa 100644
--- a/jjb/verify/xos.yaml
+++ b/jjb/verify/xos.yaml
@@ -17,3 +17,6 @@
           dependency-jobs: 'verify_xos_licensed'
       - 'api-test':
           dependency-jobs: 'verify_xos_sonarqube'
+      - 'helm-api-test':
+          dependency-jobs: 'verify_xos_sonarqube'
+
diff --git a/packer/provision/basebuild.sh b/packer/provision/basebuild.sh
index f7aba2b..d5a809a 100644
--- a/packer/provision/basebuild.sh
+++ b/packer/provision/basebuild.sh
@@ -70,6 +70,7 @@
         python-pip \
         python-urllib3 \
         ruby \
+        socat \
         ssh \
         sshpass \
         zip