blob: a562fd52b53827fc30f7a074e829932b8cf7b912 [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}"
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/
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
Andy Bavier0088c212020-01-08 13:44:03 -0700106 helm delete --purge bbsim # VOL-2342
107 helm delete --purge onos # VOL-2343, VOL-2363
108 clear_etcd service/voltha/resource_manager
109 clear_etcd service/voltha/openolt
110 clear_etcd service/voltha/devices
111 sleep 30
112 DEPLOY_K8S=no ./voltha up # Will just re-deploy BBSim and ONOS
113 fi
114 done
115 '''
116 }
117 }
118 }
119
120 post {
121 always {
122 sh '''
123 set +e
124 cd kind-voltha/
125 cp install-minimal.log $WORKSPACE/
126 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
127 kubectl get nodes -o wide
128 kubectl get pods -o wide
129 kubectl get pods -n voltha -o wide
130 ## get default pod logs
131 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
132 do
133 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
134 kubectl logs \$pod onos> $WORKSPACE/\$pod.log;
135 else
136 kubectl logs \$pod> $WORKSPACE/\$pod.log;
137 fi
138 done
139 ## get voltha pod logs
140 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
141 do
142 if [[ \$pod == *"-api-"* ]]; then
143 kubectl logs \$pod arouter -n voltha > $WORKSPACE/\$pod.log;
144 else
145 kubectl logs \$pod -n voltha > $WORKSPACE/\$pod.log;
146 fi
147 done
148 ## shut down voltha
149 WAIT_ON_DOWN=y ./voltha down
150 '''
151 step([$class: 'RobotPublisher',
152 disableArchiveOutput: false,
153 logFileName: 'RobotLogs/log*.html',
154 otherFiles: '',
155 outputFileName: 'RobotLogs/output*.xml',
156 outputPath: '.',
157 passThreshold: 100,
158 reportFileName: 'RobotLogs/report*.html',
159 unstableThreshold: 0]);
160 archiveArtifacts artifacts: '*.log'
161
162 }
163 }
164}