blob: 0ca9a4889c2cbf5897c60ab559c45b2cf2cf9a1f [file] [log] [blame]
Suchitra Vemurie6625222020-09-01 17:12:56 -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: 280, 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 {
36 stage ('Initialize') {
37 steps {
38 step([$class: 'WsCleanup'])
39 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
40 sh returnStdout: false, script: "git clone -b master ${cordRepoUrl}/kind-voltha"
41 script {
42 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
43 }
44 // This checkout allows us to show changes in Jenkins
45 checkout(changelog: true,
46 poll: false,
47 scm: [$class: 'RepoScm',
48 manifestRepositoryUrl: "${params.manifestUrl}",
49 manifestBranch: "${params.branch}",
50 currentBranch: true,
51 destinationDir: 'voltha',
52 forceSync: true,
53 resetFirst: true,
54 quiet: true,
55 jobs: 4,
56 showAllChanges: true]
57 )
58 sh returnStdout: false, script: """
59 cd voltha
60 git clone -b master ${cordRepoUrl}/cord-tester
61 mkdir -p $WORKSPACE/bin
62 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
63 cd $WORKSPACE
64 if [ "${params.branch}" != "master" ]; then
65 cd $WORKSPACE/kind-voltha
66 source releases/${params.branch}
67 VC_VERSION=1.1.8
68 else
69 VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
70 fi
71
72 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
73 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
74 if [ \$HOSTARCH == "x86_64" ]; then
75 HOSTARCH="amd64"
76 fi
77 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH}
78 chmod 755 $WORKSPACE/bin/voltctl
79 voltctl version --clientonly
80
81 if [ "${params.branch}" == "master" ]; then
82 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
83 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
84 # We should change this. In the meantime here is a workaround.
85 set +e
86
87 # Remove noise from voltha-core logs
88 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
89 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
90 # Remove noise from openolt logs
91 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
92 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
93 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
94 fi
95 """
96 }
97 }
98
99 stage('Functional Tests') {
100 environment {
101 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
102 ROBOT_FILE="Voltha_PODTests.robot"
103 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests"
104 }
105 steps {
106 sh """
107 cd $WORKSPACE/voltha/kind-voltha/scripts
108 ./log-collector.sh > /dev/null &
109 ./log-combine.sh > /dev/null &
110
111 mkdir -p $ROBOT_LOGS_DIR
112 if [ "${params.testType}" == "Functional" ]; then
113 if ( ${powerSwitch} ); then
114 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanity -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
115 else
116 export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i sanity -i functional -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
117 fi
118 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
119 fi
120 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
121 """
122 }
123 }
124
125 stage('Failure/Recovery Tests') {
126 environment {
127 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
128 ROBOT_FILE="Voltha_FailureScenarios.robot"
129 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureScenarios"
130 }
131 steps {
132 sh """
133 mkdir -p $ROBOT_LOGS_DIR
134 if [ "${params.testType}" == "Failure" ]; then
135 if ( ${powerSwitch} ); then
136 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -i PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
137 else
138 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functional -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
139 fi
140 fi
141 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
142 """
143 }
144 }
145
146 stage('Dataplane Tests') {
147 environment {
148 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
149 ROBOT_FILE="Voltha_PODTests.robot"
150 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DataplaneTests"
151 }
152 steps {
153 sh """
154 mkdir -p $ROBOT_LOGS_DIR
155 if [ "${params.testType}" == "Failure" ]; then
156 export ROBOT_MISC_ARGS="--removekeywords wuks -i dataplane -e bbsim -e notready -d $ROBOT_LOGS_DIR -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
157 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
158 fi
159 """
160 }
161 }
162
163 }
164 post {
165 always {
166 sh returnStdout: false, script: '''
167 set +e
168 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
169 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
170 kubectl get nodes -o wide
171 kubectl get pods -n voltha -o wide
172
173 sleep 60 # Wait for log-collector and log-combine to complete
174
175 # Clean up "announcer" pod used by the tests if present
176 kubectl delete pod announcer || true
177
178 ## Pull out errors from log files
179 extract_errors_go() {
180 echo
181 echo "Error summary for $1:"
182 grep '"level":"error"' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1*
183 echo
184 }
185
186 extract_errors_python() {
187 echo
188 echo "Error summary for $1:"
189 grep 'ERROR' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1*
190 echo
191 }
192
193 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
194 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
195 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
196 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
197 extract_errors_python onos >> $WORKSPACE/error-report.log
198
199 cd $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/
200 tar czf $WORKSPACE/container-logs.tgz *
201
202 cd $WORKSPACE
203 gzip *-combined.log || true
204
205 # collect ETCD cluster logs
206 mkdir -p $WORKSPACE/etcd
207 printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I@ bash -c "kubectl logs @ > $WORKSPACE/etcd/@.log"
208 '''
209 script {
210 deployment_config.olts.each { olt ->
211 sh returnStdout: false, script: """
212 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
213 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
214 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/dev_mgmt_daemon.log $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log || true
215 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
216 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/startup.log $WORKSPACE/startup-${olt.sship}.log || true
217 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
218 sshpass -p ${olt.pass} scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${olt.user}@${olt.sship}:/var/log/openolt_process_watchdog.log $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true
219 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
220 """
221 }
222 }
223 step([$class: 'RobotPublisher',
224 disableArchiveOutput: false,
225 logFileName: '**/log*.html',
226 otherFiles: '',
227 outputFileName: '**/output*.xml',
228 outputPath: 'RobotLogs',
229 passThreshold: 100,
230 reportFileName: '**/report*.html',
231 unstableThreshold: 0
232 ]);
233 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
234 }
235 unstable {
236 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
237 }
238 }
239}