blob: 688414463ed4a08a60f0744917cf9b701526f68a [file] [log] [blame]
Scott Bakerff887712020-04-29 13:39:41 -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"
Scott Baker7726bf12020-04-30 11:07:57 -070031 PATH="$WORKSPACE/voltha/kind-voltha/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Scott Bakerff887712020-04-29 13:39:41 -070032 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.manifestBranch}", \
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 """
Scott Baker7726bf12020-04-30 11:07:57 -070066 pushd $WORKSPACE/
67 echo "${gerritProject}" "${gerritChangeNumber}" "${gerritPatchsetNumber}"
68 echo "${GERRIT_REFSPEC}"
69 git clone https://gerrit.opencord.org/${gerritProject}
70 cd "${gerritProject}"
71 git fetch https://gerrit.opencord.org/${gerritProject} "${GERRIT_REFSPEC}" && git checkout FETCH_HEAD
Scott Bakerff887712020-04-29 13:39:41 -070072 popd
73 """
74 }
75 }
76 stage('Create K8s Cluster') {
77 steps {
78 sh """
Scott Baker7726bf12020-04-30 11:07:57 -070079 cd $WORKSPACE/voltha/kind-voltha/
Scott Bakerff887712020-04-29 13:39:41 -070080 JUST_K8S=y ./voltha up
Scott Baker7726bf12020-04-30 11:07:57 -070081 bash <( curl -sfL https://raw.githubusercontent.com/boz/kail/master/godownloader.sh) -b "$WORKSPACE/voltha/kind-voltha/bin"
Scott Bakerff887712020-04-29 13:39:41 -070082 """
83 }
84 }
85
Scott Baker7726bf12020-04-30 11:07:57 -070086 stage('Build Redfish Importer Image') {
Scott Bakerff887712020-04-29 13:39:41 -070087 steps {
88 sh """
Scott Baker7726bf12020-04-30 11:07:57 -070089 make -C $WORKSPACE/device-management/\$1 DOCKER_REPOSITORY=opencord/ DOCKER_TAG=citest docker-build-importer
90 """
91 }
92 }
93
94 stage('Build demo_test Image') {
95 steps {
96 sh """
97 make -C $WORKSPACE/device-management/\$1/demo_test DOCKER_REPOSITORY=opencord/ DOCKER_TAG=citest docker-build
98 """
99 }
100 }
101
102 stage('Build mock-redfish-server Image') {
103 steps {
104 sh """
105 make -C $WORKSPACE/device-management/\$1/mock-redfish-server DOCKER_REPOSITORY=opencord/ DOCKER_TAG=citest docker-build
Scott Bakerff887712020-04-29 13:39:41 -0700106 """
107 }
108 }
109
110 stage('Push Images') {
111 steps {
112 sh '''
Scott Bakerff887712020-04-29 13:39:41 -0700113 docker images | grep citest
114 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
115 '''
116 }
117 }
118 stage('Deploy Voltha') {
119 steps {
120 sh '''
121 export EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${extraHelmFlags} "
122
Scott Baker7726bf12020-04-30 11:07:57 -0700123 cd $WORKSPACE/voltha/kind-voltha/
Scott Bakerff887712020-04-29 13:39:41 -0700124 echo \$EXTRA_HELM_FLAGS
125 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
126 ./voltha up
127 '''
128 }
129 }
130
131 stage('Run E2E Tests') {
132 steps {
133 sh '''
134 mkdir -p $WORKSPACE/RobotLogs
135
136 # tell the kubernetes script to use images tagged citest and pullPolicy:Never
Scott Baker1ace6d72020-05-01 14:54:41 -0700137 sed -i 's/master/citest/g' $WORKSPACE/device-management/kubernetes/deploy*.yaml
138 sed -i 's/imagePullPolicy: Always/imagePullPolicy: Never/g' $WORKSPACE/device-management/kubernetes/deploy*.yaml
Scott Baker7726bf12020-04-30 11:07:57 -0700139 make -C $WORKSPACE/device-management functional-mock-test || true
Scott Bakerff887712020-04-29 13:39:41 -0700140 '''
141 }
142 }
143 }
144
145 post {
146 always {
147 sh '''
148 set +e
Scott Baker7726bf12020-04-30 11:07:57 -0700149 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
Scott Bakerff887712020-04-29 13:39:41 -0700152 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
Scott Baker7726bf12020-04-30 11:07:57 -0700158 md5sum $WORKSPACE/voltha/kind-voltha/bin/voltctl
Scott Bakerff887712020-04-29 13:39:41 -0700159
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 ## shut down kind-voltha
Scott Baker7726bf12020-04-30 11:07:57 -0700183 cd $WORKSPACE/voltha/kind-voltha
Scott Bakerff887712020-04-29 13:39:41 -0700184 WAIT_ON_DOWN=y ./voltha down
185 '''
186 step([$class: 'RobotPublisher',
187 disableArchiveOutput: false,
188 logFileName: 'RobotLogs/log*.html',
189 otherFiles: '',
190 outputFileName: 'RobotLogs/output*.xml',
191 outputPath: '.',
192 passThreshold: 80,
193 reportFileName: 'RobotLogs/report*.html',
194 unstableThreshold: 0]);
195 archiveArtifacts artifacts: '*.log,*.gz'
196 }
197 }
198}