blob: a87e300bcabb1e96d460bd5542c4bb31adfe7b91 [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
Hardik Windlass5e7230e2021-07-22 04:08:42 +000015library identifier: 'cord-jenkins-libraries@master',
16 retriever: modernSCM([
17 $class: 'GitSCMSource',
18 remote: 'https://gerrit.opencord.org/ci-management.git'
19])
20
Suchitra Vemurif4461652020-09-03 21:47:19 -070021node {
22 // Need this so that deployment_config has global scope when it's read later
23 deployment_config = null
24}
25
Hardik Windlass5cfb29a2021-08-10 09:39:29 +000026def volthaNamespace = "voltha"
27
Suchitra Vemurif4461652020-09-03 21:47:19 -070028pipeline {
29 /* no label, executor is determined by JJB */
30 agent {
31 label "${params.buildNode}"
32 }
33 options {
34 timeout(time: 280, unit: 'MINUTES')
35 }
36
37 environment {
38 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
39 VOLTCONFIG="$HOME/.volt/config-minimal"
40 PATH="$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
41 }
42
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080043
Suchitra Vemurif4461652020-09-03 21:47:19 -070044 stages {
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080045 stage('Clone voltha-system-tests') {
46 steps {
Hardik Windlass13d8e952021-07-20 09:16:46 +000047 step([$class: 'WsCleanup'])
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080048 checkout([
49 $class: 'GitSCM',
50 userRemoteConfigs: [[
51 url: "https://gerrit.opencord.org/voltha-system-tests",
52 refspec: "${volthaSystemTestsChange}"
53 ]],
54 branches: [[ name: "${branch}", ]],
55 extensions: [
56 [$class: 'WipeWorkspace'],
57 [$class: 'RelativeTargetDirectory', relativeTargetDir: "voltha-system-tests"],
58 [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
59 ],
60 ])
Suchitra Vemurif4461652020-09-03 21:47:19 -070061 script {
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080062 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 """)
Suchitra Vemurif4461652020-09-03 21:47:19 -070068 }
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080069 }
70 }
Suchitra Vemurief0a6e92021-02-23 21:14:07 -080071 // 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 Vemurief0a6e92021-02-23 21:14:07 -080099 script {
100 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
101 }
Suchitra Vemurif4461652020-09-03 21:47:19 -0700102 sh returnStdout: false, script: """
Suchitra Vemurif4461652020-09-03 21:47:19 -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 VC_VERSION=1.6.11
Suchitra Vemurif4461652020-09-03 21:47:19 -0700108 else
109 VC_VERSION=\$(curl -sSL https://api.github.com/repos/opencord/voltctl/releases/latest | jq -r .tag_name | sed -e 's/^v//g')
110 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
117 curl -o $WORKSPACE/bin/voltctl -sSL https://github.com/opencord/voltctl/releases/download/v\${VC_VERSION}/voltctl-\${VC_VERSION}-\${HOSTOS}-\${HOSTARCH}
118 chmod 755 $WORKSPACE/bin/voltctl
119 voltctl version --clientonly
120
121 if [ "${params.branch}" == "master" ]; then
122 # 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 set +e
126
127 # Remove noise from voltha-core logs
128 voltctl log level set WARN read-write-core#github.com/opencord/voltha-go/db/model
129 voltctl log level set WARN read-write-core#github.com/opencord/voltha-lib-go/v3/pkg/kafka
130 # Remove noise from openolt logs
131 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/db
132 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/probe
133 voltctl log level set WARN adapter-open-olt#github.com/opencord/voltha-lib-go/v3/pkg/kafka
134 fi
135 """
136 }
137 }
138
139 stage('Functional Tests') {
140 environment {
141 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700142 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700143 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FunctionalTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700144 }
145 steps {
146 sh """
Hardik Windlass5cfb29a2021-08-10 09:39:29 +0000147 JENKINS_NODE_COOKIE="dontKillMe" _TAG="prometheus" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n cattle-prometheus svc/access-prometheus 31301:80; done"&
148 ps aux | grep port-forward
Suchitra Vemurif4461652020-09-03 21:47:19 -0700149 mkdir -p $ROBOT_LOGS_DIR
150 if [ "${params.testType}" == "Functional" ]; then
151 if ( ${powerSwitch} ); then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000152 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 -0700153 else
Hardik Windlassc6eae662021-05-19 11:58:23 +0000154 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 -0700155 fi
Suchitra Vemuri0287e9b2021-02-25 11:17:32 -0800156 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700157 fi
158 """
159 }
160 }
161
162 stage('Failure/Recovery Tests') {
163 environment {
164 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700165 ROBOT_FILE="Voltha_DT_FailureScenarios.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700166 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/FailureScenarios"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700167 }
168 steps {
169 sh """
170 mkdir -p $ROBOT_LOGS_DIR
171 if [ "${params.testType}" == "Failure" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000172 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 -0800173 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700174 fi
175 """
176 }
177 }
178
179 stage('Dataplane Tests') {
180 environment {
181 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
Suchitra Vemuri4d944e92020-09-03 22:50:44 -0700182 ROBOT_FILE="Voltha_DT_PODTests.robot"
Suchitra Vemuri07ceef32020-09-03 23:19:09 -0700183 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/dt-workflow/DataplaneTests"
Suchitra Vemurif4461652020-09-03 21:47:19 -0700184 }
185 steps {
186 sh """
187 mkdir -p $ROBOT_LOGS_DIR
Suchitra Vemuri60603032020-09-10 17:13:37 -0700188 if [ "${params.testType}" == "Dataplane" ]; then
Hardik Windlassc6eae662021-05-19 11:58:23 +0000189 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 -0800190 make -C $WORKSPACE/voltha-system-tests voltha-dt-test || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700191 fi
192 """
193 }
194 }
195
196 }
197 post {
198 always {
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700199 getPodsInfo("$WORKSPACE/pods")
Suchitra Vemurif4461652020-09-03 21:47:19 -0700200 sh returnStdout: false, script: '''
201 set +e
Suchitra Vemurif4461652020-09-03 21:47:19 -0700202
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700203 # collect logs collected in the Robot Framework StartLogging keyword
Suchitra Vemurif4461652020-09-03 21:47:19 -0700204 cd $WORKSPACE
205 gzip *-combined.log || true
Matteo Scandolo5e7bd1d2021-07-16 13:29:42 -0700206 rm *-combined.log || true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700207
208 # collect ETCD cluster logs
209 mkdir -p $WORKSPACE/etcd
Girish Gowdra3eb96f62020-10-15 12:48:34 -0700210 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 -0700211 '''
212 script {
213 deployment_config.olts.each { olt ->
214 sh returnStdout: false, script: """
215 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
216 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.sship}.log # Remove escape sequences
217 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
218 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/dev_mgmt_daemon-${olt.sship}.log # Remove escape sequences
219 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
220 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/startup-${olt.sship}.log || true # Remove escape sequences
221 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
222 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt_process_watchdog-${olt.sship}.log || true # Remove escape sequences
223 """
224 }
225 }
226 step([$class: 'RobotPublisher',
227 disableArchiveOutput: false,
228 logFileName: '**/log*.html',
229 otherFiles: '',
230 outputFileName: '**/output*.xml',
231 outputPath: 'RobotLogs',
232 passThreshold: 100,
233 reportFileName: '**/report*.html',
Andrea Campanellaabc09772021-06-16 12:08:57 +0200234 unstableThreshold: 0,
235 onlyCritical: true
Suchitra Vemurif4461652020-09-03 21:47:19 -0700236 ]);
Hardik Windlass5cfb29a2021-08-10 09:39:29 +0000237 // get cpu usage by container
Hardik Windlass48e75f92021-08-11 22:11:33 +0530238 sh """
Hardik Windlass5cfb29a2021-08-10 09:39:29 +0000239 mkdir -p $WORKSPACE/plots || true
240 cd $WORKSPACE/voltha-system-tests
241 source ./vst_venv/bin/activate || true
242 sleep 60 # we have to wait for prometheus to collect all the information
Hardik Windlassb9dfd082021-08-19 04:41:14 +0000243 python scripts/sizing.py -o $WORKSPACE/plots -a 0.0.0.0:31301 -n ${volthaNamespace} -s 3600 || true
Hardik Windlass48e75f92021-08-11 22:11:33 +0530244 """
Hardik Windlass5cfb29a2021-08-10 09:39:29 +0000245 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.tgz,*.txt,pods/*.txt,plots/*'
Suchitra Vemurif4461652020-09-03 21:47:19 -0700246 }
Suchitra Vemurif4461652020-09-03 21:47:19 -0700247 }
248}