blob: 024475150ca27d4018df41d7b630c7d9ed49662c [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
Hardik Windlass7e4e3152021-09-29 06:42:05 +000026def infraNamespace = "infra"
27def volthaNamespace = "voltha"
28
Suchitra Vemuri376859a2020-07-08 17:04:44 -070029pipeline {
30 /* no label, executor is determined by JJB */
31 agent {
32 label "${params.buildNode}"
33 }
34 options {
Hardik Windlassd0f01662021-09-03 08:07:15 +000035 timeout(time: "${timeout}", unit: 'MINUTES')
Suchitra Vemuri376859a2020-07-08 17:04:44 -070036 }
37
38 environment {
39 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
40 VOLTCONFIG="$HOME/.volt/config-minimal"
41 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
42 }
43
44 stages {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070045 stage('Clone voltha-system-tests') {
46 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000047 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070048 checkout([
49 $class: 'GitSCM',
50 userRemoteConfigs: [[
51 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000052 refspec: "${volthaSystemTestsChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070053 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000054 branches: [[ name: "${branch}", ]],
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070055 extensions: [
56 [$class: 'WipeWorkspace'],
57 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
58 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
59 ],
60 ])
Hardik Windlass81f67dc2021-03-05 16:15:42 +053061 script {
62 sh(script:"""
63 if [ '${volthaSystemTestsChange}' != '' ] ; then
64 cd $WORKSPACE/voltha-system-tests;
65 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
66 fi
67 """)
68 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070069 }
70 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070071 // This checkout allows us to show changes in Jenkins
72 // we only do this on master as we don't branch all the repos for all the releases
73 // (we should compute the difference by tracking the container version, not the code)
74 stage('Download All the VOLTHA repos') {
75 when {
76 expression {
77 return "${branch}" == 'master';
78 }
79 }
80 steps {
81 checkout(changelog: true,
82 poll: false,
83 scm: [$class: 'RepoScm',
84 manifestRepositoryUrl: "${params.manifestUrl}",
85 manifestBranch: "${params.branch}",
86 currentBranch: true,
87 destinationDir: 'voltha',
88 forceSync: true,
89 resetFirst: true,
90 quiet: true,
91 jobs: 4,
92 showAllChanges: true]
93 )
94 }
95 }
96 stage ('Initialize') {
97 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000098 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -070099 script {
100 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
101 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700102 sh returnStdout: false, script: """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700103 mkdir -p $WORKSPACE/bin
104 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
105 cd $WORKSPACE
Hardik Windlass6f854a12021-07-12 13:20:21 +0000106 if [ "${params.branch}" == "voltha-2.8" ]; then
Hardik Windlasse2175102021-07-23 08:34:32 +0000107 VOLTCTL_VERSION=1.6.11
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700108 else
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700109 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 -0700110 fi
111
112 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
113 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
114 if [ \$HOSTARCH == "x86_64" ]; then
115 HOSTARCH="amd64"
116 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700117 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 -0700118 chmod 755 $WORKSPACE/bin/voltctl
119 voltctl version --clientonly
120
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200121
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700122 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
123 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
124 # We should change this. In the meantime here is a workaround.
125 if [ "${params.branch}" == "master" ]; then
126 set +e
127
128
129 # Remove noise from voltha-core logs
130 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
131 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
132 # Remove noise from openolt logs
133 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
134 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
135 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
136 fi
137 """
138 }
139 }
140
141 stage('Functional Tests') {
142 environment {
143 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
144 ROBOT_FILE="Voltha_TT_PODTests.robot"
145 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
146 }
147 steps {
148 sh """
Hardik Windlassaf12d202021-07-27 07:52:44 +0000149 device_teardown=True
150 if [ ${params.enableMultiUni} = true ]; then
151 device_teardown=False
152 fi
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700153 mkdir -p $ROBOT_LOGS_DIR
154 if ( ${powerSwitch} ); then
Hardik Windlassaf12d202021-07-27 07:52:44 +0000155 export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -i PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:\${device_teardown} -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 -0700156 else
Hardik Windlassaf12d202021-07-27 07:52:44 +0000157 export ROBOT_MISC_ARGS="--removekeywords wuks -i functionalTT -e PowerSwitch -i sanityTT -i sanityTT-MCAST -e bbsim -e notready -d $ROBOT_LOGS_DIR -v teardown_device:\${device_teardown} -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 -0700158 fi
Hardik Windlass5bf5f202021-10-07 16:38:25 +0000159 ROBOT_MISC_ARGS+=" -X -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700160 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700161 """
162 }
163 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530164
165 stage('Failure/Recovery Tests') {
166 environment {
167 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
168 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
169 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
170 }
171 steps {
172 sh """
173 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000174 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000175 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}"
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}"
179 fi
Hardik Windlass5bf5f202021-10-07 16:38:25 +0000180 ROBOT_MISC_ARGS+=" -X -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass6598b032021-07-02 10:12:01 +0000181 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530182 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530183 """
184 }
185 }
186
Hardik Windlass6a233e82021-05-27 04:08:50 +0000187 stage('Multi-Tcont Tests') {
188 environment {
189 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
190 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
191 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
192 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
193 }
194 steps {
195 sh """
196 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000197 if [ ${params.enableMultiUni} = false ]; then
198 if ( ${powerSwitch} ); then
199 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"
200 else
201 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 +0000202 fi
Hardik Windlass5bf5f202021-10-07 16:38:25 +0000203 ROBOT_MISC_ARGS+=" -X -v NAMESPACE:${volthaNamespace} -v INFRA_NAMESPACE:${infraNamespace}"
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000204 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000205 fi
206 """
207 }
208 }
209
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700210 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700211 post {
212 always {
Hardik Windlassceb56312021-07-21 16:12:25 +0000213 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700214 sh returnStdout: false, script: '''
215 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700216
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700217 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700218 cd $WORKSPACE
219 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200220 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700221 '''
222 script {
223 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100224 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
225 sh returnStdout: false, script: """
226 sshpass -p ${olt.pass} scp ${olt.user}@${olt.sship}:/var/log/openolt.log $WORKSPACE/openolt-${olt.sship}.log || true
227 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
228 """
229 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700230 }
231 }
232 step([$class: 'RobotPublisher',
233 disableArchiveOutput: false,
234 logFileName: '**/log*.html',
235 otherFiles: '',
236 outputFileName: '**/output*.xml',
237 outputPath: 'RobotLogs',
238 passThreshold: 100,
239 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200240 unstableThreshold: 0,
241 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700242 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700243 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700244 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700245 }
246}