blob: a6ce1b9cab260277eb90517d6cfe2acbe4bcff82 [file] [log] [blame]
Andy Bavier2dc931c2019-11-06 15:03:09 -07001// Copyright 2019-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// deploy VOLTHA built from patchset on a physical pod and run e2e test
16// uses kind-voltha to deploy voltha-2.X
17
18node {
19 // Need this so that deployment_config has global scope when it's read later
20 deployment_config = null
21}
22
23pipeline {
24
25 /* no label, executor is determined by JJB */
26 agent {
27 label "${params.buildNode}"
28 }
29 options {
30 timeout(time: 60, unit: 'MINUTES')
31 }
32
33 environment {
34 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
35 VOLTCONFIG="$HOME/.volt/config-minimal"
36 TYPE="minimal"
37 FANCY=0
38 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin"
39 //VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
40 ONOS_SSH_PORT=30115
41 ONOS_API_PORT=30120
42 VOLTHA_LOG_LEVEL="debug"
43 DEPLOYMENT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
44 ROBOT_VAR_FILE="$DEPLOYMENT_CONFIG_FILE"
45 ROBOT_MISC_ARGS="--removekeywords wuks -d $WORKSPACE/RobotLogs -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir}"
46 }
47
48 stages {
49 stage ('Initialize') {
50 steps {
51 sh returnStdout: true, script: """
52 test -e $WORKSPACE/kind-voltha/voltha && cd $WORKSPACE/kind-voltha && ./voltha down
53 cd $WORKSPACE
54 rm -rf $WORKSPACE/*
55 git clone -b master ${cordRepoUrl}/${configBaseDir}
56 """
57 script { deployment_config = readYaml file: "$DEPLOYMENT_CONFIG_FILE" }
58 }
59 }
60
61 stage('Get Patch') {
62 steps {
63 checkout(changelog: false, \
64 poll: false,
65 scm: [$class: 'RepoScm', \
66 manifestRepositoryUrl: "${params.manifestUrl}", \
67 manifestBranch: "${params.manifestBranch}", \
68 currentBranch: true, \
69 destinationDir: 'voltha', \
70 forceSync: true,
71 resetFirst: true, \
72 quiet: true, \
73 jobs: 4, \
74 showAllChanges: true] \
75 )
76 sh returnStdout: false, script: """
77 cd voltha
78 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml)
79 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
80 """
81 }
82 }
83
84 stage('Create KinD Cluster') {
85 steps {
86 sh returnStdout: false, script: """
87 git clone https://github.com/ciena/kind-voltha.git
88 cd kind-voltha/
89 JUST_K8S=y ./voltha up
90 """
91 }
92 }
93
94 stage('Build and Push Images') {
95 steps {
96 sh returnStdout: false, script: """
97 if ! [[ "${gerritProject}" =~ ^(voltha-system-tests)\$ ]]; then
98 make -C $WORKSPACE/voltha/${gerritProject} DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
99 docker images | grep citest
100 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}")
101 do
102 echo "Pushing \$image to nodes"
103 kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2
104 docker rmi \$image:citest \$image:latest || true
105 done
106 fi
107 """
108 }
109 }
110
111 stage('Deploy Voltha') {
112 steps {
113 sh returnStdout: false, script: """
114 export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml '
115
116 IMAGES=""
117 if [ "${gerritProject}" = "voltha-go" ]; then
118 IMAGES="cli ofagent rw_core ro_core "
119 elif [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
120 IMAGES="adapter_open_olt "
121 elif [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
122 IMAGES="adapter_open_onu "
123 elif [ "${gerritProject}" = "voltha-api-server" ]; then
124 IMAGES="afrouter afrouterd "
125 else
126 echo "No images to push"
127 fi
128
129 for I in \$IMAGES
130 do
131 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
132 done
133
134 cd $WORKSPACE/kind-voltha/
135 echo \$EXTRA_HELM_FLAGS
136 WITH_SIM_ADAPTERS=n WITH_RADIUS=y DEPLOY_K8S=no ./voltha up
137 """
138 }
139 }
140
141 stage('Push Tech-Profile') {
142 when {
143 expression { params.configurePod && params.profile != "Default" }
144 }
145 steps {
146 sh returnStdout: false, script: """
147 etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
148 kubectl cp $WORKSPACE/voltha/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
149 kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/xgspon/64'
150 """
151 }
152 }
153
154 stage('Push Sadis-config') {
155 steps {
156 sh returnStdout: false, script: """
157 curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:$ONOS_API_PORT/onos/v1/network/configuration --data @$WORKSPACE/voltha/voltha-system-tests/tests/data/${configFileName}-sadis.json
158 """
159 }
160 }
161
162 stage('Reinstall OLT software') {
163 when {
164 expression { params.reinstallOlt }
165 }
166 steps {
167 script {
168 deployment_config.olts.each { olt ->
169 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true"
170 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true"
171 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --remove asfvolt16 && dpkg --purge asfvolt16'"
172 waitUntil {
173 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
174 return olt_sw_present.toInteger() == 0
175 }
176 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --install ${oltDebVersion}'"
177 waitUntil {
178 olt_sw_present = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'dpkg --list | grep asfvolt16 | wc -l'"
179 return olt_sw_present.toInteger() == 1
180 }
181 if ( olt.fortygig ) {
182 // If the OLT is connected to a 40G switch interface, set the NNI port to be downgraded
183 sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'echo port ce128 sp=40000 >> /broadcom/qax.soc ; /opt/bcm68620/svk_init.sh'"
184 }
185 }
186 }
187 }
188 }
189
190 stage('Restart OLT processes') {
191 steps {
192 script {
193 deployment_config.olts.each { olt ->
194 sh returnStdout: true, script: """
195 ssh-keyscan -H ${olt.ip} >> ~/.ssh/known_hosts
196 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist stop' || true
197 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt stop' || true
198 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'rm -f /var/log/bal_core_dist.log /var/log/openolt.log'
199 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service bal_core_dist start &'
200 sleep 5
201 sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'service openolt start &'
202 """
203 waitUntil {
204 onu_discovered = sh returnStdout: true, script: "sshpass -p ${olt.pass} ssh -l ${olt.user} ${olt.ip} 'grep \"onu discover indication\" /var/log/openolt.log | wc -l'"
205 return onu_discovered.toInteger() > 0
206 }
207 }
208 }
209 }
210 }
211
212 stage('Run E2E Tests') {
213 steps {
214 sh returnStdout: false, script: """
215 cd voltha
216 git clone -b ${branch} ${cordRepoUrl}/cord-tester
217 git clone -b ${branch} ${cordRepoUrl}/voltha # VOL-2104 recommends we get rid of this
218 mkdir -p $WORKSPACE/RobotLogs
219 make -C $WORKSPACE/voltha/voltha-system-tests voltha-podtest || true
220 """
221 }
222 }
223 }
224
225 post {
226 always {
227 sh returnStdout: true, script: """
228 set +e
229 cp kind-voltha/install-minimal.log $WORKSPACE/
230 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
231 kubectl get nodes -o wide
232 kubectl get pods -o wide
233 kubectl get pods -n voltha -o wide
234 ## get default pod logs
235 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
236 do
237 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
238 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
239 else
240 kubectl logs \$pod> $WORKSPACE/\$pod.log;
241 fi
242 done
243 ## get voltha pod logs
244 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
245 do
246 if [[ \$pod == *"-api-"* ]]; then
247 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
248 elif [[ \$pod == "bbsim-"* ]]; then
249 kubectl logs \$pod -n voltha -p > $WORKSPACE/\$pod.log;
250 else
251 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
252 fi
253 done
254 """
255 step([$class: 'RobotPublisher',
256 disableArchiveOutput: false,
257 logFileName: 'RobotLogs/log*.html',
258 otherFiles: '',
259 outputFileName: 'RobotLogs/output*.xml',
260 outputPath: '.',
261 passThreshold: 80,
262 reportFileName: 'RobotLogs/report*.html',
263 unstableThreshold: 0]);
264 archiveArtifacts artifacts: '*.log'
265 }
266 }
267}
268