blob: 1949a5bc9e6c69c823715ccab4cb85b34d63692f [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"
136 export TARGET=openonu-go-adapter-test
Matteo Scandolofff6e062020-04-29 13:36:33 -0700137
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200138 make -C $WORKSPACE/voltha/voltha-system-tests \$TARGET || true
Matteo Scandolofff6e062020-04-29 13:36:33 -0700139 '''
140 }
141 }
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200142
Matteo Scandolofff6e062020-04-29 13:36:33 -0700143 }
144
145 post {
146 always {
147 sh '''
148 set +e
149 cp $WORKSPACE/voltha/kind-voltha/install-minimal.log $WORKSPACE/
150 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\n'}" | sort | uniq
151 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.imageID}{'\\n'}" | sort | uniq
152 kubectl get nodes -o wide
153 kubectl get pods -o wide
154 kubectl get pods -n voltha -o wide
155
156 sync
157 pkill kail || true
158 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
159
160 ## Pull out errors from log files
161 extract_errors_go() {
162 echo
163 echo "Error summary for $1:"
164 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
165 echo
166 }
167
168 extract_errors_python() {
169 echo
170 echo "Error summary for $1:"
171 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
172 echo
173 }
174
175 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
176 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
177 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
178 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
179
180 gzip $WORKSPACE/onos-voltha-combined.log
181
182
183 ## shut down kind-voltha
184 if [ "${branch}" != "master" ]; then
185 echo "on branch: ${branch}, sourcing kind-voltha/releases/${branch}"
186 source "$WORKSPACE/voltha/kind-voltha/releases/${branch}"
187 else
188 echo "on master, using default settings for kind-voltha"
189 fi
190
191 cd $WORKSPACE/voltha/kind-voltha
192 WAIT_ON_DOWN=y ./voltha down
193 '''
Andrea Campanella40ff56f2020-05-11 15:22:29 +0200194 step([$class: 'RobotPublisher',
195 disableArchiveOutput: false,
196 logFileName: 'RobotLogs/*/log*.html',
197 otherFiles: '',
198 outputFileName: 'RobotLogs/*/output*.xml',
199 outputPath: '.',
200 passThreshold: 100,
201 reportFileName: 'RobotLogs/*/report*.html',
202 unstableThreshold: 0]);
Matteo Scandolofff6e062020-04-29 13:36:33 -0700203 archiveArtifacts artifacts: '*.log,*.gz'
204 }
205 }
206}