blob: a6f7b3dbf231b47deec4860dae2cf32587cef47e [file] [log] [blame]
Kailashaad71012019-08-27 10:36:53 -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// voltha-2.x e2e tests
16// uses kind-voltha to deploy voltha-2.X
17// uses bbsim to simulate OLT/ONUs
18
19pipeline {
20
21 /* no label, executor is determined by JJB */
22 agent {
Zack Williamsb3292082019-10-11 17:15:18 -070023 label "${params.buildNode}"
Kailashaad71012019-08-27 10:36:53 -070024 }
25 options {
Andy Bavier5f4b2fa2019-10-03 07:48:49 -070026 timeout(time: 90, unit: 'MINUTES')
Kailashaad71012019-08-27 10:36:53 -070027 }
28
29 stages {
30
31 stage('Repo') {
32 steps {
33 checkout(changelog: false, \
34 poll: false,
35 scm: [$class: 'RepoScm', \
36 manifestRepositoryUrl: "${params.manifestUrl}", \
37 manifestBranch: "${params.manifestBranch}", \
38 currentBranch: true, \
39 destinationDir: 'voltha', \
40 forceSync: true,
41 resetFirst: true, \
42 quiet: true, \
43 jobs: 4, \
44 showAllChanges: true] \
45 )
46 }
47 }
48 stage('Patch') {
49 steps {
50 sh """
51 pushd voltha
52 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
53 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
54 popd
55 """
56 }
57 }
58 stage('Create K8s Cluster') {
59 steps {
60 sh """
Kailashaad71012019-08-27 10:36:53 -070061 git clone https://github.com/ciena/kind-voltha.git
62 cd kind-voltha/
Kailash9eac2732019-09-03 18:05:48 -070063 DEPLOY_K8S=y JUST_K8S=y FANCY=0 ./voltha up
Kailashaad71012019-08-27 10:36:53 -070064 """
65 }
66 }
67
68 stage('Build Images') {
69 steps {
70 sh """
hwchiu9140fd22019-10-10 15:48:30 -070071 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -070072 cd $WORKSPACE/voltha/${gerritProject}/
73 make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
74 fi
Kailashaad71012019-08-27 10:36:53 -070075 """
76 }
77 }
78
79 stage('Push Images') {
80 steps {
81 sh '''
hwchiu9140fd22019-10-10 15:48:30 -070082 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -070083 export GOROOT=/usr/local/go
84 export GOPATH=\$(pwd)
85 export TYPE=minimal
86 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
87 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Andy Baviere6f41902019-11-21 17:26:56 -070088 export PATH=$WORKSPACE/kind-voltha/bin:$PATH
Andy Bavier07615f92019-10-03 12:31:18 -070089 docker images | grep citest
90 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; done
91 fi
Kailashaad71012019-08-27 10:36:53 -070092 '''
93 }
94 }
95 stage('Deploy Voltha') {
96 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -070097 sh '''
Andy Bavier90f74702019-10-16 20:21:51 -070098 HELM_FLAG="${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -070099
100 if [ "${gerritProject}" = "voltha-go" ]; then
Zack Williamse65b1ee2019-12-09 15:57:16 -0700101 HELM_FLAG+="--set images.rw_core.tag=citest,images.rw_core.pullPolicy=Never,images.ro_core.tag=citest,images.ro_core.pullPolicy=Never "
102 fi
103
Matteo Scandolo70800a32020-01-06 11:55:27 -0800104 if [ "${gerritProject}" = "voltha-onos" ]; then
105 HELM_FLAG+="--set images.onos.tag=citest,images.onos.pullPolicy=Never "
106 fi
107
Zack Williamse65b1ee2019-12-09 15:57:16 -0700108 if [ "${gerritProject}" = "ofagent-py" ]; then
109 HELM_FLAG+="--set images.ofagent.tag=citest,images.ofagent.pullPolicy=Never "
Kailashaad71012019-08-27 10:36:53 -0700110 fi
111
112 if [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700113 HELM_FLAG+="--set images.adapter_open_olt.tag=citest,images.adapter_open_olt.pullPolicy=Never "
Kailashaad71012019-08-27 10:36:53 -0700114 fi
115
116 if [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700117 HELM_FLAG+="--set images.adapter_open_onu.tag=citest,images.adapter_open_onu.pullPolicy=Never "
Kailashaad71012019-08-27 10:36:53 -0700118 fi
119
Andy Baviera6f8e482019-10-24 08:22:30 -0700120 if [ "${gerritProject}" = "bbsim" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700121 HELM_FLAG+="--set images.bbsim.tag=citest,images.bbsim.pullPolicy=Never "
Andy Bavierc4183ba2019-09-30 15:40:18 -0700122 fi
123
Scott Baker9ac23712019-10-02 09:26:50 -0700124 if [ "${gerritProject}" = "voltha-api-server" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700125 HELM_FLAG+="--set images.afrouter.tag=citest,images.afrouter.pullPolicy=Never,images.afrouterd.tag=citest,images.afrouterd.pullPolicy=Never "
Zack Williams04997502019-10-04 14:32:20 -0700126 else
Andy Bavierbedd0392019-10-16 13:58:18 -0700127 # afrouter only has master branch at present
Zack Williams04997502019-10-04 14:32:20 -0700128 HELM_FLAG+="--set images.afrouter.tag=master,images.afrouterd.tag=master "
Scott Baker9ac23712019-10-02 09:26:50 -0700129 fi
130
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700131 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700132 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
133 export VOLTHA_CHART=\$CHART_PATH/voltha
134 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
135 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700136 helm dep update \$VOLTHA_CHART
137 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
138 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
139 fi
140
141 cd $WORKSPACE/kind-voltha/
Kailashda9b6562019-09-03 12:48:31 -0700142 echo \$HELM_FLAG
Andy Bavier0088c212020-01-08 13:44:03 -0700143 EXTRA_HELM_FLAGS=\$HELM_FLAG VOLTHA_LOG_LEVEL=DEBUG TYPE=minimal WITH_RADIUS=y WITH_BBSIM=y INSTALL_ONOS_APPS=y CONFIG_SADIS=n FANCY=0 WITH_SIM_ADAPTERS=n ./voltha up
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700144 '''
Kailashaad71012019-08-27 10:36:53 -0700145 }
146 }
147
148 stage('Run E2E Tests') {
149 steps {
150 sh '''
151 cd kind-voltha/
152 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
153 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Andy Baviere6f41902019-11-21 17:26:56 -0700154 export PATH=$WORKSPACE/kind-voltha/bin:$PATH
Andy Bavier3708d072019-12-10 15:22:18 -0700155 export ROBOT_MISC_ARGS="-v teardown_device:False"
Andy Bavieraca510e2019-10-15 08:00:25 -0700156 make -C $WORKSPACE/voltha/voltha-system-tests sanity-kind || true
Kailashaad71012019-08-27 10:36:53 -0700157 '''
158 }
159 }
160 }
161
162 post {
163 always {
164 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700165 set +e
Kailashaad71012019-08-27 10:36:53 -0700166 # copy robot logs
167 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Andy Bavier70f4b8f2019-10-15 08:34:49 -0700168 cp -r $WORKSPACE/voltha/voltha-system-tests/tests/*/*.html ./RobotLogs || true
169 cp -r $WORKSPACE/voltha/voltha-system-tests/tests/*/*.xml ./RobotLogs || true
Kailashaad71012019-08-27 10:36:53 -0700170 cd kind-voltha/
171 cp install-minimal.log $WORKSPACE/
172 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
173 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Andy Baviere6f41902019-11-21 17:26:56 -0700174 export PATH=$WORKSPACE/kind-voltha/bin:$PATH
Andy Bavieraec60382019-10-29 15:09:04 -0700175 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
Kailashaad71012019-08-27 10:36:53 -0700176 kubectl get nodes -o wide
177 kubectl get pods -o wide
178 kubectl get pods -n voltha -o wide
179 ## get default pod logs
180 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
181 do
182 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
183 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
184 else
185 kubectl logs \$pod> $WORKSPACE/\$pod.log;
186 fi
187 done
188 ## get voltha pod logs
189 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
190 do
191 if [[ \$pod == *"-api-"* ]]; then
192 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
193 else
194 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
195 fi
196 done
Kailash2365ea82019-09-10 11:09:58 -0700197 ## clean up node
Andy Bavier3d8d5282019-10-04 16:03:49 -0700198 FANCY=0 WAIT_ON_DOWN=y ./voltha down
Kailash2365ea82019-09-10 11:09:58 -0700199 cd $WORKSPACE/
Andy Bavier70f4b8f2019-10-15 08:34:49 -0700200 rm -rf kind-voltha/ voltha/ || true
Kailashaad71012019-08-27 10:36:53 -0700201 '''
202 step([$class: 'RobotPublisher',
203 disableArchiveOutput: false,
204 logFileName: 'RobotLogs/log*.html',
205 otherFiles: '',
206 outputFileName: 'RobotLogs/output*.xml',
207 outputPath: '.',
208 passThreshold: 80,
209 reportFileName: 'RobotLogs/report*.html',
210 unstableThreshold: 0]);
211 archiveArtifacts artifacts: '*.log'
212
213 }
214 }
215}