blob: 6fd342f2c42eea6f6c0a0a0e849a29eac6e273a1 [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
Matteo Scandolo712514a2021-07-20 09:49:09 -070015library identifier: 'cord-jenkins-libraries@master',
16 retriever: modernSCM([
17 $class: 'GitSCMSource',
18 remote: 'https://gerrit.opencord.org/ci-management.git'
19])
20
Suchitra Vemuri376859a2020-07-08 17:04:44 -070021node {
22 // Need this so that deployment_config has global scope when it's read later
23 deployment_config = null
24}
25
26pipeline {
27 /* no label, executor is determined by JJB */
28 agent {
29 label "${params.buildNode}"
30 }
31 options {
Hardik Windlassd0f01662021-09-03 08:07:15 +000032 timeout(time: "${timeout}", unit: 'MINUTES')
Suchitra Vemuri376859a2020-07-08 17:04:44 -070033 }
34
35 environment {
36 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
37 VOLTCONFIG="$HOME/.volt/config-minimal"
38 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
39 }
40
41 stages {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070042 stage('Clone voltha-system-tests') {
43 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000044 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070045 checkout([
46 $class: 'GitSCM',
47 userRemoteConfigs: [[
48 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000049 refspec: "${volthaSystemTestsChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070050 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000051 branches: [[ name: "${branch}", ]],
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070052 extensions: [
53 [$class: 'WipeWorkspace'],
54 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
55 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
56 ],
57 ])
Hardik Windlass81f67dc2021-03-05 16:15:42 +053058 script {
59 sh(script:"""
60 if [ '${volthaSystemTestsChange}' != '' ] ; then
61 cd $WORKSPACE/voltha-system-tests;
62 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
63 fi
64 """)
65 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070066 }
67 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070068 // This checkout allows us to show changes in Jenkins
69 // we only do this on master as we don't branch all the repos for all the releases
70 // (we should compute the difference by tracking the container version, not the code)
71 stage('Download All the VOLTHA repos') {
72 when {
73 expression {
74 return "${branch}" == 'master';
75 }
76 }
77 steps {
78 checkout(changelog: true,
79 poll: false,
80 scm: [$class: 'RepoScm',
81 manifestRepositoryUrl: "${params.manifestUrl}",
82 manifestBranch: "${params.branch}",
83 currentBranch: true,
84 destinationDir: 'voltha',
85 forceSync: true,
86 resetFirst: true,
87 quiet: true,
88 jobs: 4,
89 showAllChanges: true]
90 )
91 }
92 }
93 stage ('Initialize') {
94 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000095 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -070096 script {
97 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
98 }
Hardik Windlass9658cd22021-10-25 11:13:25 +000099 installVoltctl("${branch}")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700100 sh returnStdout: false, script: """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700101 mkdir -p $WORKSPACE/bin
Hardik Windlass9658cd22021-10-25 11:13:25 +0000102 # download kail
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700103 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200104
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700105 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
106 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
107 # We should change this. In the meantime here is a workaround.
108 if [ "${params.branch}" == "master" ]; then
109 set +e
110
111
112 # Remove noise from voltha-core logs
113 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
114 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
115 # Remove noise from openolt logs
116 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
117 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
118 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
119 fi
120 """
121 }
122 }
123
124 stage('Functional Tests') {
125 environment {
126 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
127 ROBOT_FILE="Voltha_TT_PODTests.robot"
128 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
129 }
130 steps {
131 sh """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700132 mkdir -p $ROBOT_LOGS_DIR
133 if ( ${powerSwitch} ); then
Hardik Windlass44461ee2021-05-26 07:19:53 +0000134 export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700135 else
Hardik Windlass44461ee2021-05-26 07:19:53 +0000136 export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -e 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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700137 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700138 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700139 """
140 }
141 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530142
143 stage('Failure/Recovery Tests') {
144 environment {
145 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
146 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
147 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
148 }
149 steps {
150 sh """
151 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000152 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000153 if ( ${powerSwitch} ); then
154 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
155 else
156 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel}"
157 fi
158 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530159 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530160 """
161 }
162 }
163
Hardik Windlass6a233e82021-05-27 04:08:50 +0000164 stage('Multi-Tcont Tests') {
165 environment {
166 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
167 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
168 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
169 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
170 }
171 steps {
172 sh """
173 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000174 if [ ${params.enableMultiUni} = false ]; then
175 if ( ${powerSwitch} ); then
176 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE"
177 else
178 export ROBOT_MISC_ARGS="--removekeywords wuks -L TRACE -i functionalTT -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 -v OLT_ADAPTER_APP_LABEL:${oltAdapterAppLabel} -V $ROBOT_TEST_INPUT_FILE"
Hardik Windlass6598b032021-07-02 10:12:01 +0000179 fi
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000180 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000181 fi
182 """
183 }
184 }
185
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700186 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700187 post {
188 always {
Hardik Windlassceb56312021-07-21 16:12:25 +0000189 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700190 sh returnStdout: false, script: '''
191 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700192
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700193 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700194 cd $WORKSPACE
195 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200196 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700197 '''
198 script {
199 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100200 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
201 sh returnStdout: false, script: """
202 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
203 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
204 """
205 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700206 }
207 }
208 step([$class: 'RobotPublisher',
209 disableArchiveOutput: false,
210 logFileName: '**/log*.html',
211 otherFiles: '',
212 outputFileName: '**/output*.xml',
213 outputPath: 'RobotLogs',
214 passThreshold: 100,
215 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200216 unstableThreshold: 0,
217 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700218 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700219 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700220 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700221 }
222}