blob: 7ddccad2caad5f9337c1d9e93690ffd69e1818b0 [file] [log] [blame]
Kailash Khalasic00ac4d2018-08-20 09:21:48 -07001// Copyright 2017-present Open Networking Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// chart-api-test-helm.groovy
16// Checks functionality of the helm-chart, without overriding the version/tag used
17
18pipeline {
19
20 /* no label, executor is determined by JJB */
21 agent {
22 label "${params.executorNode}"
23 }
24
25 stages {
26
27 stage('repo') {
28 steps {
29 checkout(changelog: false, \
30 poll: false,
31 scm: [$class: 'RepoScm', \
32 manifestRepositoryUrl: "${params.manifestUrl}", \
Kailash Khalasif55eba82018-08-21 13:02:38 -070033 manifestBranch: "${params.manifestBranch}", \
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070034 currentBranch: true, \
35 destinationDir: 'cord', \
36 forceSync: true,
37 resetFirst: true, \
38 quiet: true, \
39 jobs: 4, \
40 showAllChanges: true] \
41 )
42 }
43 }
44
45 stage('minikube') {
46 steps {
47 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
48 sh '''
49 export MINIKUBE_WANTUPDATENOTIFICATION=false
50 export MINIKUBE_WANTREPORTERRORPROMPT=false
51 export CHANGE_MINIKUBE_NONE_USER=true
52 export MINIKUBE_HOME=$HOME
53 mkdir -p $HOME/.kube || true
54 touch $HOME/.kube/config
55 export KUBECONFIG=$HOME/.kube/config
56 sudo -E /usr/bin/minikube start --vm-driver=none
57 '''
58 script {
59 timeout(3) {
60 waitUntil {
61 sleep 5
62 def kc_ret = sh script: "kubectl get po", returnStatus: true
63 return (kc_ret == 0);
64 }
65 }
66 }
67 }
68 }
69
70 stage('helm') {
71 steps {
72 sh '''
73 helm init
74 sleep 60
75 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
76 '''
77 }
78 }
79
Kailash2caf2b02019-05-01 14:50:47 -070080 stage('install xos') {
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070081 steps {
82 sh """
83 #!/usr/bin/env bash
84 set -eu -o pipefail
85
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070086 pushd cord/helm-charts
87
Zack Williamsa26fc9d2018-09-18 16:49:01 -070088 helm install -f examples/kafka-single.yaml --version 0.8.8 -n cord-kafka incubator/kafka
Luca Prete2ae90132018-12-13 17:14:01 -080089
Luca Prete2ae90132018-12-13 17:14:01 -080090 helm-repo-tools/wait_for_pods.sh
Zack Williamsa26fc9d2018-09-18 16:49:01 -070091
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070092 helm dep up xos-core
Kailashb06829d2019-05-02 14:44:57 -070093 helm install --set images.xos_core.tag=master xos-core -n xos-core
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070094
Kailashf05f3a12018-12-17 09:06:28 -080095 helm dep update xos-profiles/seba-services
Kailashbe13fe72019-02-04 10:50:48 -080096 helm install xos-profiles/seba-services
Kailashf05f3a12018-12-17 09:06:28 -080097 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
Kailashf05f3a12018-12-17 09:06:28 -080098
Kailashb06829d2019-05-02 14:44:57 -070099 sleep 60
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700100 echo "# Checking helm deployments"
101 kubectl get pods
102 helm list
103
104 for hchart in \$(helm list -q);
105 do
106 echo "## 'helm status' for chart: \${hchart} ##"
107 helm status "\${hchart}"
108 done
Kailashbe13fe72019-02-04 10:50:48 -0800109 popd
110
111 """
112 }
113 }
Kailash2caf2b02019-05-01 14:50:47 -0700114
115 stage('install profile') {
116 when { expression { return params.InstallService } }
117 steps {
118 sh """
119 #!/usr/bin/env bash
120 set -eu -o pipefail
121
122 pushd cord/helm-charts
123
124 helm dep update ${params.helmChart}
125 helm install --set image.tag=master ${params.helmChart} --set att-workflow-driver.kafkaService=cord-kafka -n ${params.service}
126
127 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
128
129 # wait for services to load
130 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
Kailashb06829d2019-05-02 14:44:57 -0700131 sleep 120
Kailash2caf2b02019-05-01 14:50:47 -0700132 echo "# Checking helm deployments"
133 kubectl get pods
134 helm list
135
136 for hchart in \$(helm list -q);
137 do
138 echo "## 'helm status' for chart: \${hchart} ##"
139 helm status "\${hchart}"
140 done
141 popd
142
143 """
144 }
145 }
146
Kailash866e14f2019-02-22 10:43:23 -0800147 stage('test') {
Kailashbe13fe72019-02-04 10:50:48 -0800148 steps {
149 sh """
150 #!/usr/bin/env bash
151 set -eu -o pipefail
Kailashf73ff1c2019-03-06 14:00:51 -0800152 export CORD_KAFKA_IP=\$(kubectl exec cord-kafka-0 -- ip a | grep -oE "([0-9]{1,3}\\.){3}[0-9]{1,3}\\b" | grep 172)
Kailashbe13fe72019-02-04 10:50:48 -0800153 pushd cord/test/cord-tester/src/test/cord-api/
154 source setup_venv.sh
Kailashc47d9c52019-03-05 13:10:47 -0800155 cd Tests/${params.TestDir}
Kailash866e14f2019-02-22 10:43:23 -0800156 ${params.TestCommand} || true
Kailashbe13fe72019-02-04 10:50:48 -0800157 popd
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700158 """
159 }
160 }
161 }
Kailash2caf2b02019-05-01 14:50:47 -0700162
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700163 post {
164 always {
Kailashf73ff1c2019-03-06 14:00:51 -0800165 sh """
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700166 kubectl get pods --all-namespaces
167
Kailash2caf2b02019-05-01 14:50:47 -0700168 ## get pod logs
169 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
170 do
171 kubectl logs \$pod> $WORKSPACE/\$pod.log;
172 done || true
173
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700174 # copy robot logs
175 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailashc47d9c52019-03-05 13:10:47 -0800176 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/${params.TestDir}/Log/*ml ./RobotLogs
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700177 echo "# removing helm deployments"
178 kubectl get pods
179 helm list
180
181 for hchart in \$(helm list -q);
182 do
183 echo "## Purging chart: \${hchart} ##"
184 helm delete --purge "\${hchart}"
185 done
186
187 sudo minikube delete
Kailashf73ff1c2019-03-06 14:00:51 -0800188 """
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700189 step([$class: 'RobotPublisher',
190 disableArchiveOutput: false,
191 logFileName: 'RobotLogs/log*.html',
192 otherFiles: '',
193 outputFileName: 'RobotLogs/output*.xml',
194 outputPath: '.',
195 passThreshold: 100,
196 reportFileName: 'RobotLogs/report*.html',
197 unstableThreshold: 0]);
Kailash2caf2b02019-05-01 14:50:47 -0700198 archiveArtifacts artifacts: '*.log'
199 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.notificationEmail}", sendToIndividuals: false])
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700200
201 }
202 }
203}