blob: 42b984be74ee7f11d80b7434c2888476ae95799d [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 {
23 label "${params.executorNode}"
24 }
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/
Andy Bavierff4f9952019-10-18 15:22:55 -070063 export DESIRED_VERSION=v2.14.3 # For Helm
Kailash9eac2732019-09-03 18:05:48 -070064 DEPLOY_K8S=y JUST_K8S=y FANCY=0 ./voltha up
Kailashaad71012019-08-27 10:36:53 -070065 """
66 }
67 }
68
69 stage('Build Images') {
70 steps {
71 sh """
hwchiu9140fd22019-10-10 15:48:30 -070072 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -070073 cd $WORKSPACE/voltha/${gerritProject}/
74 make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
75 fi
Kailashaad71012019-08-27 10:36:53 -070076 """
77 }
78 }
79
80 stage('Push Images') {
81 steps {
82 sh '''
hwchiu9140fd22019-10-10 15:48:30 -070083 if ! [[ "${gerritProject}" =~ ^(voltha-helm-charts|voltha-system-tests)\$ ]]; then
Andy Bavier07615f92019-10-03 12:31:18 -070084 export GOROOT=/usr/local/go
85 export GOPATH=\$(pwd)
86 export TYPE=minimal
87 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
88 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
89 export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH
90 docker images | grep citest
91 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
92 fi
Kailashaad71012019-08-27 10:36:53 -070093 '''
94 }
95 }
96 stage('Deploy Voltha') {
97 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -070098 sh '''
Andy Bavier90f74702019-10-16 20:21:51 -070099 HELM_FLAG="${extraHelmFlags} "
Kailashaad71012019-08-27 10:36:53 -0700100
101 if [ "${gerritProject}" = "voltha-go" ]; then
hwchiu9140fd22019-10-10 15:48:30 -0700102 HELM_FLAG+="-f $WORKSPACE/voltha/voltha-system-tests/tests/data/ci-test.yaml "
Kailashaad71012019-08-27 10:36:53 -0700103 fi
104
105 if [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700106 HELM_FLAG+="--set images.adapter_open_olt.tag=citest,images.adapter_open_olt.pullPolicy=Never "
Kailashaad71012019-08-27 10:36:53 -0700107 fi
108
109 if [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700110 HELM_FLAG+="--set images.adapter_open_onu.tag=citest,images.adapter_open_onu.pullPolicy=Never "
Kailashaad71012019-08-27 10:36:53 -0700111 fi
112
Andy Bavierc4183ba2019-09-30 15:40:18 -0700113 if [ "${gerritProject}" = "voltha-bbsim" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700114 HELM_FLAG+="--set images.bbsim.tag=citest,images.bbsim.pullPolicy=Never "
Andy Bavierc4183ba2019-09-30 15:40:18 -0700115 fi
116
Scott Baker9ac23712019-10-02 09:26:50 -0700117 if [ "${gerritProject}" = "voltha-api-server" ]; then
Andy Baviera9857572019-10-04 15:33:02 -0700118 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 -0700119 else
Andy Bavierbedd0392019-10-16 13:58:18 -0700120 # afrouter only has master branch at present
Zack Williams04997502019-10-04 14:32:20 -0700121 HELM_FLAG+="--set images.afrouter.tag=master,images.afrouterd.tag=master "
Scott Baker9ac23712019-10-02 09:26:50 -0700122 fi
123
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700124 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
Andy Bavier45406342019-10-02 16:45:40 -0700125 export CHART_PATH=$WORKSPACE/voltha/voltha-helm-charts
126 export VOLTHA_CHART=\$CHART_PATH/voltha
127 export VOLTHA_ADAPTER_OPEN_OLT_CHART=\$CHART_PATH/voltha-adapter-openolt
128 export VOLTHA_ADAPTER_OPEN_ONU_CHART=\$CHART_PATH/voltha-adapter-openonu
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700129 helm dep update \$VOLTHA_CHART
130 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
131 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
132 fi
133
134 cd $WORKSPACE/kind-voltha/
Kailashda9b6562019-09-03 12:48:31 -0700135 echo \$HELM_FLAG
Andy Bavier3d8d5282019-10-04 16:03:49 -0700136 EXTRA_HELM_FLAGS=\$HELM_FLAG VOLTHA_LOG_LEVEL=DEBUG TYPE=minimal WITH_RADIUS=y WITH_BBSIM=y INSTALL_ONOS_APPS=y CONFIG_SADIS=y FANCY=0 WITH_SIM_ADAPTERS=n ./voltha up
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700137 '''
Kailashaad71012019-08-27 10:36:53 -0700138 }
139 }
140
141 stage('Run E2E Tests') {
142 steps {
143 sh '''
144 cd kind-voltha/
145 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
146 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Kailasheadb2e22019-09-05 10:30:06 -0700147 export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH
Andy Bavieraca510e2019-10-15 08:00:25 -0700148 make -C $WORKSPACE/voltha/voltha-system-tests sanity-kind || true
Kailashaad71012019-08-27 10:36:53 -0700149 '''
150 }
151 }
152 }
153
154 post {
155 always {
156 sh '''
Andy Bavier07615f92019-10-03 12:31:18 -0700157 set +e
Kailashaad71012019-08-27 10:36:53 -0700158 # copy robot logs
159 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Andy Bavier70f4b8f2019-10-15 08:34:49 -0700160 cp -r $WORKSPACE/voltha/voltha-system-tests/tests/*/*.html ./RobotLogs || true
161 cp -r $WORKSPACE/voltha/voltha-system-tests/tests/*/*.xml ./RobotLogs || true
Kailashaad71012019-08-27 10:36:53 -0700162 cd kind-voltha/
163 cp install-minimal.log $WORKSPACE/
164 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
165 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Kailasheadb2e22019-09-05 10:30:06 -0700166 export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH
Kailashaad71012019-08-27 10:36:53 -0700167 kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s "[[:space:]]" "\n" | sort | uniq -c
168 kubectl get nodes -o wide
169 kubectl get pods -o wide
170 kubectl get pods -n voltha -o wide
171 ## get default pod logs
172 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
173 do
174 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
175 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
176 else
177 kubectl logs \$pod> $WORKSPACE/\$pod.log;
178 fi
179 done
180 ## get voltha pod logs
181 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
182 do
183 if [[ \$pod == *"-api-"* ]]; then
184 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
185 else
186 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
187 fi
188 done
Kailash2365ea82019-09-10 11:09:58 -0700189 ## clean up node
Andy Bavier3d8d5282019-10-04 16:03:49 -0700190 FANCY=0 WAIT_ON_DOWN=y ./voltha down
Kailash2365ea82019-09-10 11:09:58 -0700191 cd $WORKSPACE/
Andy Bavier70f4b8f2019-10-15 08:34:49 -0700192 rm -rf kind-voltha/ voltha/ || true
Kailashaad71012019-08-27 10:36:53 -0700193 '''
194 step([$class: 'RobotPublisher',
195 disableArchiveOutput: false,
196 logFileName: 'RobotLogs/log*.html',
197 otherFiles: '',
198 outputFileName: 'RobotLogs/output*.xml',
199 outputPath: '.',
200 passThreshold: 80,
201 reportFileName: 'RobotLogs/report*.html',
202 unstableThreshold: 0]);
203 archiveArtifacts artifacts: '*.log'
204
205 }
206 }
207}
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700208