blob: 79b52ed20a2cfd019300890a37230ac138be5a51 [file] [log] [blame]
Matteo Scandolofff6e062020-04-29 13:36:33 -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.buildNode}"
24 }
25 options {
26 timeout(time: 90, unit: 'MINUTES')
27 }
28 environment {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
31 PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
32 TYPE="minimal"
33 FANCY=0
34 WITH_SIM_ADAPTERS="n"
35 WITH_RADIUS="y"
36 WITH_BBSIM="y"
37 DEPLOY_K8S="y"
38 VOLTHA_LOG_LEVEL="DEBUG"
39 CONFIG_SADIS="n"
40 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
41 }
42
43 stages {
44
45 stage('Repo') {
46 steps {
47 step([$class: 'WsCleanup'])
48 checkout(changelog: false, \
49 poll: false,
50 scm: [$class: 'RepoScm', \
51 manifestRepositoryUrl: "${params.manifestUrl}", \
52 manifestBranch: "${params.branch}", \
53 currentBranch: true, \
54 destinationDir: 'voltha', \
55 forceSync: true,
56 resetFirst: true, \
57 quiet: true, \
58 jobs: 4, \
59 showAllChanges: true] \
60 )
61 }
62 }
63 stage('Patch') {
64 steps {
65 sh """
66 if [ "${gerritProject}" != "voltha-openonu-adapter-go"]
67 then
68 echo "This pipeline is reserved for 'voltha-openonu-adapter-go' you are probably looking for 'voltha-bbsim-test.groovy'"
69 exit 1
70 fi
71 pushd voltha
72 if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ]
73 then
74 repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
75 else
76 echo "No patchset to download!"
77 fi
78 popd
79 """
80 }
81 }
82 stage('Create K8s Cluster') {
83 steps {
84 sh """
85 cd $WORKSPACE/voltha/kind-voltha/
86 JUST_K8S=y ./voltha up
87 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin"
88 """
89 }
90 }
91
92 stage('Build Images') {
93 steps {
94 sh """
95 make -C $WORKSPACE/voltha/voltha-openonu-adapter-go DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
96 """
97 }
98 }
99
100 stage('Push Images') {
101 steps {
102 sh '''
103 docker images | grep citest
104 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
105 '''
106 }
107 }
108 stage('Deploy Voltha') {
109 steps {
110 sh '''
111 export EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${extraHelmFlags},use_openonu_adapter_go=true "
112
113 IMAGES="adapter_open_onu_go"
114
115 for I in \$IMAGES
116 do
117 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
118 done
119
120 cd $WORKSPACE/voltha/kind-voltha/
121 echo \$EXTRA_HELM_FLAGS
122 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
123 ./voltha up
124 '''
125 }
126 }
127
128 stage('Run E2E Tests') {
129 steps {
130 sh '''
131 RUNNING=$(kubectl get pods --all-namespaces | grep open-onu | grep 1/1 | wc -l)
132 if [ $RUNNING -eq 1 ]; then
133 echo "Openonu adapter is correctly deployed"
134 else
135 echo "Openonu adapter is not running!"
136 exit 1
137 fi
138
139 ADAPTER=$(voltctl adapter list | grep brcm_openomci_onu | wc -l)
140 if [ $ADAPTER -eq 1 ]; then
141 echo "Openonu adapter is correctly registered with VOLTHA core"
142 else
143 echo "Openonu adapter is NOT registered with VOLTHA core"
144 exit 1
145 fi
146 # TODO once we have a test for the openonu golang adapter replace the bash check
147 '''
148 }
149 }
150 }
151
152 post {
153 always {
154 sh '''
155 set +e
156 cp $WORKSPACE/voltha/kind-voltha/install-minimal.log $WORKSPACE/
157 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
158 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
159 kubectl get nodes -o wide
160 kubectl get pods -o wide
161 kubectl get pods -n voltha -o wide
162
163 sync
164 pkill kail || true
165 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
166
167 ## Pull out errors from log files
168 extract_errors_go() {
169 echo
170 echo "Error summary for $1:"
171 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
172 echo
173 }
174
175 extract_errors_python() {
176 echo
177 echo "Error summary for $1:"
178 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
179 echo
180 }
181
182 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
183 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
184 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
185 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
186
187 gzip $WORKSPACE/onos-voltha-combined.log
188
189
190 ## shut down kind-voltha
191 if [ "${branch}" != "master" ]; then
192 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
193 source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
194 else
195 echo "on master, using default settings for kind-voltha"
196 fi
197
198 cd $WORKSPACE/voltha/kind-voltha
199 WAIT_ON_DOWN=y ./voltha down
200 '''
201 step([$class: 'RobotPublisher',
202 disableArchiveOutput: false,
203 logFileName: 'RobotLogs/log*.html',
204 otherFiles: '',
205 outputFileName: 'RobotLogs/output*.xml',
206 outputPath: '.',
207 passThreshold: 80,
208 reportFileName: 'RobotLogs/report*.html',
209 unstableThreshold: 0]);
210 archiveArtifacts artifacts: '*.log,*.gz'
211 }
212 }
213}