blob: 78e6d3a9a21fb9bb1066520bd78ed543f86993aa [file] [log] [blame]
hwchiufdc49242019-11-18 16:37:22 -08001// 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
hwchiu8585b572019-12-16 11:20:43 -080019
hwchiu810c70b2020-01-22 11:20:57 -080020def logKubernetes(prefix) {
21 sh """
22 set +e
23 cd kind-voltha/
24 cp install-minimal.log $WORKSPACE/${prefix}_instsall-minimal.log
25 kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq -c
26 kubectl get nodes -o wide
27 kubectl get pods -o wide
28 kubectl get pods -n voltha -o wide
29 ## get default pod logs
30 for pod in \$(kubectl get pods --no-headers | awk '{print \$1}');
31 do
32 if [[ \$pod == *"onos"* && \$pod != *"onos-service"* ]]; then
33 kubectl logs \$pod onos> $WORKSPACE/${prefix}_\$pod.log;
34 else
35 kubectl logs \$pod> $WORKSPACE/${prefix}_\$pod.log;
36 fi
37 done
38 ## get voltha pod logs
39 for pod in \$(kubectl get pods --no-headers -n voltha | awk '{print \$1}');
40 do
41 if [[ \$pod == *"-api-"* ]]; then
42 kubectl logs \$pod arouter -n voltha > $WORKSPACE/${prefix}_\$pod.log;
43 elif [[ \$pod == "bbsim-"* ]]; then
44 kubectl logs \$pod -n voltha -p > $WORKSPACE/${prefix}_\$pod.log;
45 else
46 kubectl logs \$pod -n voltha > $WORKSPACE/${prefix}_\$pod.log;
47 fi
48 done
49 """
50}
hwchiu8585b572019-12-16 11:20:43 -080051
52
hwchiufdc49242019-11-18 16:37:22 -080053pipeline {
54
55 /* no label, executor is determined by JJB */
56 agent {
57 label "${params.buildNode}"
58 }
59 options {
hwchiu8585b572019-12-16 11:20:43 -080060 timeout(time: 80, unit: 'MINUTES')
hwchiufdc49242019-11-18 16:37:22 -080061 }
62 environment {
63 KUBECONFIG="$HOME/.kube/kind-config-voltha-minimal"
64 VOLTCONFIG="$HOME/.volt/config-minimal"
65 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$WORKSPACE/kind-voltha/bin"
66 TYPE="minimal"
67 FANCY=0
68 WITH_SIM_ADAPTERS="n"
69 WITH_RADIUS="y"
70 WITH_BBSIM="y"
71 DEPLOY_K8S="y"
72 VOLTHA_LOG_LEVEL="DEBUG"
73 CONFIG_SADIS="y"
74 EXTRA_HELM_FLAGS="${params.extraHelmFlags} --set voltha-etcd-cluster.clusterSize=3"
75 ROBOT_MISC_ARGS="-d $WORKSPACE/RobotLogs"
76 }
77 stages {
hwchiufdc49242019-11-18 16:37:22 -080078 stage('Download kind-voltha') {
79 steps {
80 sh """
81 git clone https://github.com/ciena/kind-voltha.git
82 """
83 }
84 }
85
86 stage('Deploy Voltha') {
87 steps {
88 sh """
hwchiuc7d5d032019-12-03 16:42:47 -080089 pushd kind-voltha/
hwchiufdc49242019-11-18 16:37:22 -080090 ./voltha up
hwchiuc7d5d032019-12-03 16:42:47 -080091 popd
hwchiufdc49242019-11-18 16:37:22 -080092 """
93 }
94 }
95
96 stage('Run E2E Tests') {
97 steps {
98 sh '''
99 rm -rf $WORKSPACE/RobotLogs; mkdir -p $WORKSPACE/RobotLogs
100 git clone https://gerrit.opencord.org/voltha-system-tests
hwchiu8585b572019-12-16 11:20:43 -0800101 make ROBOT_DEBUG_LOG_OPT="-l sanity_log.html -r sanity_result.html -o sanity_result.xml" -C $WORKSPACE/voltha-system-tests ${makeTarget}
hwchiufdc49242019-11-18 16:37:22 -0800102 '''
103 }
104 }
105
hwchiu8585b572019-12-16 11:20:43 -0800106 stage('Log the kubernetes for sanity-test') {
107 steps {
108 logKubernetes('sanity_test')
109 }
110 }
hwchiufdc49242019-11-18 16:37:22 -0800111 //Remove this stage once https://jira.opencord.org/browse/VOL-1977 be resolved
hwchiu8585b572019-12-16 11:20:43 -0800112 stage('Deploy Voltha Again for Functional Tests') {
hwchiufdc49242019-11-18 16:37:22 -0800113 steps {
114 sh """
hwchiuc7d5d032019-12-03 16:42:47 -0800115 pushd kind-voltha/
hwchiu8585b572019-12-16 11:20:43 -0800116 WAIT_ON_DOWN=yes DEPLOY_K8S=no ./voltha down
117 DEPLOY_K8S=no ./voltha up
hwchiuc7d5d032019-12-03 16:42:47 -0800118 popd
hwchiufdc49242019-11-18 16:37:22 -0800119 """
120 }
121 }
hwchiu8585b572019-12-16 11:20:43 -0800122
hwchiufdc49242019-11-18 16:37:22 -0800123 stage('Kubernetes Functional Tests') {
124 steps {
125 sh '''
hwchiu8585b572019-12-16 11:20:43 -0800126 make ROBOT_DEBUG_LOG_OPT="-l functional_log.html -r functional_result.html -o functional_output.xml" -C $WORKSPACE/voltha-system-tests system-scale-test
hwchiufdc49242019-11-18 16:37:22 -0800127 '''
128 }
129 }
hwchiu8585b572019-12-16 11:20:43 -0800130
131 stage('Log the kubernetes for functional-test') {
132 steps {
133 logKubernetes('functional')
134 }
135 }
136
137 //Remove this stage once https://jira.opencord.org/browse/VOL-1977 be resolved
138 stage('Deploy Voltha Again for Failure Scenario Tests') {
139 steps {
140 sh """
141 pushd kind-voltha/
142 WAIT_ON_DOWN=yes DEPLOY_K8S=no ./voltha down
143 DEPLOY_K8S=no ./voltha up
144 popd
145 """
146 }
147 }
148
149 stage('Kubernetes Failure Scenario Tests') {
150 steps {
151 sh '''
152 make ROBOT_DEBUG_LOG_OPT="-l failure_log.html -r failure_result.html -o failure_output.xml" -C $WORKSPACE/voltha-system-tests failure-test
153 '''
154 }
155 }
156
157 stage('Log the kubernetes for failure scenario test') {
158 steps {
159 logKubernetes('failure')
160 }
161 }
162
hwchiufdc49242019-11-18 16:37:22 -0800163 }
164
165 post {
hwchiu8585b572019-12-16 11:20:43 -0800166 failure {
167 logKubernetes('last')
168 }
169 aborted {
170 logKubernetes('last')
171 }
hwchiu810c70b2020-01-22 11:20:57 -0800172 cleanup {
hwchiu8585b572019-12-16 11:20:43 -0800173
hwchiufdc49242019-11-18 16:37:22 -0800174 step([$class: 'RobotPublisher',
175 disableArchiveOutput: false,
176 logFileName: 'RobotLogs/*log*.html',
177 otherFiles: '',
178 outputFileName: 'RobotLogs/*output*.xml',
179 outputPath: '.',
180 passThreshold: 100,
181 reportFileName: 'RobotLogs/*report*.html',
182 unstableThreshold: 0]);
183 archiveArtifacts artifacts: '*.log'
184
185 }
186 }
187}