blob: 5575c8de3532ca338dd1fafbab097eb637aa42af [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 {
Kailash2365ea82019-09-10 11:09:58 -070026 timeout(time: 120, 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 """
61 git clone https://gerrit.opencord.org/voltha-system-tests
62 git clone https://github.com/ciena/kind-voltha.git
63 cd kind-voltha/
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') {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -070070 when { expression { return params.buildImages } }
Kailashaad71012019-08-27 10:36:53 -070071 steps {
72 sh """
73 cd $WORKSPACE/voltha/${gerritProject}/
Kailash9eac2732019-09-03 18:05:48 -070074 make DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
Kailashaad71012019-08-27 10:36:53 -070075 """
76 }
77 }
78
79 stage('Push Images') {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -070080 when { expression { return params.buildImages } }
Kailashaad71012019-08-27 10:36:53 -070081 steps {
82 sh '''
83 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"
Kailasheadb2e22019-09-05 10:30:06 -070088 export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH
Kailashaad71012019-08-27 10:36:53 -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 '''
92 }
93 }
94 stage('Deploy Voltha') {
95 steps {
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -070096 sh '''
Kailash25f7a702019-09-05 11:43:11 -070097 HELM_FLAG="--set defaults.image_tag=voltha-2.1 "
Kailashaad71012019-08-27 10:36:53 -070098
99 if [ "${gerritProject}" = "voltha-go" ]; then
100 HELM_FLAG+="-f $WORKSPACE/voltha-system-tests/tests/data/ci-test.yaml"
101 fi
102
103 if [ "${gerritProject}" = "voltha-openolt-adapter" ]; then
104 HELM_FLAG+="--set images.adapter_open_olt.tag=citest,images.adapter_open_olt.pullPolicy=Never"
105 fi
106
107 if [ "${gerritProject}" = "voltha-openonu-adapter" ]; then
108 HELM_FLAG+="--set images.adapter_open_onu.tag=citest,images.adapter_open_onu.pullPolicy=Never"
109 fi
110
Andy Bavierc4183ba2019-09-30 15:40:18 -0700111 if [ "${gerritProject}" = "voltha-bbsim" ]; then
112 HELM_FLAG+="--set images.bbsim.tag=citest,images.bbsim.pullPolicy=Never"
113 fi
114
Scott Baker9ac23712019-10-02 09:26:50 -0700115 if [ "${gerritProject}" = "voltha-api-server" ]; then
116 HELM_FLAG+="--set images.afrouter.tag=citest,images.afrouter.pullPolicy=Never,images.afrouterd.tag=citest,images.afrouterd.pullPolicy=Never"
117 fi
118
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700119 if [ "${gerritProject}" = "voltha-helm-charts" ]; then
120 export VOLTHA_CHART=$WORKSPACE/voltha/voltha
121 export VOLTHA_ADAPTER_OPEN_OLT_CHART=$WORKSPACE/voltha/voltha-adapter-openolt
122 export VOLTHA_ADAPTER_OPEN_ONU_CHART=$WORKSPACE/voltha/voltha-adapter-openonu
123 helm dep update \$VOLTHA_CHART
124 helm dep update \$VOLTHA_ADAPTER_OPEN_OLT_CHART
125 helm dep update \$VOLTHA_ADAPTER_OPEN_ONU_CHART
126 fi
127
128 cd $WORKSPACE/kind-voltha/
Kailashda9b6562019-09-03 12:48:31 -0700129 echo \$HELM_FLAG
130 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 ./voltha up
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700131 '''
Kailashaad71012019-08-27 10:36:53 -0700132 }
133 }
134
135 stage('Run E2E Tests') {
136 steps {
137 sh '''
138 cd kind-voltha/
139 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
140 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Kailasheadb2e22019-09-05 10:30:06 -0700141 export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH
Kailashaad71012019-08-27 10:36:53 -0700142 cd $WORKSPACE/voltha-system-tests/tests/sanity
Kailash184cbea2019-09-11 13:54:47 -0700143 robot -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101 -e notready --critical sanity --noncritical VOL-1705 -v num_onus:1 sanity.robot || true
Kailashaad71012019-08-27 10:36:53 -0700144 '''
145 }
146 }
147 }
148
149 post {
150 always {
151 sh '''
152 # copy robot logs
153 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
154 cp -r $WORKSPACE/voltha-system-tests/tests/sanity/*ml ./RobotLogs || true
155 cd kind-voltha/
156 cp install-minimal.log $WORKSPACE/
157 export KUBECONFIG="$(./bin/kind get kubeconfig-path --name="voltha-minimal")"
158 export VOLTCONFIG="/home/jenkins/.volt/config-minimal"
Kailasheadb2e22019-09-05 10:30:06 -0700159 export PATH=/w/workspace/${gerritProject}_sanity-system-test/kind-voltha/bin:$PATH
Kailashaad71012019-08-27 10:36:53 -0700160 kubectl get pods --all-namespaces -o jsonpath="{..image}" |tr -s "[[:space:]]" "\n" | sort | uniq -c
161 kubectl get nodes -o wide
162 kubectl get pods -o wide
163 kubectl get pods -n voltha -o wide
164 ## get default pod logs
165 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
166 do
167 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
168 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
169 else
170 kubectl logs \$pod> $WORKSPACE/\$pod.log;
171 fi
172 done
173 ## get voltha pod logs
174 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
175 do
176 if [[ \$pod == *"-api-"* ]]; then
177 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
178 else
179 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
180 fi
181 done
Kailash2365ea82019-09-10 11:09:58 -0700182 ## clean up node
Andy Bavier3a58ba32019-09-20 16:31:40 -0700183 WAIT_ON_DOWN=y ./voltha down
Kailash2365ea82019-09-10 11:09:58 -0700184 cd $WORKSPACE/
185 rm -rf kind-voltha/ voltha-system-tests/ || true
Kailashaad71012019-08-27 10:36:53 -0700186 '''
187 step([$class: 'RobotPublisher',
188 disableArchiveOutput: false,
189 logFileName: 'RobotLogs/log*.html',
190 otherFiles: '',
191 outputFileName: 'RobotLogs/output*.xml',
192 outputPath: '.',
193 passThreshold: 80,
194 reportFileName: 'RobotLogs/report*.html',
195 unstableThreshold: 0]);
196 archiveArtifacts artifacts: '*.log'
197
198 }
199 }
200}
Kailash Khalasiaf3a2a62019-10-02 09:44:08 -0700201