blob: 2e6633848514945694ec97852f68247935b1f1fd [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 {
Andy Bavier6a801b32020-05-27 12:53:15 -070026 timeout(time: 60, 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"
39 CONFIG_SADIS="no"
Andy Bavier4be37062020-06-29 15:17:26 -070040 ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -070041 }
42 stages {
43
44 stage('Repo') {
45 steps {
46 step([$class: 'WsCleanup'])
47 checkout(changelog: true,
48 poll: false,
49 scm: [$class: 'RepoScm',
50 manifestRepositoryUrl: "${params.manifestUrl}",
51 manifestBranch: "${params.branch}",
52 currentBranch: true,
53 destinationDir: 'voltha',
54 forceSync: true,
55 resetFirst: true,
56 quiet: true,
57 jobs: 4,
58 showAllChanges: true]
59 )
60 }
61 }
62
63 stage('Download kind-voltha') {
64 steps {
65 sh """
66 cd $HOME
67 [ -d kind-voltha ] || git clone https://gerrit.opencord.org/kind-voltha
68 rm -rf $HOME/kind-voltha/scripts/logger
69 cd $HOME/kind-voltha
70 git pull
71 """
72 }
73 }
74
75 stage('Deploy Voltha') {
76 steps {
77 sh """
78 export EXTRA_HELM_FLAGS=""
79 if [ "${branch}" != "master" ]; then
80 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
81 source "$HOME/kind-voltha/releases/${branch}"
82 else
83 echo "on master, using default settings for kind-voltha"
84 fi
85
86 EXTRA_HELM_FLAGS+="--set log_agent.enabled=False ${params.extraHelmFlags} "
87
88 cd $HOME/kind-voltha/
89 WAIT_ON_DOWN=y DEPLOY_K8S=n ./voltha down || ./voltha down
90 ./voltha up
91 """
92 }
93 }
94
95 stage('Functional Tests') {
96 environment {
97 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FunctionalTests"
98 }
99 steps {
100 sh '''
101 set +e
102 mkdir -p $ROBOT_LOGS_DIR
103 cd $HOME/kind-voltha/scripts
104 ./log-collector.sh > /dev/null &
105 ./log-combine.sh > /dev/null &
106
107 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
108 make -C $WORKSPACE/voltha/voltha-system-tests functional-single-kind || true
109 '''
110 }
111 }
112
Hung-Wei Chiuc72fe1f2020-05-04 13:54:32 -0700113 stage('Alarm Tests') {
114 environment {
115 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/AlarmTests"
116 }
117 steps {
118 sh '''
119 set +e
120 mkdir -p $WORKSPACE/RobotLogs
121
122 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
123 make -C $WORKSPACE/voltha/voltha-system-tests bbsim-alarms-kind || true
124 '''
125 }
126 }
127
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700128 stage('Failure/Recovery Tests') {
129 environment {
130 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureTests"
131 }
132 steps {
133 sh '''
134 set +e
135 mkdir -p $WORKSPACE/RobotLogs
136
137 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
138 make -C $WORKSPACE/voltha/voltha-system-tests bbsim-failurescenarios || true
139 '''
140 }
141 }
142
143 stage('Error Tests') {
144 environment {
145 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ErrorTests"
146 }
147 steps {
148 sh '''
149 set +e
150 mkdir -p $WORKSPACE/RobotLogs
151
152 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
153 make -C $WORKSPACE/voltha/voltha-system-tests bbsim-errorscenarios || true
154 '''
155 }
156 }
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700157 }
158
159 post {
160 always {
161 sh '''
162 set +e
163 cp $HOME/kind-voltha/install-minimal.log $WORKSPACE/
164 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
165 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
166 kubectl get nodes -o wide
167 kubectl get pods -o wide
168 kubectl get pods -n voltha -o wide
169
170 sleep 60 # Wait for log-collector and log-combine to complete
171
172 ## Pull out errors from log files
173 extract_errors_go() {
174 echo
175 echo "Error summary for $1:"
176 grep '"level":"error"' $HOME/kind-voltha/scripts/logger/combined/$1*
177 echo
178 }
179
180 extract_errors_python() {
181 echo
182 echo "Error summary for $1:"
183 grep 'ERROR' $HOME/kind-voltha/scripts/logger/combined/$1*
184 echo
185 }
186
187 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
188 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
189 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
190 extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log
191 extract_errors_python onos >> $WORKSPACE/error-report.log
192
193 cd $HOME/kind-voltha/scripts/logger/combined/
194 tar czf $WORKSPACE/container-logs.tgz *
195
196 cd $WORKSPACE
197 gzip *-combined.log || true
198
199 ## shut down voltha but leave kind-voltha cluster
200 cd $HOME/kind-voltha/
201 DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
Andy Bavierfcae3832020-06-04 08:51:10 -0700202 kubectl delete deployment voltctl || true
Hung-Wei Chiu5ec2edf2020-04-30 14:53:13 -0700203 '''
204 step([$class: 'RobotPublisher',
205 disableArchiveOutput: false,
206 logFileName: '**/log*.html',
207 otherFiles: '',
208 outputFileName: '**/output*.xml',
209 outputPath: 'RobotLogs',
210 passThreshold: 100,
211 reportFileName: '**/report*.html',
212 unstableThreshold: 0]);
213
214 archiveArtifacts artifacts: '*.log,*.gz,*.tgz'
215
216 }
217 }
218}