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