blob: ee337e8b1365759b6e0b88c780fd4cb5b88f8cb1 [file] [log] [blame]
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -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
15// voltha-2.x e2e tests
16// uses kind-voltha to deploy voltha-2.X
17// uses bbsim to simulate OLT/ONUs
18
19pipeline {
20
21 /* no label, executor is determined by JJB */
22 agent {
23 label "${params.buildNode}"
24 }
25 options {
Andrea Campanella5e352622020-09-09 20:33:29 +020026 timeout(time: 90, unit: 'MINUTES')
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070027 }
28 environment {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
31 PATH="$HOME/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
32 TYPE="minimal"
33 FANCY=0
34 WITH_SIM_ADAPTERS="no"
35 WITH_RADIUS="yes"
36 WITH_BBSIM="yes"
37 DEPLOY_K8S="yes"
38 VOLTHA_LOG_LEVEL="DEBUG"
Andrea Campanella2a01b5a2020-09-09 11:38:18 +020039 CONFIG_SADIS="external"
40 BBSIM_CFG="configs/bbsim-sadis-att.yaml"
Andy Bavier4be37062020-06-29 15:17:26 -070041 ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
pierventref48ebc12020-07-17 16:01:32 +020042 KARAF_HOME="${params.karafHome}"
43 DIAGS_PROFILE="VOLTHA_PROFILE"
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070044 }
45 stages {
46
47 stage('Repo') {
48 steps {
49 step([$class: 'WsCleanup'])
50 checkout(changelog: true,
51 poll: false,
52 scm: [$class: 'RepoScm',
53 manifestRepositoryUrl: "${params.manifestUrl}",
54 manifestBranch: "${params.branch}",
55 currentBranch: true,
56 destinationDir: 'voltha',
57 forceSync: true,
58 resetFirst: true,
59 quiet: true,
60 jobs: 4,
61 showAllChanges: true]
62 )
63 }
64 }
65
66 stage('Download kind-voltha') {
67 steps {
68 sh """
69 cd $HOME
70 [ -d kind-voltha ] || git clone https://gerrit.opencord.org/kind-voltha
71 rm -rf $HOME/kind-voltha/scripts/logger
72 cd $HOME/kind-voltha
73 git pull
74 """
75 }
76 }
77
78 stage('Deploy Voltha') {
79 steps {
80 sh """
81 export EXTRA_HELM_FLAGS=""
82 if [ "${branch}" != "master" ]; then
83 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
84 source "$HOME/kind-voltha/releases/${branch}"
85 else
86 echo "on master, using default settings for kind-voltha"
87 fi
88
89 EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags} "
90
91 cd $HOME/kind-voltha/
92 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
93 ./voltha up
94 """
95 }
96 }
97
98 stage('Functional Tests') {
99 environment {
100 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests"
101 }
102 steps {
103 sh '''
104 set +e
105 mkdir -p $ROBOT_LOGS_DIR
106 cd $HOME/kind-voltha/scripts
107 ./log-collector.sh > /dev/null &
108 ./log-combine.sh > /dev/null &
109
110 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
111 make -C $WORKSPACE/voltha/voltha-system-tests functional-single-kind || true
112 '''
113 }
114 }
115
Hung-Wei Chiuc72fe1f2020-05-04 13:54:32 -0700116 stage('Alarm Tests') {
117 environment {
118 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/AlarmTests"
119 }
120 steps {
121 sh '''
122 set +e
123 mkdir -p $WORKSPACE/RobotLogs
124
125 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
126 make -C $WORKSPACE/voltha/voltha-system-tests bbsim-alarms-kind || true
127 '''
128 }
129 }
130
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700131 stage('Failure/Recovery Tests') {
132 environment {
133 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureTests"
134 }
135 steps {
136 sh '''
137 set +e
138 mkdir -p $WORKSPACE/RobotLogs
139
140 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
141 make -C $WORKSPACE/voltha/voltha-system-tests bbsim-failurescenarios || true
142 '''
143 }
144 }
145
146 stage('Error Tests') {
147 environment {
148 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ErrorTests"
149 }
150 steps {
151 sh '''
152 set +e
153 mkdir -p $WORKSPACE/RobotLogs
154
155 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
156 make -C $WORKSPACE/voltha/voltha-system-tests bbsim-errorscenarios || true
157 '''
158 }
159 }
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700160 }
161
162 post {
163 always {
164 sh '''
165 set +e
166 cp $HOME/kind-voltha/install-minimal.log $WORKSPACE/
167 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
168 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
169 kubectl get nodes -o wide
170 kubectl get pods -o wide
171 kubectl get pods -n voltha -o wide
172
173 sleep 60 # Wait for log-collector and log-combine to complete
174
175 ## Pull out errors from log files
176 extract_errors_go() {
177 echo
178 echo "Error summary for $1:"
179 grep '"level":"error"' $HOME/kind-voltha/scripts/logger/combined/$1*
180 echo
181 }
182
183 extract_errors_python() {
184 echo
185 echo "Error summary for $1:"
186 grep 'ERROR' $HOME/kind-voltha/scripts/logger/combined/$1*
187 echo
188 }
189
190 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
191 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
192 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
193 extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log
194 extract_errors_python onos >> $WORKSPACE/error-report.log
195
Andrea Campanella9a95cb72020-09-03 11:28:35 +0200196 gzip error-report.log || true
197
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700198 cd $HOME/kind-voltha/scripts/logger/combined/
199 tar czf $WORKSPACE/container-logs.tgz *
200
201 cd $WORKSPACE
202 gzip *-combined.log || true
203
Hung-Wei Chiu9669b7d2020-05-14 12:12:05 -0700204 ## Collect ONOS log
205 wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-k8s
206 wget https://raw.githubusercontent.com/opennetworkinglab/onos/master/tools/package/runtime/bin/onos-diagnostics-profile
207 chmod 755 onos-diagnostics-k8s
pierventref48ebc12020-07-17 16:01:32 +0200208 pod_names=$(kubectl get pods -lapp=onos-onos-classic -o name | cut -d '/' -f2 | tr '\n' ' ')
209 ./onos-diagnostics-k8s ${pod_names}
Hung-Wei Chiu9669b7d2020-05-14 12:12:05 -0700210 cp /tmp/onos-diags.tar.gz $WORKSPACE/onos-diags.tar.gz
211
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700212 ## shut down voltha but leave kind-voltha cluster
213 cd $HOME/kind-voltha/
214 DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
Andy Bavierfcae3832020-06-04 08:51:10 -0700215 kubectl delete deployment voltctl || true
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700216 '''
217 step([$class: 'RobotPublisher',
218 disableArchiveOutput: false,
219 logFileName: '**/log*.html',
220 otherFiles: '',
221 outputFileName: '**/output*.xml',
222 outputPath: 'RobotLogs',
223 passThreshold: 100,
224 reportFileName: '**/report*.html',
225 unstableThreshold: 0]);
226
227 archiveArtifacts artifacts: '*.log,*.gz,*.tgz'
228
229 }
230 }
231}