blob: d3d28ab09c0598a4214f842ee749674586cc5547 [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 {
26 timeout(time: 40, unit: 'MINUTES')
27 }
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"
40 ROBOT_MISC_ARGS="${params.extraRobotArgs}"
41 }
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
113 stage('Failure/Recovery Tests') {
114 environment {
115 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/FailureTests"
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-failurescenarios || true
124 '''
125 }
126 }
127
128 stage('Error Tests') {
129 environment {
130 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/ErrorTests"
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-errorscenarios || true
139 '''
140 }
141 }
142
143
144 }
145
146 post {
147 always {
148 sh '''
149 set +e
150 cp $HOME/kind-voltha/install-minimal.log $WORKSPACE/
151 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
152 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
153 kubectl get nodes -o wide
154 kubectl get pods -o wide
155 kubectl get pods -n voltha -o wide
156
157 sleep 60 # Wait for log-collector and log-combine to complete
158
159 ## Pull out errors from log files
160 extract_errors_go() {
161 echo
162 echo "Error summary for $1:"
163 grep '"level":"error"' $HOME/kind-voltha/scripts/logger/combined/$1*
164 echo
165 }
166
167 extract_errors_python() {
168 echo
169 echo "Error summary for $1:"
170 grep 'ERROR' $HOME/kind-voltha/scripts/logger/combined/$1*
171 echo
172 }
173
174 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
175 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
176 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
177 extract_errors_go voltha-ofagent >> $WORKSPACE/error-report.log
178 extract_errors_python onos >> $WORKSPACE/error-report.log
179
180 cd $HOME/kind-voltha/scripts/logger/combined/
181 tar czf $WORKSPACE/container-logs.tgz *
182
183 cd $WORKSPACE
184 gzip *-combined.log || true
185
186 ## shut down voltha but leave kind-voltha cluster
187 cd $HOME/kind-voltha/
188 DEPLOY_K8S=n WAIT_ON_DOWN=y ./voltha down
189 '''
190 step([$class: 'RobotPublisher',
191 disableArchiveOutput: false,
192 logFileName: '**/log*.html',
193 otherFiles: '',
194 outputFileName: '**/output*.xml',
195 outputPath: 'RobotLogs',
196 passThreshold: 100,
197 reportFileName: '**/report*.html',
198 unstableThreshold: 0]);
199
200 archiveArtifacts artifacts: '*.log,*.gz,*.tgz'
201
202 }
203 }
204}