blob: 8aa703ecf0ba1df7d9c00c5dfd74c9208782c296 [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"
32 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin"
33 }
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
60 git clone -b ${branch} ${cordRepoUrl}/voltha # NOTE do we need the voltha source code??
61 """
62 }
63 }
64 stage('Subscriber Validation and Ping Tests') {
65 environment {
66 ROBOT_CONFIG_FILE="$WORKSPACE/${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
Andy Bavier358aa0b2019-11-22 11:55:39 -070067 ROBOT_FILE="Voltha_PODTests.robot"
68 }
69 steps {
70 sh """
71 mkdir -p $WORKSPACE/RobotLogs
Suchitra Vemurifbc4a742020-01-08 16:55:26 -080072 if ( ${released} ); then
73 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}"
74 else
75 export ROBOT_MISC_ARGS="--removekeywords wuks -e bbsim -e notready -d $WORKSPACE/RobotLogs -v POD_NAME:${configFileName} -v KUBERNETES_CONFIGS_DIR:$WORKSPACE/${configBaseDir}/${configKubernetesDir}"
76 fi
Andy Bavier358aa0b2019-11-22 11:55:39 -070077 make -C $WORKSPACE/voltha/voltha-system-tests voltha-test || true
78 """
79 }
80 }
81 }
82
83 post {
84 always {
hwchiu1f0b0fe2019-12-06 11:45:23 -080085 sh returnStdout: false, script: """
Andy Bavier358aa0b2019-11-22 11:55:39 -070086 set +e
87 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
88 kubectl get nodes -o wide
89 kubectl get pods -n voltha -o wide
90 ## get default pod logs
91 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
92 do
93 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
94 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
95 else
96 kubectl logs \$pod> $WORKSPACE/\$pod.log;
97 fi
98 done
99 ## get voltha pod logs
100 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
101 do
102 if [[ \$pod == *"-api-"* ]]; then
103 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
104 else
105 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
106 fi
107 done
108 """
109 script {
110 deployment_config.olts.each { olt ->
hwchiu1f0b0fe2019-12-06 11:45:23 -0800111 sh returnStdout: false, script: """
Andy Bavier358aa0b2019-11-22 11:55:39 -0700112 sshpass -p ${olt.pass} scp ${olt.user}@${olt.ip}:/var/log/openolt.log $WORKSPACE/openolt-${olt.ip}.log || true
113 sed -i 's/\\x1b\\[[0-9;]*[a-zA-Z]//g' $WORKSPACE/openolt-${olt.ip}.log # Remove escape sequences
114 """
115 }
116 }
117 step([$class: 'RobotPublisher',
118 disableArchiveOutput: false,
119 logFileName: 'RobotLogs/log*.html',
120 otherFiles: '',
121 outputFileName: 'RobotLogs/output*.xml',
122 outputPath: '.',
123 passThreshold: 100,
124 reportFileName: 'RobotLogs/report*.html',
125 unstableThreshold: 0
126 ]);
127 archiveArtifacts artifacts: '*.log'
128 }
129 unstable {
130 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
131 }
132 }
133}