blob: d86aac9a915f0a12cb33c3778e965de2d0d1be6e [file] [log] [blame]
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -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 {
Hardik Windlassfcb86272021-02-15 17:01:24 +053026 timeout(time: 300, unit: 'MINUTES')
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070027 }
28 environment {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
Matteo Scandolo861a53a2020-09-16 11:39:42 -070031 PATH="$PATH:$WORKSPACE/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Matteo Scandolo4d1a12f2020-12-07 16:17:12 -080032 NAME="minimal"
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070033 FANCY=0
34 WITH_SIM_ADAPTERS="no"
35 WITH_RADIUS="yes"
36 WITH_BBSIM="yes"
37 DEPLOY_K8S="yes"
38 VOLTHA_LOG_LEVEL="DEBUG"
Andrea Campanella2a01b5a2020-09-09 11:38:18 +020039 CONFIG_SADIS="external"
40 BBSIM_CFG="configs/bbsim-sadis-att.yaml"
Andy Bavier4be37062020-06-29 15:17:26 -070041 ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
pierventref48ebc12020-07-17 16:01:32 +020042 KARAF_HOME="${params.karafHome}"
43 DIAGS_PROFILE="VOLTHA_PROFILE"
Suchitra Vemuri456b6b42020-11-10 19:06:22 -080044 NUM_OF_BBSIM="${olts}"
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070045 }
46 stages {
Matteo Scandolo861a53a2020-09-16 11:39:42 -070047 stage('Clone kind-voltha') {
48 steps {
49 checkout([
50 $class: 'GitSCM',
51 userRemoteConfigs: [[
52 url: "https://gerrit.opencord.org/kind-voltha",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000053 // refspec: "${kindVolthaChange}"
Matteo Scandolo861a53a2020-09-16 11:39:42 -070054 ]],
55 branches: [[ name: "master", ]],
56 extensions: [
57 [$class: 'WipeWorkspace'],
58 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
59 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
60 ],
61 ])
62 }
63 }
Matteo Scandolofa90bb12020-09-18 11:00:50 -070064 stage('Cleanup') {
65 steps {
66 sh """
67 cd $WORKSPACE/kind-voltha/
68 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
69 """
70 }
71 }
Matteo Scandolo861a53a2020-09-16 11:39:42 -070072 stage('Clone voltha-system-tests') {
73 steps {
74 checkout([
75 $class: 'GitSCM',
76 userRemoteConfigs: [[
77 url: "https://gerrit.opencord.org/voltha-system-tests",
Hardik Windlassfcb86272021-02-15 17:01:24 +053078 refspec: "${volthaSystemTestsChange}"
Matteo Scandolo861a53a2020-09-16 11:39:42 -070079 ]],
80 branches: [[ name: "${branch}", ]],
81 extensions: [
82 [$class: 'WipeWorkspace'],
83 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
84 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
85 ],
86 ])
Hardik Windlassd31dfc72021-02-22 17:53:32 +053087 script {
88 sh(script:"""
89 if [ '${volthaSystemTestsChange}' != '' ] ; then
90 cd $WORKSPACE/voltha-system-tests;
91 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
92 fi
93 """)
94 }
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070095 }
96 }
97
98 stage('Deploy Voltha') {
99 steps {
100 sh """
101 export EXTRA_HELM_FLAGS=""
102 if [ "${branch}" != "master" ]; then
103 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700104 source "$WORKSPACE/kind-voltha/releases/${branch}"
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700105 else
Hardik Windlassdc6cee12021-04-30 06:02:12 +0000106 export INFRA_NS="infra"
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700107 echo "on master, using default settings for kind-voltha"
108 fi
109
Andrea Campanella427d13e2020-12-16 18:27:08 +0100110 EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags} --set defaults.image_registry=mirror.registry.opennetworking.org/ "
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700111
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700112 cd $WORKSPACE/kind-voltha/
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700113 ./voltha up
114 """
115 }
116 }
117
118 stage('Functional Tests') {
119 environment {
120 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests"
121 }
122 steps {
123 sh '''
124 set +e
125 mkdir -p $ROBOT_LOGS_DIR
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700126 cd $WORKSPACE/kind-voltha/scripts
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700127 ./log-collector.sh > /dev/null &
128 ./log-combine.sh > /dev/null &
129
130 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Suchitra Vemuri456b6b42020-11-10 19:06:22 -0800131 make -C $WORKSPACE/voltha-system-tests ${makeTarget} || true
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700132 '''
133 }
134 }
135
Hung-Wei Chiuc72fe1f2020-05-04 13:54:32 -0700136 stage('Alarm Tests') {
137 environment {
138 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/AlarmTests"
139 }
Suchitra Vemuri456b6b42020-11-10 19:06:22 -0800140 when {
141 expression {
142 return params.withAlarms
143 }
144 }
Hung-Wei Chiuc72fe1f2020-05-04 13:54:32 -0700145 steps {
146 sh '''
147 set +e
148 mkdir -p $WORKSPACE/RobotLogs
149
150 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Suchitra Vemuri456b6b42020-11-10 19:06:22 -0800151 make -C $WORKSPACE/voltha-system-tests ${makeAlarmtestTarget} || true
Hung-Wei Chiuc72fe1f2020-05-04 13:54:32 -0700152 '''
153 }
154 }
155
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700156 stage('Failure/Recovery Tests') {
157 environment {
158 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureTests"
159 }
160 steps {
161 sh '''
162 set +e
163 mkdir -p $WORKSPACE/RobotLogs
164
165 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Suchitra Vemuri456b6b42020-11-10 19:06:22 -0800166 make -C $WORKSPACE/voltha-system-tests ${makeFailtestTarget} || true
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700167 '''
168 }
169 }
Suchitra Vemuri5eb71952020-12-15 18:18:32 -0800170 stage('Multiple OLT Tests') {
171 environment {
172 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/MultipleOLTTests"
173 }
174 steps {
175 sh '''
176 if [ "${olts}" -gt 1 ]; then
177 set +e
178 mkdir -p $WORKSPACE/RobotLogs
179 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
180 make -C $WORKSPACE/voltha-system-tests ${makeMultiOltTarget} || true
181 fi
182 '''
183 }
184 }
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700185
186 stage('Error Tests') {
187 environment {
188 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ErrorTests"
189 }
190 steps {
191 sh '''
192 set +e
193 mkdir -p $WORKSPACE/RobotLogs
194
195 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Suchitra Vemuri456b6b42020-11-10 19:06:22 -0800196 make -C $WORKSPACE/voltha-system-tests ${makeErrortestTarget} || true
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700197 '''
198 }
199 }
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700200 }
201
202 post {
203 always {
204 sh '''
205 set +e
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700206 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700207 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
208 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
209 kubectl get nodes -o wide
210 kubectl get pods -o wide
211 kubectl get pods -n voltha -o wide
212
213 sleep 60 # Wait for log-collector and log-combine to complete
214
215 ## Pull out errors from log files
216 extract_errors_go() {
217 echo
218 echo "Error summary for $1:"
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700219 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700220 echo
221 }
222
223 extract_errors_python() {
224 echo
225 echo "Error summary for $1:"
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700226 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700227 echo
228 }
229
230 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
231 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
232 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
233 extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log
234 extract_errors_python onos >> $WORKSPACE/error-report.log
235
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200236 gzip error-report.log || true
237
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700238 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700239 tar czf $WORKSPACE/container-logs.tgz *
240
241 cd $WORKSPACE
242 gzip *-combined.log || true
243
244 ## shut down voltha but leave kind-voltha cluster
Matteo Scandolo861a53a2020-09-16 11:39:42 -0700245 cd $WORKSPACE/kind-voltha/
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700246 DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
Andy Bavierfcae3832020-06-04 08:51:10 -0700247 kubectl delete deployment voltctl || true
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700248 '''
249 step([$class: 'RobotPublisher',
250 disableArchiveOutput: false,
251 logFileName: '**/log*.html',
252 otherFiles: '',
253 outputFileName: '**/output*.xml',
254 outputPath: 'RobotLogs',
255 passThreshold: 100,
256 reportFileName: '**/report*.html',
257 unstableThreshold: 0]);
258
259 archiveArtifacts artifacts: '*.log,*.gz,*.tgz'
260
261 }
262 }
263}