[CORD-2966]
helm-api-test job for containerized testing of xos-core

Change-Id: I314502a2edec41de5f08d3e430ecfa4aeb0cf6cc
diff --git a/jjb/helm-api-test.yaml b/jjb/helm-api-test.yaml
new file mode 100644
index 0000000..45e8c5e
--- /dev/null
+++ b/jjb/helm-api-test.yaml
@@ -0,0 +1,33 @@
+---
+# CORD API tests using helm
+
+- job-template:
+    id: helm-api-test
+    name: 'verify_{project}_helm-api-test'
+    description: |
+      Created by helm-api-test job-template from ci-management/jjb/helm-api-test.yaml
+
+    triggers:
+      - cord-infra-gerrit-trigger-patchset:
+          gerrit-server-name: '{gerrit-server-name}'
+          project-regexp: '^{project}$'
+          branch-regexp: '{branch-regexp}'
+          file-include-regexp: '{all-files-regexp}'
+          dependency-jobs: '{dependency-jobs}'
+
+    properties:
+      - cord-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+          artifact-num-to-keep: '{artifact-num-to-keep}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '60'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    node: 'ubuntu16.04-basebuild-4c-8g'
+    project-type: pipeline
+    concurrent: true
+
+    dsl: !include-raw-escape: pipeline/helm-api-test.groovy
+
diff --git a/jjb/pipeline/helm-api-test.groovy b/jjb/pipeline/helm-api-test.groovy
new file mode 100644
index 0000000..68f4f6f
--- /dev/null
+++ b/jjb/pipeline/helm-api-test.groovy
@@ -0,0 +1,89 @@
+/* helm-api-test pipeline */
+
+pipeline {
+
+  /* no label, executor is determined by JJB */
+  agent {
+    label ''
+  }
+
+  stages {
+
+    stage('prep') {
+      parallel {
+
+        stage('images') {
+          steps {
+            sh 'cd cord/build; ./scripts/imagebuilder.py -f helm-charts/examples/test-images.yaml'
+
+          }
+        }
+
+        stage('minikube') {
+          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;
+               sudo -E minikube start --vm-driver=none;
+
+               sudo chown -R $USER $HOME/.minikube;
+               sudo 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
+               '''
+          }
+        }
+      }
+    }
+
+    stage('helm') {
+      steps {
+        sh 'helm init && sleep 60'
+      }
+    }
+
+    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;
+           sleep 60
+           '''
+      }
+    }
+
+    stage('test'){
+      steps {
+        sh 'helm test xos-core'
+        sh 'kubectl logs xos-core-api-test'
+      }
+      post {
+        always {
+          archive '/tmp/helm_test_xos_core_logs_*/**'
+
+        }
+      }
+    }
+  }
+
+  post {
+    always {
+      sh 'kubectl delete pod xos-core-api-test'
+      sh 'helm delete --purge xos-core'
+      deleteDir()
+    }
+  }
+}
diff --git a/jjb/verify/helm-charts.yaml b/jjb/verify/helm-charts.yaml
index 621168b..23ade64 100644
--- a/jjb/verify/helm-charts.yaml
+++ b/jjb/verify/helm-charts.yaml
@@ -17,4 +17,6 @@
           dependency-jobs: 'verify_helm-charts_licensed'
       - 'verify-helm-lint':
           dependency-jobs: 'verify_helm-charts_sonarqube'
+      - 'helm-api-test':
+          dependency-jobs: 'verify_helm-charts_helm-lint'