blob: 447c287ee1dba78aa4cc55dc133fc46392938b11 [file] [log] [blame]
Matteo Scandolofff6e062020-04-29 13:36:33 -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: 90, unit: 'MINUTES')
27 }
28 environment {
29 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
30 VOLTCONFIG="$HOME/.volt/config-minimal"
31 PATH="$WORKSPACE/voltha/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="n"
35 WITH_RADIUS="y"
36 WITH_BBSIM="y"
37 DEPLOY_K8S="y"
38 VOLTHA_LOG_LEVEL="DEBUG"
Andrea Campanellaa0cd5be2020-09-07 15:47:18 +020039 CONFIG_SADIS="external"
40 BBSIM_CFG="configs/bbsim-sadis-att.yaml"
Matteo Scandolofff6e062020-04-29 13:36:33 -070041 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
42 }
43
44 stages {
45
46 stage('Repo') {
47 steps {
48 step([$class: 'WsCleanup'])
49 checkout(changelog: false, \
50 poll: false,
51 scm: [$class: 'RepoScm', \
52 manifestRepositoryUrl: "${params.manifestUrl}", \
53 manifestBranch: "${params.branch}", \
54 currentBranch: true, \
55 destinationDir: 'voltha', \
56 forceSync: true,
57 resetFirst: true, \
58 quiet: true, \
59 jobs: 4, \
60 showAllChanges: true] \
61 )
62 }
63 }
64 stage('Patch') {
65 steps {
66 sh """
67 if [ "${gerritProject}" != "voltha-openonu-adapter-go"]
68 then
69 echo "This pipeline is reserved for 'voltha-openonu-adapter-go' you are probably looking for 'voltha-bbsim-test.groovy'"
70 exit 1
71 fi
72 pushd voltha
73 if [ "${gerritProject}" != "" -a "${gerritChangeNumber}" != "" -a "${gerritPatchsetNumber}" != "" ]
74 then
75 repo download "${gerritProject}" "${gerritChangeNumber}/${gerritPatchsetNumber}"
76 else
77 echo "No patchset to download!"
78 fi
79 popd
80 """
81 }
82 }
83 stage('Create K8s Cluster') {
84 steps {
85 sh """
86 cd $WORKSPACE/voltha/kind-voltha/
87 JUST_K8S=y ./voltha up
88 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin"
89 """
90 }
91 }
92
93 stage('Build Images') {
94 steps {
95 sh """
96 make -C $WORKSPACE/voltha/voltha-openonu-adapter-go DOCKER_REPOSITORY=voltha/ DOCKER_TAG=citest docker-build
97 """
98 }
99 }
100
101 stage('Push Images') {
102 steps {
103 sh '''
104 docker images | grep citest
105 for image in \$(docker images -f "reference=*/*citest" --format "{{.Repository}}"); do echo "Pushing \$image to nodes"; kind load docker-image \$image:citest --name voltha-\$TYPE --nodes voltha-\$TYPE-worker,voltha-\$TYPE-worker2; done
106 '''
107 }
108 }
109 stage('Deploy Voltha') {
110 steps {
111 sh '''
Matteo Scandolof21ae312020-04-29 21:04:15 -0700112 export EXTRA_HELM_FLAGS+="--set use_openonu_adapter_go=true,log_agent.enabled=False ${extraHelmFlags} "
Matteo Scandolofff6e062020-04-29 13:36:33 -0700113
114 IMAGES="adapter_open_onu_go"
115
116 for I in \$IMAGES
117 do
118 EXTRA_HELM_FLAGS+="--set images.\$I.tag=citest,images.\$I.pullPolicy=Never "
119 done
120
121 cd $WORKSPACE/voltha/kind-voltha/
122 echo \$EXTRA_HELM_FLAGS
123 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
124 ./voltha up
125 '''
126 }
127 }
128
129 stage('Run E2E Tests') {
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200130 environment {
131 ROBOT_LOGS_DIR="$WORKSPACE/RobotLogs/openonu-go"
132 }
Matteo Scandolofff6e062020-04-29 13:36:33 -0700133 steps {
134 sh '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200135 mkdir -p $ROBOT_LOGS_DIR
136 export ROBOT_MISC_ARGS="-d $ROBOT_LOGS_DIR"
Andrea Campanella27ddf062020-08-07 10:35:15 +0200137 export TARGET_DEFAULT=openonu-go-adapter-test
Matteo Scandolofff6e062020-04-29 13:36:33 -0700138
Andrea Campanella27ddf062020-08-07 10:35:15 +0200139 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET_DEFAULT || true
140
141 export TARGET_1T8GEM=1t8gem-openonu-go-adapter-test
142
143 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET_1T8GEM || true
Matteo Scandolofff6e062020-04-29 13:36:33 -0700144 '''
145 }
146 }
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200147
Matteo Scandolofff6e062020-04-29 13:36:33 -0700148 }
149
150 post {
151 always {
152 sh '''
153 set +e
154 cp $WORKSPACE/voltha/kind-voltha/install-minimal.log $WORKSPACE/
155 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
156 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
157 kubectl get nodes -o wide
158 kubectl get pods -o wide
159 kubectl get pods -n voltha -o wide
160
161 sync
162 pkill kail || true
163 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
164
165 ## Pull out errors from log files
166 extract_errors_go() {
167 echo
168 echo "Error summary for $1:"
169 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
170 echo
171 }
172
173 extract_errors_python() {
174 echo
175 echo "Error summary for $1:"
176 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
177 echo
178 }
179
180 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
181 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
182 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
183 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
184
185 gzip $WORKSPACE/onos-voltha-combined.log
186
187
188 ## shut down kind-voltha
189 if [ "${branch}" != "master" ]; then
190 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
191 source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
192 else
193 echo "on master, using default settings for kind-voltha"
194 fi
195
196 cd $WORKSPACE/voltha/kind-voltha
197 WAIT_ON_DOWN=y ./voltha down
198 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200199 step([$class: 'RobotPublisher',
200 disableArchiveOutput: false,
201 logFileName: 'RobotLogs/*/log*.html',
202 otherFiles: '',
203 outputFileName: 'RobotLogs/*/output*.xml',
204 outputPath: '.',
205 passThreshold: 100,
206 reportFileName: 'RobotLogs/*/report*.html',
207 unstableThreshold: 0]);
Matteo Scandolofff6e062020-04-29 13:36:33 -0700208 archiveArtifacts artifacts: '*.log,*.gz'
209 }
210 }
211}