blob: 4bb8b02b60ae76586b75dea74e0255ad8ff00eaf [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'])
Hardik Windlass6f854a12021-07-12 13:20:21 +000039 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemurie6625222020-09-01 17:12:56 -070040 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
Hardik Windlass6f854a12021-07-12 13:20:21 +000064 if [ "${params.branch}" == "voltha-2.8" ]; then
65 VC_VERSION=1.6.10
Suchitra Vemurie6625222020-09-01 17:12:56 -070066 else
67 VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
68 fi
69
70 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
71 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
72 if [ \$HOSTARCH == "x86_64" ]; then
73 HOSTARCH="amd64"
74 fi
75 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH}
76 chmod 755 $WORKSPACE/bin/voltctl
77 voltctl version --clientonly
78
79 if [ "${params.branch}" == "master" ]; then
80 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
81 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
82 # We should change this. In the meantime here is a workaround.
83 set +e
84
85 # Remove noise from voltha-core logs
86 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
87 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
88 # Remove noise from openolt logs
89 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
90 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
91 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
92 fi
93 """
94 }
95 }
96
97 stage('Functional Tests') {
98 environment {
99 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
100 ROBOT_FILE="Voltha_PODTests.robot"
101 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests"
102 }
103 steps {
104 sh """
105 cd $WORKSPACE/voltha/kind-voltha/scripts
106 ./log-collector.sh > /dev/null &
107 ./log-combine.sh > /dev/null &
108
109 mkdir -p $ROBOT_LOGS_DIR
110 if [ "${params.testType}" == "Functional" ]; then
111 if ( ${powerSwitch} ); then
Suchitra Vemuri0d966722020-09-08 21:03:58 -0700112 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i sanity -i functional -e DeleteOLT -e DisableONU_AuthCheck -e DisableDeleteONUandOLT -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 Vemurie6625222020-09-01 17:12:56 -0700113 else
114 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"
115 fi
116 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
117 fi
Suchitra Vemurie6625222020-09-01 17:12:56 -0700118 """
119 }
120 }
121
122 stage('Failure/Recovery Tests') {
123 environment {
124 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
125 ROBOT_FILE="Voltha_FailureScenarios.robot"
126 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureScenarios"
127 }
128 steps {
129 sh """
130 mkdir -p $ROBOT_LOGS_DIR
131 if [ "${params.testType}" == "Failure" ]; then
132 if ( ${powerSwitch} ); then
133 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"
134 else
135 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"
136 fi
Suchitra Vemuri0903e662020-09-02 09:24:18 -0700137 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
Suchitra Vemurie6625222020-09-01 17:12:56 -0700138 fi
Suchitra Vemurie6625222020-09-01 17:12:56 -0700139 """
140 }
141 }
142
143 stage('Dataplane Tests') {
144 environment {
145 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
146 ROBOT_FILE="Voltha_PODTests.robot"
147 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/DataplaneTests"
148 }
149 steps {
150 sh """
151 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri0d966722020-09-08 21:03:58 -0700152 if [ "${params.testType}" == "Dataplane" ]; then
Suchitra Vemurie6625222020-09-01 17:12:56 -0700153 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"
154 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
155 fi
156 """
157 }
158 }
159
160 }
161 post {
162 always {
163 sh returnStdout: false, script: '''
164 set +e
165 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
166 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
167 kubectl get nodes -o wide
168 kubectl get pods -n voltha -o wide
169
170 sleep 60 # Wait for log-collector and log-combine to complete
171
172 # Clean up "announcer" pod used by the tests if present
173 kubectl delete pod announcer || true
174
175 ## Pull out errors from log files
176 extract_errors_go() {
177 echo
178 echo "Error summary for $1:"
179 grep '"level":"error"' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1*
180 echo
181 }
182
183 extract_errors_python() {
184 echo
185 echo "Error summary for $1:"
186 grep 'ERROR' $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/$1*
187 echo
188 }
189
190 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
191 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
192 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
193 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
194 extract_errors_python onos >> $WORKSPACE/error-report.log
195
196 cd $WORKSPACE/voltha/kind-voltha/scripts/logger/combined/
197 tar czf $WORKSPACE/container-logs.tgz *
198
199 cd $WORKSPACE
200 gzip *-combined.log || true
201
202 # collect ETCD cluster logs
203 mkdir -p $WORKSPACE/etcd
Girish Gowdra3eb96f62020-10-15 12:48:34 -0700204 printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I% bash -c "kubectl logs % > $WORKSPACE/etcd/%.log"
Suchitra Vemurie6625222020-09-01 17:12:56 -0700205 '''
206 script {
207 deployment_config.olts.each { olt ->
208 sh returnStdout: false, script: """
209 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
210 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
211 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
212 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
213 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
214 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
215 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
216 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
217 """
218 }
219 }
220 step([$class: 'RobotPublisher',
221 disableArchiveOutput: false,
222 logFileName: '**/log*.html',
223 otherFiles: '',
224 outputFileName: '**/output*.xml',
225 outputPath: 'RobotLogs',
226 passThreshold: 100,
227 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200228 unstableThreshold: 0,
229 onlyCritical: true
Suchitra Vemurie6625222020-09-01 17:12:56 -0700230 ]);
231 archiveArtifacts artifacts: '*.log,*.gz,*.tgz,etcd/*.log'
232 }
Suchitra Vemurie6625222020-09-01 17:12:56 -0700233 }
234}