blob: 695058386350027044b74090b9e963dab0cb17ef [file] [log] [blame]
Andy Bavier0088c212020-01-08 13:44:03 -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="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/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"
Andy Bavier4af02722020-01-15 10:24:24 -070040 EXTRA_HELM_FLAGS="--set log_agent.enabled=False ${params.extraHelmFlags}"
Andy Bavier4a02b232020-01-09 14:50:30 -070041 ROBOT_MISC_ARGS="${params.extraRobotArgs} -d $WORKSPACE/RobotLogs"
Andy Bavier0088c212020-01-08 13:44:03 -070042 }
43 stages {
44
45 stage('Repo') {
46 steps {
47 step([$class: 'WsCleanup'])
48 checkout(changelog: true,
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
64 stage('Download kind-voltha') {
65 steps {
66 sh """
67 git clone https://github.com/ciena/kind-voltha.git
68 """
69 }
70 }
71
72 stage('Deploy Voltha') {
73 steps {
74 sh """
75 cd kind-voltha/
Andy Bavier4af02722020-01-15 10:24:24 -070076 JUST_K8S=y ./voltha up
77 kail -n voltha -n default > $WORKSPACE/onos-voltha-combined.log &
Andy Bavier0088c212020-01-08 13:44:03 -070078 ./voltha up
79 """
80 }
81 }
82
83 stage('Run E2E Tests') {
84 steps {
85 sh '''
86
87 clear_etcd() {
88 kubectl -n voltha exec $(kubectl -n voltha get pods -lapp=etcd -o=name) -- sh -c "ETCDCTL_API=3 etcdctl del --prefix $1"
89 }
90
Andy Bavier0088c212020-01-08 13:44:03 -070091 mkdir -p $WORKSPACE/RobotLogs
92 git clone https://gerrit.opencord.org/voltha-system-tests
93 cd kind-voltha
94 for i in \$(seq 1 ${testRuns})
95 do
96 make -C $WORKSPACE/voltha-system-tests ${makeTarget}
97 echo "Completed run: \$i"
98 echo ""
99 if [[ \$i -lt ${testRuns} ]]
100 then
101 # For testing multiple back-to-back runs
Andy Bavier93e125e2020-01-17 15:23:50 -0700102 # Work around a known issue in BBSim
103 kubectl -n voltha delete pod -lapp=bbsim
Andy Bavier0088c212020-01-08 13:44:03 -0700104 fi
105 done
106 '''
107 }
108 }
109 }
110
111 post {
112 always {
113 sh '''
114 set +e
Andy Bavier4af02722020-01-15 10:24:24 -0700115 cp $WORKSPACE/kind-voltha/install-minimal.log $WORKSPACE/
Andy Bavier0088c212020-01-08 13:44:03 -0700116 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
117 kubectl get nodes -o wide
118 kubectl get pods -o wide
119 kubectl get pods -n voltha -o wide
Andy Bavier4af02722020-01-15 10:24:24 -0700120
121 sync
122 pkill kail || true
123
124 ## Pull out errors from log files
125 extract_errors_go() {
126 echo
127 echo "Error summary for $1:"
128 grep $1 $WORKSPACE/onos-voltha-combined.log | grep '"level":"error"' | cut -d ' ' -f 2- | jq -r '.msg'
129 echo
130 }
131
132 extract_errors_python() {
133 echo
134 echo "Error summary for $1:"
135 grep $1 $WORKSPACE/onos-voltha-combined.log | grep 'ERROR' | cut -d ' ' -f 2-
136 echo
137 }
138
139 extract_errors_go voltha-rw-core > $WORKSPACE/error-report.log
140 extract_errors_go adapter-open-olt >> $WORKSPACE/error-report.log
141 extract_errors_python adapter-open-onu >> $WORKSPACE/error-report.log
142 extract_errors_python voltha-ofagent >> $WORKSPACE/error-report.log
143
Andy Bavier0088c212020-01-08 13:44:03 -0700144 ## shut down voltha
Andy Bavier4af02722020-01-15 10:24:24 -0700145 cd $WORKSPACE/kind-voltha/
Andy Bavier0088c212020-01-08 13:44:03 -0700146 WAIT_ON_DOWN=y ./voltha down
147 '''
148 step([$class: 'RobotPublisher',
149 disableArchiveOutput: false,
150 logFileName: 'RobotLogs/log*.html',
151 otherFiles: '',
152 outputFileName: 'RobotLogs/output*.xml',
153 outputPath: '.',
154 passThreshold: 100,
155 reportFileName: 'RobotLogs/report*.html',
156 unstableThreshold: 0]);
157 archiveArtifacts artifacts: '*.log'
158
159 }
160 }
161}