blob: 8a2933023add6cccc0a66d2c3d0a70a7d8fa51ce [file] [log] [blame]
Suchitra Vemurif4461652020-09-03 21:47:19 -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
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080035
Suchitra Vemurif4461652020-09-03 21:47:19 -070036 stages {
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080037 stage('Clone voltha-system-tests') {
38 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000039 step([$class: 'WsCleanup'])
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080040 checkout([
41 $class: 'GitSCM',
42 userRemoteConfigs: [[
43 url: "https://gerrit.opencord.org/voltha-system-tests",
44 refspec: "${volthaSystemTestsChange}"
45 ]],
46 branches: [[ name: "${branch}", ]],
47 extensions: [
48 [$class: 'WipeWorkspace'],
49 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
50 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
51 ],
52 ])
Suchitra Vemurif4461652020-09-03 21:47:19 -070053 script {
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080054 sh(script:"""
55 if [ '${volthaSystemTestsChange}' != '' ] ; then
56 cd $WORKSPACE/voltha-system-tests;
57 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
58 fi
59 """)
Suchitra Vemurif4461652020-09-03 21:47:19 -070060 }
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080061 }
62 }
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080063 // This checkout allows us to show changes in Jenkins
64 // we only do this on master as we don't branch all the repos for all the releases
65 // (we should compute the difference by tracking the container version, not the code)
66 stage('Download All the VOLTHA repos') {
67 when {
68 expression {
69 return "${branch}" == 'master';
70 }
71 }
72 steps {
73 checkout(changelog: true,
74 poll: false,
75 scm: [$class: 'RepoScm',
76 manifestRepositoryUrl: "${params.manifestUrl}",
77 manifestBranch: "${params.branch}",
78 currentBranch: true,
79 destinationDir: 'voltha',
80 forceSync: true,
81 resetFirst: true,
82 quiet: true,
83 jobs: 4,
84 showAllChanges: true]
85 )
86 }
87 }
88 stage ('Initialize') {
89 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000090 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080091 script {
92 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
93 }
Suchitra Vemurif4461652020-09-03 21:47:19 -070094 sh returnStdout: false, script: """
Suchitra Vemurif4461652020-09-03 21:47:19 -070095 mkdir -p $WORKSPACE/bin
96 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
97 cd $WORKSPACE
Hardik Windlass6f854a12021-07-12 13:20:21 +000098 if [ "${params.branch}" == "voltha-2.8" ]; then
99 VC_VERSION=1.6.10
Suchitra Vemurif4461652020-09-03 21:47:19 -0700100 else
101 VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
102 fi
103
104 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
105 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
106 if [ \$HOSTARCH == "x86_64" ]; then
107 HOSTARCH="amd64"
108 fi
109 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH}
110 chmod 755 $WORKSPACE/bin/voltctl
111 voltctl version --clientonly
112
113 if [ "${params.branch}" == "master" ]; then
114 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
115 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
116 # We should change this. In the meantime here is a workaround.
117 set +e
118
119 # Remove noise from voltha-core logs
120 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
121 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
122 # Remove noise from openolt logs
123 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
124 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
125 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
126 fi
127 """
128 }
129 }
130
131 stage('Functional Tests') {
132 environment {
133 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700134 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700135 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700136 }
137 steps {
138 sh """
Suchitra Vemurif4461652020-09-03 21:47:19 -0700139 mkdir -p $ROBOT_LOGS_DIR
140 if [ "${params.testType}" == "Functional" ]; then
141 if ( ${powerSwitch} ); then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000142 export ROBOT_MISC_ARGS="--removekeywords wuks -i PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700143 else
Hardik Windlassc6eae662021-05-19 11:58:23 +0000144 export ROBOT_MISC_ARGS="--removekeywords wuks -e PowerSwitch -i soak -e dataplaneDt -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700145 fi
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800146 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700147 fi
148 """
149 }
150 }
151
152 stage('Failure/Recovery Tests') {
153 environment {
154 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700155 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700156 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700157 }
158 steps {
159 sh """
160 mkdir -p $ROBOT_LOGS_DIR
161 if [ "${params.testType}" == "Failure" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000162 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i soak -e PowerSwitch -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800163 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700164 fi
165 """
166 }
167 }
168
169 stage('Dataplane Tests') {
170 environment {
171 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700172 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700173 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700174 }
175 steps {
176 sh """
177 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri60603032020-09-10 17:13:37 -0700178 if [ "${params.testType}" == "Dataplane" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000179 export ROBOT_MISC_ARGS="--removekeywords wuks -i soakDataplane -e bbsim -e notready -d $ROBOT_LOGS_DIR -v SOAK_TEST:True -v logging:False -v teardown_device:False -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir} -v container_log_dir:$WORKSPACE"
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800180 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700181 fi
182 """
183 }
184 }
185
186 }
187 post {
188 always {
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700189 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemurif4461652020-09-03 21:47:19 -0700190 sh returnStdout: false, script: '''
191 set +e
Suchitra Vemurif4461652020-09-03 21:47:19 -0700192
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700193 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemurif4461652020-09-03 21:47:19 -0700194 cd $WORKSPACE
195 gzip *-combined.log || true
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700196 rm *-combined.log || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700197
198 # collect ETCD cluster logs
199 mkdir -p $WORKSPACE/etcd
Girish Gowdra3eb96f62020-10-15 12:48:34 -0700200 printf '%s\n' $(kubectl get pods -l app=etcd -o=jsonpath="{.items[*]['metadata.name']}") | xargs -I% bash -c "kubectl logs % > $WORKSPACE/etcd/%.log"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700201 '''
202 script {
203 deployment_config.olts.each { olt ->
204 sh returnStdout: false, script: """
205 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
206 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
207 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
208 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
209 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
210 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
211 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
212 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
213 """
214 }
215 }
216 step([$class: 'RobotPublisher',
217 disableArchiveOutput: false,
218 logFileName: '**/log*.html',
219 otherFiles: '',
220 outputFileName: '**/output*.xml',
221 outputPath: 'RobotLogs',
222 passThreshold: 100,
223 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200224 unstableThreshold: 0,
225 onlyCritical: true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700226 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700227 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemurif4461652020-09-03 21:47:19 -0700228 }
Suchitra Vemurif4461652020-09-03 21:47:19 -0700229 }
230}