blob: dbc4009a8144ab27f388bc898de9b2dd243b411e [file] [log] [blame]
Suchitra Vemuri376859a2020-07-08 17:04:44 -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
15node {
16 // Need this so that deployment_config has global scope when it's read later
17 deployment_config = null
18}
19
20pipeline {
21 /* no label, executor is determined by JJB */
22 agent {
23 label "${params.buildNode}"
24 }
25 options {
26 timeout(time: 180, unit: 'MINUTES')
27 }
28
29 environment {
30 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
31 VOLTCONFIG="$HOME/.volt/config-minimal"
32 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
33 }
34
35 stages {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070036 stage('Clone kind-voltha') {
Suchitra Vemuri376859a2020-07-08 17:04:44 -070037 steps {
38 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070039 checkout([
40 $class: 'GitSCM',
41 userRemoteConfigs: [[
42 url: "https://gerrit.opencord.org/kind-voltha",
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070043 ]],
44 branches: [[ name: "master", ]],
45 extensions: [
46 [$class: 'WipeWorkspace'],
47 [$class: 'RelativeTargetDirectory', relativeTargetDir: "kind-voltha"],
48 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
49 ],
50 ])
Matteo Scandolo01d596c2020-09-18 16:37:55 -070051 sh """
52 cd $WORKSPACE/kind-voltha
53 git fetch https://gerrit.opencord.org/kind-voltha ${gerritRefspec} && git checkout FETCH_HEAD
54 """
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070055 }
56 }
57 stage('Clone voltha-system-tests') {
58 steps {
59 checkout([
60 $class: 'GitSCM',
61 userRemoteConfigs: [[
62 url: "https://gerrit.opencord.org/voltha-system-tests",
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070063 ]],
64 branches: [[ name: "${branch}", ]],
65 extensions: [
66 [$class: 'WipeWorkspace'],
67 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
68 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
69 ],
70 ])
Matteo Scandolo01d596c2020-09-18 16:37:55 -070071 sh """
72 cd $WORKSPACE/voltha-system-tests
73 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
74 """
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070075 }
76 }
77 stage('Clone cord-tester') {
78 steps {
79 checkout([
80 $class: 'GitSCM',
81 userRemoteConfigs: [[
82 url: "https://gerrit.opencord.org/cord-tester",
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070083 ]],
84 branches: [[ name: "master", ]],
85 extensions: [
86 [$class: 'WipeWorkspace'],
87 [$class: 'RelativeTargetDirectory', relativeTargetDir: "cord-tester"],
88 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
89 ],
90 ])
Matteo Scandolo01d596c2020-09-18 16:37:55 -070091 sh """
92 cd $WORKSPACE/cord-tester
93 git fetch https://gerrit.opencord.org/voltha-system-tests ${cordTesterChange} && git checkout FETCH_HEAD
94 """
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070095 }
96 }
97 // This checkout allows us to show changes in Jenkins
98 // we only do this on master as we don't branch all the repos for all the releases
99 // (we should compute the difference by tracking the container version, not the code)
100 stage('Download All the VOLTHA repos') {
101 when {
102 expression {
103 return "${branch}" == 'master';
104 }
105 }
106 steps {
107 checkout(changelog: true,
108 poll: false,
109 scm: [$class: 'RepoScm',
110 manifestRepositoryUrl: "${params.manifestUrl}",
111 manifestBranch: "${params.branch}",
112 currentBranch: true,
113 destinationDir: 'voltha',
114 forceSync: true,
115 resetFirst: true,
116 quiet: true,
117 jobs: 4,
118 showAllChanges: true]
119 )
120 }
121 }
122 stage ('Initialize') {
123 steps {
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700124 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700125 script {
126 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
127 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700128 sh returnStdout: false, script: """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700129 mkdir -p $WORKSPACE/bin
130 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
131 cd $WORKSPACE
132 if [ "${params.branch}" != "master" ]; then
133 cd $WORKSPACE/kind-voltha
134 source releases/${params.branch}
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700135 else
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700136 VOLTCTL_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700137 fi
138
139 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
140 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
141 if [ \$HOSTARCH == "x86_64" ]; then
142 HOSTARCH="amd64"
143 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700144 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VOLTCTL_VERSION}/voltctl-\${VOLTCTL_VERSION}-\${HOSTOS}-\${HOSTARCH}
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700145 chmod 755 $WORKSPACE/bin/voltctl
146 voltctl version --clientonly
147
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200148
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700149 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
150 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
151 # We should change this. In the meantime here is a workaround.
152 if [ "${params.branch}" == "master" ]; then
153 set +e
154
155
156 # Remove noise from voltha-core logs
157 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
158 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
159 # Remove noise from openolt logs
160 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
161 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
162 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
163 fi
164 """
165 }
166 }
167
168 stage('Functional Tests') {
169 environment {
170 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
171 ROBOT_FILE="Voltha_TT_PODTests.robot"
172 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
173 }
174 steps {
175 sh """
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700176 cd $WORKSPACE/kind-voltha/scripts
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700177 ./log-collector.sh > /dev/null &
178 ./log-combine.sh > /dev/null &
179
180 mkdir -p $ROBOT_LOGS_DIR
181 if ( ${powerSwitch} ); then
Suchitra Vemuri52862722020-07-17 21:28:34 -0700182 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700183 else
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700184 export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanityTT -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700185 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700186 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700187 """
188 }
189 }
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700190 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700191 post {
192 always {
193 sh returnStdout: false, script: '''
194 set +e
195 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
196 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
197 kubectl get nodes -o wide
198 kubectl get pods -n voltha -o wide
199
200 sleep 60 # Wait for log-collector and log-combine to complete
201
202 # Clean up "announcer" pod used by the tests if present
203 kubectl delete pod announcer || true
204
205 ## Pull out errors from log files
206 extract_errors_go() {
207 echo
208 echo "Error summary for $1:"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700209 grep '"level":"error"' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700210 echo
211 }
212
213 extract_errors_python() {
214 echo
215 echo "Error summary for $1:"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700216 grep 'ERROR' $WORKSPACE/kind-voltha/scripts/logger/combined/$1*
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700217 echo
218 }
219
220 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
221 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
222 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
223 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
224 extract_errors_python onos >> $WORKSPACE/error-report.log
225
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200226 gzip error-report.log || true
227
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700228 cd $WORKSPACE/kind-voltha/scripts/logger/combined/
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700229 tar czf $WORKSPACE/container-logs.tgz *
230
231 cd $WORKSPACE
232 gzip *-combined.log || true
233 '''
234 script {
235 deployment_config.olts.each { olt ->
236 sh returnStdout: false, script: """
Suchitra Vemuria0695662020-07-17 09:41:49 -0700237 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
238 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700239 """
240 }
241 }
242 step([$class: 'RobotPublisher',
243 disableArchiveOutput: false,
244 logFileName: '**/log*.html',
245 otherFiles: '',
246 outputFileName: '**/output*.xml',
247 outputPath: 'RobotLogs',
248 passThreshold: 100,
249 reportFileName: '**/report*.html',
250 unstableThreshold: 0
251 ]);
252 archiveArtifacts artifacts: '*.log,*.gz,*.tgz'
253 }
254 unstable {
255 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
256 }
257 }
258}