blob: f7478cf29d3bb346d5b019112d771586115cdef5 [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
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 {
Hardik Windlass6c22b202021-07-02 03:46:37 +000026 timeout(time: 210, unit: 'MINUTES')
Suchitra Vemuri376859a2020-07-08 17:04:44 -070027 }
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 {
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070036 stage('Clone voltha-system-tests') {
37 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000038 step([$class: 'WsCleanup'])
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070039 checkout([
40 $class: 'GitSCM',
41 userRemoteConfigs: [[
42 url: "https://gerrit.opencord.org/voltha-system-tests",
Matteo Scandoloa42c6f52020-09-19 01:35:12 +000043 refspec: "${volthaSystemTestsChange}"
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070044 ]],
Suchitra Vemuri1143ae32021-03-26 01:08:37 +000045 branches: [[ name: "${branch}", ]],
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070046 extensions: [
47 [$class: 'WipeWorkspace'],
48 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
49 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
50 ],
51 ])
Hardik Windlass81f67dc2021-03-05 16:15:42 +053052 script {
53 sh(script:"""
54 if [ '${volthaSystemTestsChange}' != '' ] ; then
55 cd $WORKSPACE/voltha-system-tests;
56 git fetch https://gerrit.opencord.org/voltha-system-tests ${volthaSystemTestsChange} && git checkout FETCH_HEAD
57 fi
58 """)
59 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070060 }
61 }
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -070062 // This checkout allows us to show changes in Jenkins
63 // we only do this on master as we don't branch all the repos for all the releases
64 // (we should compute the difference by tracking the container version, not the code)
65 stage('Download All the VOLTHA repos') {
66 when {
67 expression {
68 return "${branch}" == 'master';
69 }
70 }
71 steps {
72 checkout(changelog: true,
73 poll: false,
74 scm: [$class: 'RepoScm',
75 manifestRepositoryUrl: "${params.manifestUrl}",
76 manifestBranch: "${params.branch}",
77 currentBranch: true,
78 destinationDir: 'voltha',
79 forceSync: true,
80 resetFirst: true,
81 quiet: true,
82 jobs: 4,
83 showAllChanges: true]
84 )
85 }
86 }
87 stage ('Initialize') {
88 steps {
Hardik Windlass6f854a12021-07-12 13:20:21 +000089 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Suchitra Vemuri376859a2020-07-08 17:04:44 -070090 script {
91 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
92 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -070093 sh returnStdout: false, script: """
Suchitra Vemuri376859a2020-07-08 17:04:44 -070094 mkdir -p $WORKSPACE/bin
95 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
96 cd $WORKSPACE
Hardik Windlass6f854a12021-07-12 13:20:21 +000097 if [ "${params.branch}" == "voltha-2.8" ]; then
98 VOLTCTL_VERSION=1.6.10
Suchitra Vemuri376859a2020-07-08 17:04:44 -070099 else
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700100 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 -0700101 fi
102
103 HOSTOS=\$(uname -s | tr "[:upper:]" "[:lower:"])
104 HOSTARCH=\$(uname -m | tr "[:upper:]" "[:lower:"])
105 if [ \$HOSTARCH == "x86_64" ]; then
106 HOSTARCH="amd64"
107 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700108 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 -0700109 chmod 755 $WORKSPACE/bin/voltctl
110 voltctl version --clientonly
111
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200112
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700113 # Default kind-voltha config doesn't work on ONF demo pod for accessing kvstore.
114 # The issue is that the mgmt node is also one of the k8s nodes and so port forwarding doesn't work.
115 # We should change this. In the meantime here is a workaround.
116 if [ "${params.branch}" == "master" ]; then
117 set +e
118
119
120 # Remove noise from voltha-core logs
121 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
122 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
123 # Remove noise from openolt logs
124 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
125 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
126 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
127 fi
128 """
129 }
130 }
131
132 stage('Functional Tests') {
133 environment {
134 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
135 ROBOT_FILE="Voltha_TT_PODTests.robot"
136 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FunctionalTests"
137 }
138 steps {
139 sh """
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700140 mkdir -p $ROBOT_LOGS_DIR
141 if ( ${powerSwitch} ); then
Hardik Windlass44461ee2021-05-26 07:19:53 +0000142 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 -0700143 else
Hardik Windlass44461ee2021-05-26 07:19:53 +0000144 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 -0700145 fi
Suchitra Vemurie3bb90d2020-09-15 17:15:50 -0700146 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700147 """
148 }
149 }
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530150
151 stage('Failure/Recovery Tests') {
152 environment {
153 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
154 ROBOT_FILE="Voltha_TT_FailureScenarios.robot"
155 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/FailureScenarios"
156 }
157 steps {
158 sh """
159 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass47c4dc12021-07-02 23:40:03 +0000160 if [ ${params.enableMultiUni} = false ]; then
Hardik Windlass6598b032021-07-02 10:12:01 +0000161 if ( ${powerSwitch} ); then
162 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}"
163 else
164 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}"
165 fi
166 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530167 fi
Hardik Windlass81f67dc2021-03-05 16:15:42 +0530168 """
169 }
170 }
171
Hardik Windlass6a233e82021-05-27 04:08:50 +0000172 stage('Multi-Tcont Tests') {
173 environment {
174 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
175 ROBOT_FILE="Voltha_TT_MultiTcontTests.robot"
176 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/tt-workflow/MultiTcontScenarios"
177 ROBOT_TEST_INPUT_FILE="$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-TT-multi-tcont-tests-input.yaml"
178 }
179 steps {
180 sh """
181 mkdir -p $ROBOT_LOGS_DIR
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000182 if [ ${params.enableMultiUni} = false ]; then
183 if ( ${powerSwitch} ); then
184 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"
185 else
186 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 +0000187 fi
Hardik Windlass92dba5d2021-07-14 06:37:44 +0000188 make -C $WORKSPACE/voltha-system-tests voltha-tt-test || true
Hardik Windlass6a233e82021-05-27 04:08:50 +0000189 fi
190 """
191 }
192 }
193
Suchitra Vemuri6cd54232020-07-09 16:06:55 -0700194 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700195 post {
196 always {
197 sh returnStdout: false, script: '''
198 set +e
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700199
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700200 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700201 cd $WORKSPACE
202 gzip *-combined.log || true
Andrea Campanellac9c80682020-09-30 12:02:01 +0200203 rm *-combined.log || true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700204 '''
205 script {
206 deployment_config.olts.each { olt ->
Andrea Campanella0d3110c2021-01-20 12:25:45 +0100207 if (olt.type == null || olt.type == "" || olt.type == "openolt") {
208 sh returnStdout: false, script: """
209 sshpass -p ${olt.pass} scp ${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 """
212 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700213 }
214 }
215 step([$class: 'RobotPublisher',
216 disableArchiveOutput: false,
217 logFileName: '**/log*.html',
218 otherFiles: '',
219 outputFileName: '**/output*.xml',
220 outputPath: 'RobotLogs',
221 passThreshold: 100,
222 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200223 unstableThreshold: 0,
224 onlyCritical: true
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700225 ]);
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700226 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt'
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700227 }
Suchitra Vemuri376859a2020-07-08 17:04:44 -0700228 }
229}