blob: 18b3fb82ac1612c7d4cdad12962239f135555963 [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
90 git clone https://gerrit.opencord.org/helm-repo-tools
91 helm-repo-tools/wait_for_pods.sh
Zack Williamsa26fc9d2018-09-18 16:49:01 -070092
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070093 helm dep up xos-core
Kailash2caf2b02019-05-01 14:50:47 -070094 helm install --set images.xos_core.tag:master xos-core -n xos-core
Kailash Khalasic00ac4d2018-08-20 09:21:48 -070095
Kailashf05f3a12018-12-17 09:06:28 -080096 helm dep update xos-profiles/seba-services
Kailashbe13fe72019-02-04 10:50:48 -080097 helm install xos-profiles/seba-services
Kailashf05f3a12018-12-17 09:06:28 -080098 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
99 helm dep update workflows/att-workflow
Kailash8fb3b692019-02-06 12:07:36 -0800100 helm install workflows/att-workflow --set att-workflow-driver.kafkaService=cord-kafka -n att-workflow
Kailashf05f3a12018-12-17 09:06:28 -0800101
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700102 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700103
104 # wait for services to load
Luca Prete2ae90132018-12-13 17:14:01 -0800105 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700106 sleep 300
107 echo "# Checking helm deployments"
108 kubectl get pods
109 helm list
110
111 for hchart in \$(helm list -q);
112 do
113 echo "## 'helm status' for chart: \${hchart} ##"
114 helm status "\${hchart}"
115 done
Kailashbe13fe72019-02-04 10:50:48 -0800116 popd
117
118 """
119 }
120 }
Kailash2caf2b02019-05-01 14:50:47 -0700121
122 stage('install profile') {
123 when { expression { return params.InstallService } }
124 steps {
125 sh """
126 #!/usr/bin/env bash
127 set -eu -o pipefail
128
129 pushd cord/helm-charts
130
131 helm dep update ${params.helmChart}
132 helm install --set image.tag=master ${params.helmChart} --set att-workflow-driver.kafkaService=cord-kafka -n ${params.service}
133
134 helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
135
136 # wait for services to load
137 JOBS_TIMEOUT=900 ./helm-repo-tools/wait_for_jobs.sh
138 sleep 300
139 echo "# Checking helm deployments"
140 kubectl get pods
141 helm list
142
143 for hchart in \$(helm list -q);
144 do
145 echo "## 'helm status' for chart: \${hchart} ##"
146 helm status "\${hchart}"
147 done
148 popd
149
150 """
151 }
152 }
153
Kailash866e14f2019-02-22 10:43:23 -0800154 stage('test') {
Kailashbe13fe72019-02-04 10:50:48 -0800155 steps {
156 sh """
157 #!/usr/bin/env bash
158 set -eu -o pipefail
Kailashf73ff1c2019-03-06 14:00:51 -0800159 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 -0800160 pushd cord/test/cord-tester/src/test/cord-api/
161 source setup_venv.sh
Kailashc47d9c52019-03-05 13:10:47 -0800162 cd Tests/${params.TestDir}
Kailash866e14f2019-02-22 10:43:23 -0800163 ${params.TestCommand} || true
Kailashbe13fe72019-02-04 10:50:48 -0800164 popd
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700165 """
166 }
167 }
168 }
Kailash2caf2b02019-05-01 14:50:47 -0700169
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700170 post {
171 always {
Kailashf73ff1c2019-03-06 14:00:51 -0800172 sh """
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700173 kubectl get pods --all-namespaces
174
Kailash2caf2b02019-05-01 14:50:47 -0700175 ## get pod logs
176 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
177 do
178 kubectl logs \$pod> $WORKSPACE/\$pod.log;
179 done || true
180
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700181 # copy robot logs
182 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailashc47d9c52019-03-05 13:10:47 -0800183 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/${params.TestDir}/Log/*ml ./RobotLogs
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700184 echo "# removing helm deployments"
185 kubectl get pods
186 helm list
187
188 for hchart in \$(helm list -q);
189 do
190 echo "## Purging chart: \${hchart} ##"
191 helm delete --purge "\${hchart}"
192 done
193
194 sudo minikube delete
Kailashf73ff1c2019-03-06 14:00:51 -0800195 """
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700196 step([$class: 'RobotPublisher',
197 disableArchiveOutput: false,
198 logFileName: 'RobotLogs/log*.html',
199 otherFiles: '',
200 outputFileName: 'RobotLogs/output*.xml',
201 outputPath: '.',
202 passThreshold: 100,
203 reportFileName: 'RobotLogs/report*.html',
204 unstableThreshold: 0]);
Kailash2caf2b02019-05-01 14:50:47 -0700205 archiveArtifacts artifacts: '*.log'
206 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.notificationEmail}", sendToIndividuals: false])
Kailash Khalasic00ac4d2018-08-20 09:21:48 -0700207
208 }
209 }
210}