blob: dca5f16d385f96db5e90e6d990ef9f0e0812138e [file] [log] [blame]
Kailashc8170bb2019-03-26 10:06:55 -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}", \
33 manifestBranch: "${params.manifestBranch}", \
34 currentBranch: true, \
35 destinationDir: 'cord', \
36 forceSync: true,
37 resetFirst: true, \
38 quiet: true, \
39 jobs: 4, \
40 showAllChanges: true] \
41 )
42 }
43 }
44
Scott Baker17a3cb52019-03-28 14:35:01 -070045 stage('patch') {
46 steps {
47 sh '''
48 pushd cord
49 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
50 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
51 popd
52 '''
53 }
54 }
55
Kailashc8170bb2019-03-26 10:06:55 -070056 stage('minikube') {
57 steps {
58 /* see https://github.com/kubernetes/minikube/#linux-continuous-integration-without-vm-support */
59 sh '''
60 export MINIKUBE_WANTUPDATENOTIFICATION=false
61 export MINIKUBE_WANTREPORTERRORPROMPT=false
62 export CHANGE_MINIKUBE_NONE_USER=true
63 export MINIKUBE_HOME=$HOME
64 mkdir -p $HOME/.kube || true
65 touch $HOME/.kube/config
66 export KUBECONFIG=$HOME/.kube/config
67 sudo -E /usr/bin/minikube start --vm-driver=none
68 '''
69 script {
70 timeout(3) {
71 waitUntil {
72 sleep 5
73 def kc_ret = sh script: "kubectl get po", returnStatus: true
74 return (kc_ret == 0);
75 }
76 }
77 }
78 }
79 }
80
81 stage('helm') {
82 steps {
83 sh '''
84 helm init
85 sleep 60
86 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
87 '''
88 }
89 }
90
91 stage ('Build XOS Core and TestService') {
92 steps {
93 sh """
94 #!/usr/bin/env bash
95 set -eu -o pipefail
96
Scott Baker17a3cb52019-03-28 14:35:01 -070097 export DOCKER_REPOSITORY=xosproject/
98 export DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos/VERSION)
99
Kailashc8170bb2019-03-26 10:06:55 -0700100 cd $WORKSPACE/cord/orchestration/xos/containers/xos
101 make build
102 cd $WORKSPACE/cord/orchestration/xos/testservice
Scott Baker17a3cb52019-03-28 14:35:01 -0700103 make DOCKER_BUILD_ARGS=--no-cache docker-build
Kailashc8170bb2019-03-26 10:06:55 -0700104 """
105 }
106 }
107
108 stage('Install XOS w/TestService') {
109 steps {
110 sh """
111 #!/usr/bin/env bash
112 set -eu -o pipefail
113
Scott Baker17a3cb52019-03-28 14:35:01 -0700114 export DOCKER_TAG=\$(cat $WORKSPACE/cord/orchestration/xos/VERSION)
115
Kailashc8170bb2019-03-26 10:06:55 -0700116 pushd cord/helm-charts
117 helm dep update xos-core
Scott Baker17a3cb52019-03-28 14:35:01 -0700118 helm install --set images.xos_core.tag=\$DOCKER_TAG,images.xos_core.pullPolicy=Never xos-core -n xos-core
Kailashc8170bb2019-03-26 10:06:55 -0700119
120 git clone https://gerrit.opencord.org/helm-repo-tools
121 helm-repo-tools/wait_for_pods.sh
122
123 #install testservice
Kailashfe840382019-03-26 21:11:09 -0700124 cd $WORKSPACE/cord/orchestration/xos/testservice/helm-charts
Scott Baker17a3cb52019-03-28 14:35:01 -0700125 helm install --set testservice_synchronizerImage=xosproject/testservice-synchronizer:\$DOCKER_TAG \
126 --set imagePullPolicy=Never \
127 testservice -n testservice
Kailashc8170bb2019-03-26 10:06:55 -0700128 popd
129 """
130 }
131 }
132 stage('Wait for Core') {
133 steps {
134 sh """
Kailashfe840382019-03-26 21:11:09 -0700135 #!/usr/bin/env bash
136 set -ex -o pipefail
137
Kailashc8170bb2019-03-26 10:06:55 -0700138 #wait for xos-core and models to be loaded
139 timeout 300 bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/sites |jq '.items[0].name'|grep -q mysite; do echo 'Waiting for API To be up'; sleep 10; done"
140 """
141 }
142 }
143 stage('Test Core') {
144 steps {
145 sh """
146 #!/usr/bin/env bash
147 set -eu -o pipefail
148 pushd cord/test/cord-tester/src/test/cord-api/
149 source setup_venv.sh
150 cd Tests/xos-test-service
151 robot -e notready test-service.robot || true
152 popd
153 """
154 }
155 }
156 }
157 post {
158 always {
159 sh """
160 kubectl get pods --all-namespaces
161
162 # copy robot logs
163 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailashfe840382019-03-26 21:11:09 -0700164 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/xos-test-service/*ml ./RobotLogs
Kailashc8170bb2019-03-26 10:06:55 -0700165 echo "# removing helm deployments"
166 kubectl get pods
167 helm list
168
169 for hchart in \$(helm list -q);
170 do
171 echo "## Purging chart: \${hchart} ##"
172 helm delete --purge "\${hchart}"
173 done
174
175 sudo minikube delete
176 """
177 step([$class: 'RobotPublisher',
178 disableArchiveOutput: false,
179 logFileName: 'RobotLogs/log*.html',
180 otherFiles: '',
181 outputFileName: 'RobotLogs/output*.xml',
182 outputPath: '.',
183 passThreshold: 100,
184 reportFileName: 'RobotLogs/report*.html',
185 unstableThreshold: 0]);
186 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org, teo@opennetworking.org", sendToIndividuals: false])
187
188 }
189 }
190}