blob: ed2107b5100d8b1b59c24d0b6ef8fa00a2fc95fd [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"
40 EXTRA_HELM_FLAGS="${params.extraHelmFlags}"
41 ROBOT_MISC_ARGS="${params.extraRobotArgs} -d $WORKSPACE/RobotLogs -v teardown_device:False"
42 }
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/
76 ./voltha up
77 """
78 }
79 }
80
81 stage('Run E2E Tests') {
82 steps {
83 sh '''
84
85 clear_etcd() {
86 kubectl -n voltha exec $(kubectl -n voltha get pods -lapp=etcd -o=name) -- sh -c "ETCDCTL_API=3 etcdctl del --prefix $1"
87 }
88
89 wait_for_state_change() {
90 timeout 60 bash -c "until voltctl device list -f Type=$2,AdminState=$3,OperStatus=$4,ConnectStatus=$5 -q | wc -l | grep -q 1; do echo Waiting for $1 to change states; voltctl device list; echo; sleep 5; done"
91 }
92
93 mkdir -p $WORKSPACE/RobotLogs
94 git clone https://gerrit.opencord.org/voltha-system-tests
95 cd kind-voltha
96 for i in \$(seq 1 ${testRuns})
97 do
98 make -C $WORKSPACE/voltha-system-tests ${makeTarget}
99 echo "Completed run: \$i"
100 echo ""
101 if [[ \$i -lt ${testRuns} ]]
102 then
103 # For testing multiple back-to-back runs
104 # Doing some manual cleanup to work around known issues in BBSim and ONOS apps
105
106 OLT=\$( voltctl device list -f Type=openolt -q )
107 ONU=\$( voltctl device list -f Type=brcm_openomci_onu -q )
108
109 voltctl device disable \$OLT
110 wait_for_state_change OLT openolt DISABLED UNKNOWN REACHABLE
111 wait_for_state_change ONU brcm_openomci_onu ENABLED DISCOVERED UNREACHABLE
112
113 voltctl device disable \$ONU
114 wait_for_state_change ONU brcm_openomci_onu DISABLED UNKNOWN UNREACHABLE
115
116 voltctl device delete \$OLT
117
118 timeout 60 bash -c 'until voltctl device list -q | wc -l | grep -q 0; do echo "Waiting for all devices to be deleted"; voltctl device list; echo ""; sleep 5; done'
119
120 helm delete --purge bbsim # VOL-2342
121 helm delete --purge onos # VOL-2343, VOL-2363
122 clear_etcd service/voltha/resource_manager
123 clear_etcd service/voltha/openolt
124 clear_etcd service/voltha/devices
125 sleep 30
126 DEPLOY_K8S=no ./voltha up # Will just re-deploy BBSim and ONOS
127 fi
128 done
129 '''
130 }
131 }
132 }
133
134 post {
135 always {
136 sh '''
137 set +e
138 cd kind-voltha/
139 cp install-minimal.log $WORKSPACE/
140 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
141 kubectl get nodes -o wide
142 kubectl get pods -o wide
143 kubectl get pods -n voltha -o wide
144 ## get default pod logs
145 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
146 do
147 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
148 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
149 else
150 kubectl logs \$pod> $WORKSPACE/\$pod.log;
151 fi
152 done
153 ## get voltha pod logs
154 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
155 do
156 if [[ \$pod == *"-api-"* ]]; then
157 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
158 else
159 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
160 fi
161 done
162 ## shut down voltha
163 WAIT_ON_DOWN=y ./voltha down
164 '''
165 step([$class: 'RobotPublisher',
166 disableArchiveOutput: false,
167 logFileName: 'RobotLogs/log*.html',
168 otherFiles: '',
169 outputFileName: 'RobotLogs/output*.xml',
170 outputPath: '.',
171 passThreshold: 100,
172 reportFileName: 'RobotLogs/report*.html',
173 unstableThreshold: 0]);
174 archiveArtifacts artifacts: '*.log'
175
176 }
177 }
178}