blob: f4194029b3faacfa79561895a7457e7a5c4c9f77 [file] [log] [blame]
Andy Bavier358aa0b2019-11-22 11:55:39 -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: 60, unit: 'MINUTES')
27 }
28
29 environment {
30 KUBECONFIG="$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf"
31 VOLTCONFIG="$HOME/.volt/config-minimal"
Andy Bavier4af02722020-01-15 10:24:24 -070032 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/bin"
Andy Bavier358aa0b2019-11-22 11:55:39 -070033 }
34
35 stages {
36 stage ('Initialize') {
37 steps {
38 step([$class: 'WsCleanup'])
hwchiu1f0b0fe2019-12-06 11:45:23 -080039 sh returnStdout: false, script: "git clone -b ${branch} ${cordRepoUrl}/${configBaseDir}"
Andy Bavier358aa0b2019-11-22 11:55:39 -070040 script {
41 deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
42 }
43 // This checkout is just so that we can show changes in Jenkins
44 checkout(changelog: true,
45 poll: false,
46 scm: [$class: 'RepoScm',
47 manifestRepositoryUrl: "${params.manifestUrl}",
48 manifestBranch: "${params.manifestBranch}",
49 currentBranch: true,
50 destinationDir: 'voltha',
51 forceSync: true,
52 resetFirst: true,
53 quiet: true,
54 jobs: 4,
55 showAllChanges: true]
56 )
hwchiu1f0b0fe2019-12-06 11:45:23 -080057 sh returnStdout: false, script: """
Andy Bavier358aa0b2019-11-22 11:55:39 -070058 cd voltha
59 git clone -b ${branch} ${cordRepoUrl}/cord-tester
Andy Bavier4af02722020-01-15 10:24:24 -070060 mkdir -p $WORKSPACE/bin
61 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/bin"
Andy Bavier358aa0b2019-11-22 11:55:39 -070062 """
63 }
64 }
65 stage('Subscriber Validation and Ping Tests') {
66 environment {
67 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
Andy Bavier358aa0b2019-11-22 11:55:39 -070068 ROBOT_FILE="Voltha_PODTests.robot"
69 }
70 steps {
71 sh """
72 mkdir -p $WORKSPACE/RobotLogs
Suchitra Vemurifbc4a742020-01-08 16:55:26 -080073 if ( ${released} ); then
74 export ROBOT_MISC_ARGS="--removekeywords wuks -i released -i sanity -e bbsim -e notready -d $WORKSPACE/RobotLogs -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir}"
75 else
76 export ROBOT_MISC_ARGS="--removekeywords wuks -e bbsim -e notready -d $WORKSPACE/RobotLogs -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir}"
77 fi
Andy Bavier4af02722020-01-15 10:24:24 -070078 kail -n voltha -n default --since=20m > $WORKSPACE/onos-voltha-combined.log &
Andy Bavier358aa0b2019-11-22 11:55:39 -070079 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
80 """
81 }
82 }
83 }
84
85 post {
86 always {
Andy Bavier4af02722020-01-15 10:24:24 -070087 sh returnStdout: false, script: '''
Andy Bavier358aa0b2019-11-22 11:55:39 -070088 set +e
89 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
90 kubectl get nodes -o wide
91 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -070092
93 sync
94 pkill kail || true
95
96 ## Pull out errors from log files
97 extract_errors_go() {
98 echo
99 echo "Error summary for $1:"
100 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
101 echo
102 }
103
104 extract_errors_python() {
105 echo
106 echo "Error summary for $1:"
107 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
108 echo
109 }
110
111 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
112 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
113 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
114 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
115 '''
Andy Bavier358aa0b2019-11-22 11:55:39 -0700116 script {
117 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800118 sh returnStdout: false, script: """
Andy Bavier358aa0b2019-11-22 11:55:39 -0700119 sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log || true
120 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.ip}.log # Remove escape sequences
121 """
122 }
123 }
124 step([$class: 'RobotPublisher',
125 disableArchiveOutput: false,
126 logFileName: 'RobotLogs/log*.html',
127 otherFiles: '',
128 outputFileName: 'RobotLogs/output*.xml',
129 outputPath: '.',
130 passThreshold: 100,
131 reportFileName: 'RobotLogs/report*.html',
132 unstableThreshold: 0
133 ]);
134 archiveArtifacts artifacts: '*.log'
135 }
136 unstable {
137 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
138 }
139 }
140}