SEBA-589 creating service upgrade verify test
Change-Id: I2b79c7117e34b495d3e792a5cbb3d9c3c3f8c9be
diff --git a/jjb/pipeline/xos-service-upgrade.groovy b/jjb/pipeline/xos-service-upgrade.groovy
new file mode 100644
index 0000000..e8df696
--- /dev/null
+++ b/jjb/pipeline/xos-service-upgrade.groovy
@@ -0,0 +1,197 @@
+// 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.
+
+// chart-api-test-helm.groovy
+// Checks functionality of the helm-chart, without overriding the version/tag used
+
+pipeline {
+
+ /* no label, executor is determined by JJB */
+ agent {
+ label "${params.executorNode}"
+ }
+
+ stages {
+
+ stage('repo') {
+ steps {
+ checkout(changelog: false, \
+ poll: false,
+ scm: [$class: 'RepoScm', \
+ manifestRepositoryUrl: "${params.manifestUrl}", \
+ manifestBranch: "${params.manifestBranch}", \
+ currentBranch: true, \
+ destinationDir: 'cord', \
+ forceSync: true,
+ resetFirst: true, \
+ quiet: true, \
+ jobs: 4, \
+ showAllChanges: true] \
+ )
+ }
+ }
+
+ 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('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 /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);
+ }
+ }
+ }
+ }
+ }
+
+ stage('helm') {
+ steps {
+ sh '''
+ helm init
+ sleep 60
+ helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
+ '''
+ }
+ }
+
+ stage('Install XOS w/Service') {
+ steps {
+ sh """
+ #!/usr/bin/env bash
+ set -eu -o pipefail
+
+ pushd cord/helm-charts
+ helm dep update xos-core
+ helm install xos-core -n xos-core
+
+ git clone https://gerrit.opencord.org/helm-repo-tools
+ helm-repo-tools/wait_for_pods.sh
+
+ #install service
+ helm dep update xos-services/${gerritProject}
+ helm install xos-services/${gerritProject} -n ${gerritProject}
+ popd
+ """
+ }
+ }
+ stage('Verify') {
+ steps {
+ sh """
+ #!/usr/bin/env bash
+ set -ex -o pipefail
+ export DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos/VERSION)
+
+ #wait for xos-core and models to be loaded
+ timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
+ timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
+ http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq ".services[] | select(.name==\\"core\\").version"| grep -q \$DOCKER_TAG
+
+ ## get pod logs
+ for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
+ do
+ kubectl logs \$pod> $WORKSPACE/\$pod.log;
+ done
+ """
+ }
+ }
+
+ stage('Build/Install New Service') {
+ steps {
+ sh """
+ #!/usr/bin/env bash
+ set -eu -o pipefail
+ pushd $WORKSPACE/cord/orchestration/xos-services/${gerritProject}
+ export DOCKER_TAG=\$(cat VERSION)-test
+ export DOCKER_REPOSITORY=xosproject/
+ export DOCKER_BUILD_ARGS=--no-cache
+ cd $WORKSPACE/cord/orchestration/xos-services/${gerritProject}
+ echo "\$(cat VERSION)-test" > VERSION
+ make docker-build
+
+ #install newservice
+ cd $WORKSPACE/cord/helm-charts
+ helm upgrade --set image.tag=\$DOCKER_TAG \
+ --set image.pullPolicy=Never \
+ --recreate-pods ${gerritProject} xos-services/${gerritProject}
+ popd
+ """
+ }
+ }
+ stage('Verify Service Upgrade') {
+ steps {
+ sh """
+ #!/usr/bin/env bash
+ set -ex -o pipefail
+ DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos-services/${gerritProject}/VERSION)
+
+ #wait for xos-core and models to be loaded
+ timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"core\\").state'| grep -q present; do echo 'Waiting for Core to be loaded'; sleep 5; done"
+ timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").state'| grep -q present; do echo 'Waiting for New Service to be loaded'; sleep 5; done"
+ timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status | jq '.services[] | select(.name==\\"${gerritProject}\\").version'| grep -q \$DOCKER_TAG; do echo 'Waiting for New Service Version Check'; sleep 5; done"
+ ## get pod logs
+ for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
+ do
+ kubectl logs \$pod> $WORKSPACE/\$pod.log;
+ done || true
+ """
+ }
+ }
+ }
+ post {
+ always {
+ sh """
+ kubectl get pods --all-namespaces
+ kubectl describe pods
+ http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/dynamicload/load_status
+ echo "# removing helm deployments"
+ kubectl get pods
+ helm list
+
+ for hchart in \$(helm list -q);
+ do
+ echo "## Purging chart: \${hchart} ##"
+ helm delete --purge "\${hchart}"
+ done
+
+ sudo minikube delete
+ """
+ archiveArtifacts artifacts: '*.log'
+ step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, scottb@opennetworking.org", sendToIndividuals: false])
+
+ }
+ }
+}
diff --git a/jjb/verify/att-workflow-driver.yaml b/jjb/verify/att-workflow-driver.yaml
index 8cc1ed6..b2a7fa8 100644
--- a/jjb/verify/att-workflow-driver.yaml
+++ b/jjb/verify/att-workflow-driver.yaml
@@ -20,6 +20,8 @@
dependency-jobs: 'verify_att-workflow-driver_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_att-workflow-driver_sonarqube'
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_att-workflow-driver-unit-test'
- job-group:
name: 'publish-att-workflow-driver-jobs'
diff --git a/jjb/verify/exampleservice.yaml b/jjb/verify/exampleservice.yaml
index e9b1e63..819e4c4 100644
--- a/jjb/verify/exampleservice.yaml
+++ b/jjb/verify/exampleservice.yaml
@@ -38,3 +38,5 @@
name-extension: '-legacy'
dependency-jobs: 'verify_exampleservice_sonarqube'
pipeline_script: 'all-xos-api-test.groovy'
+
+
diff --git a/jjb/verify/fabric-crossconnect.yaml b/jjb/verify/fabric-crossconnect.yaml
index a515d26..ec79bba 100644
--- a/jjb/verify/fabric-crossconnect.yaml
+++ b/jjb/verify/fabric-crossconnect.yaml
@@ -20,7 +20,8 @@
dependency-jobs: 'verify_fabric-crossconnect_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_fabric-crossconnect_sonarqube'
-
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_fabric-crossconnect-unit-test'
- job-group:
name: 'publish-fabric-crossconnect-jobs'
jobs:
diff --git a/jjb/verify/fabric.yaml b/jjb/verify/fabric.yaml
index 70ccef0..978b931 100644
--- a/jjb/verify/fabric.yaml
+++ b/jjb/verify/fabric.yaml
@@ -20,6 +20,8 @@
dependency-jobs: 'verify_fabric_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_fabric_sonarqube'
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_fabric-unit-test'
- job-group:
name: 'publish-fabric-jobs'
diff --git a/jjb/verify/kubernetes-service.yaml b/jjb/verify/kubernetes-service.yaml
index ba8555e..68b4ddc 100644
--- a/jjb/verify/kubernetes-service.yaml
+++ b/jjb/verify/kubernetes-service.yaml
@@ -20,6 +20,8 @@
dependency-jobs: 'verify_kubernetes-service_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_kubernetes-service_sonarqube'
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_kubernetes-service-unit-test'
- job-group:
name: 'publish-kubernetes-service-jobs'
diff --git a/jjb/verify/olt-service.yaml b/jjb/verify/olt-service.yaml
index c5bbbb3..65f86a0 100644
--- a/jjb/verify/olt-service.yaml
+++ b/jjb/verify/olt-service.yaml
@@ -20,7 +20,8 @@
dependency-jobs: 'verify_olt-service_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_olt-service_sonarqube'
-
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_olt-service-unit-test'
- job-group:
name: 'publish-olt-service-jobs'
jobs:
diff --git a/jjb/verify/onos-service.yaml b/jjb/verify/onos-service.yaml
index 558d7ed..8cfda63 100644
--- a/jjb/verify/onos-service.yaml
+++ b/jjb/verify/onos-service.yaml
@@ -20,6 +20,8 @@
dependency-jobs: 'verify_onos-service_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_onos-service_sonarqube'
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_onos-service-unit-test'
- job-group:
name: 'publish-onos-service-jobs'
diff --git a/jjb/verify/rcord.yaml b/jjb/verify/rcord.yaml
index f9b3994..be27a70 100644
--- a/jjb/verify/rcord.yaml
+++ b/jjb/verify/rcord.yaml
@@ -20,6 +20,8 @@
dependency-jobs: 'verify_rcord_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_rcord_sonarqube'
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_rcord-unit-test'
- job-group:
name: 'publish-rcord-jobs'
diff --git a/jjb/verify/simpleexampleservice.yaml b/jjb/verify/simpleexampleservice.yaml
index 6cda297..709aa41 100644
--- a/jjb/verify/simpleexampleservice.yaml
+++ b/jjb/verify/simpleexampleservice.yaml
@@ -20,6 +20,8 @@
dependency-jobs: 'verify_simpleexampleservice_tag-collision'
- 'xos-unit-test':
dependency-jobs: 'verify_simpleexampleservice_sonarqube'
+ - 'xos-service-upgrade':
+ dependency-jobs: 'verify_simpleexampleservice-unit-test'
- job-group:
name: 'publish-simpleexampleservice-jobs'
diff --git a/jjb/xos-upgrade.yaml b/jjb/xos-upgrade.yaml
new file mode 100644
index 0000000..35aba14
--- /dev/null
+++ b/jjb/xos-upgrade.yaml
@@ -0,0 +1,63 @@
+---
+# CORD API tests using cord-tester
+
+- job-template:
+ id: xos-service-upgrade
+ name: 'verify_{project}_service-upgrade-test'
+ description: |
+ Created by {id} job-template from ci-management/jjb/xos-upgrade.yaml, using pipeline: xos-service-upgrade.groovy
+
+
+ triggers:
+ - cord-infra-gerrit-trigger-patchset:
+ gerrit-server-name: '{gerrit-server-name}'
+ project-regexp: '^{project}$'
+ branch-regexp: '{branch-regexp}'
+ file-include-regexp: '{api-test-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}'
+
+ parameters:
+ - string:
+ name: executorNode
+ default: 'ubuntu16.04-basebuild-4c-8g'
+ description: 'Name of the Jenkins node to run the job on'
+
+ - string:
+ name: manifestUrl
+ default: '{gerrit-server-url}/{cord-repo-manifest}'
+ description: 'URL to the repo manifest'
+
+ - string:
+ name: manifestBranch
+ 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
+
+ dsl: !include-raw-escape: pipeline/xos-service-upgrade.groovy