blob: 0001facc263c46a15122dec1c61e610897da40b9 [file] [log] [blame]
Matteo Scandolo075740f2021-04-22 14:52:29 -07001// Copyright 2021-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 for openonu-go
16// uses bbsim to simulate OLT/ONUs
17
18library identifier: 'cord-jenkins-libraries@master',
19 retriever: modernSCM([
20 $class: 'GitSCMSource',
21 remote: 'https://gerrit.opencord.org/ci-management.git'
22])
23
24def clusterName = "kind-ci"
25
26def execute_test(testName, workflow, testTarget, outputDir, testSpecificHelmFlags = "") {
27 def infraNamespace = "default"
28 def volthaNamespace = "voltha"
29 def robotLogsDir = "RobotLogs"
30 stage('Cleanup') {
31 timeout(15) {
32 script {
33 helmTeardown(["default", infraNamespace, volthaNamespace])
34 }
35 timeout(1) {
36 sh returnStdout: false, script: '''
37 # remove orphaned port-forward from different namespaces
38 ps aux | grep port-forw | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9
39 '''
40 }
Matteo Scandolo075740f2021-04-22 14:52:29 -070041 }
42 }
43 stage('Deploy Voltha') {
44 timeout(20) {
45 script {
46
47 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
48 def localCharts = false
49 if (volthaHelmChartsChange != "") {
50 localCharts = true
51 }
52
53 // NOTE temporary workaround expose ONOS node ports
54 def localHelmFlags = extraHelmFlags + " --set onos-classic.onosSshPort=30115 " +
55 " --set onos-classic.onosApiPort=30120 " +
56 " --set onos-classic.onosOfPort=31653 " +
57 " --set onos-classic.individualOpenFlowNodePorts=true " + testSpecificHelmFlags
58 volthaDeploy([
59 infraNamespace: infraNamespace,
60 volthaNamespace: volthaNamespace,
61 workflow: workflow.toLowerCase(),
62 extraHelmFlags: localHelmFlags,
63 localCharts: localCharts,
64 bbsimReplica: olts.toInteger(),
65 dockerRegistry: "mirror.registry.opennetworking.org"
66 ])
67 }
68 // start logging
69 sh """
70 mkdir -p ${outputDir}
71 _TAG=kail-${workflow} kail -n infra -n voltha > ${outputDir}/onos-voltha-combined.log &
72 """
73 sh """
74 JENKINS_NODE_COOKIE="dontKillMe" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${volthaNamespace} svc/voltha-voltha-api 55555:55555; done"&
75 JENKINS_NODE_COOKIE="dontKillMe" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-etcd 2379:2379; done"&
76 JENKINS_NODE_COOKIE="dontKillMe" bash -c "while true; do kubectl port-forward --address 0.0.0.0 -n ${infraNamespace} svc/voltha-infra-kafka 9092:9092; done"&
77 ps aux | grep port-forward
78 """
79 getPodsInfo("${outputDir}")
80 }
81 }
82 stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow') {
83 sh """
84 mkdir -p $WORKSPACE/${robotLogsDir}/${testName}
85 export ROBOT_MISC_ARGS="-d $WORKSPACE/${robotLogsDir}/${testName} "
86 ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120"
87 export KVSTOREPREFIX=voltha/voltha_voltha
88
89 make -C $WORKSPACE/voltha-system-tests ${testTarget} || true
90 """
Matteo Scandolo2cc5b392021-05-03 09:33:18 -070091 // stop logging
92 sh """
93 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${workflow}" | grep -v grep | awk '{print \$1}')"
94 if [ -n "\$P_IDS" ]; then
95 echo \$P_IDS
96 for P_ID in \$P_IDS; do
97 kill -9 \$P_ID
98 done
99 fi
100 """
Matteo Scandolo075740f2021-04-22 14:52:29 -0700101 }
102}
103
Matteo Scandolo2cc5b392021-05-03 09:33:18 -0700104def collectArtifacts(exitStatus) {
105 getPodsInfo("$WORKSPACE/${exitStatus}")
106 sh """
107 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/${exitStatus}/voltha.log
108 """
109 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html'
110 sh '''
111 sync
112 pkill kail || true
113 which voltctl
114 md5sum $(which voltctl)
115 '''
116 step([$class: 'RobotPublisher',
117 disableArchiveOutput: false,
118 logFileName: "RobotLogs/*/log*.html",
119 otherFiles: '',
120 outputFileName: "RobotLogs/*/output*.xml",
121 outputPath: '.',
122 passThreshold: 100,
123 reportFileName: "RobotLogs/*/report*.html",
124 unstableThreshold: 0]);
125}
126
Matteo Scandolo075740f2021-04-22 14:52:29 -0700127pipeline {
128
129 /* no label, executor is determined by JJB */
130 agent {
131 label "${params.buildNode}"
132 }
133 options {
134 timeout(time: 130, unit: 'MINUTES')
135 }
136 environment {
137 KUBECONFIG="$HOME/.kube/kind-${clusterName}"
138 VOLTCONFIG="$HOME/.volt/config"
139 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
140 ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
141 DIAGS_PROFILE="VOLTHA_PROFILE"
142 }
143 stages {
144 stage('Download Code') {
145 steps {
146 getVolthaCode([
147 branch: "${branch}",
148 gerritProject: "${gerritProject}",
149 gerritRefspec: "${gerritRefspec}",
150 volthaSystemTestsChange: "${volthaSystemTestsChange}",
151 volthaHelmChartsChange: "${volthaHelmChartsChange}",
152 ])
153 }
154 }
155 stage('Create K8s Cluster') {
156 steps {
157 script {
158 def clusterExists = sh returnStdout: true, script: """
159 kind get clusters | grep ${clusterName} | wc -l
160 """
161 if (clusterExists.trim() == "0") {
162 createKubernetesCluster([nodes: 3, name: clusterName])
163 }
164 }
165 }
166 }
167
168 stage('Run E2E Tests 1t1gem') {
169 steps {
170 execute_test("1t1gem", "att", makeTarget, "$WORKSPACE/1t1gem")
171 }
172 }
173
174 stage('Run E2E Tests 1t4gem') {
175 steps {
176 execute_test("1t4gem", "att", make1t4gemTestTarget, "$WORKSPACE/1t4gem")
177 }
178 }
179
180 stage('Run E2E Tests 1t8gem') {
181 steps {
182 execute_test("1t8gem", "att", make1t8gemTestTarget, "$WORKSPACE/1t8gem")
183 }
184 }
185
186 stage('Run MIB Upload Tests') {
187 when { beforeAgent true; expression { return "${olts}" == "1" } }
188 steps {
189 script {
190 def mibUploadHelmFlags = "--set pon=2,onu=2,controlledActivation=only-onu "
Matteo Scandolo2cc5b392021-05-03 09:33:18 -0700191 execute_test("mibupload", "att", "mib-upload-templating-openonu-go-adapter-test", "$WORKSPACE/mibupload", mibUploadHelmFlags)
Matteo Scandolo075740f2021-04-22 14:52:29 -0700192 }
193 }
194 }
195
196 stage('Reconcile DT workflow') {
197 steps {
198 script {
199 execute_test("ReconcileDT", "dt", makeReconcileDtTestTarget, "$WORKSPACE/ReconcileDT")
200 }
201 }
202 }
203
204 stage('Reconcile ATT workflow') {
205 steps {
206 script {
207 execute_test("ReconcileATT", "att", makeReconcileTestTarget, "$WORKSPACE/ReconcileATT")
208 }
209 }
210 }
211
212 stage('Reconcile TT workflow') {
213 steps {
214 script {
215 execute_test("ReconcileTT", "tt", makeReconcileTtTestTarget, "$WORKSPACE/ReconcileTT")
216 }
217 }
218 }
219 }
220 post {
221 aborted {
Matteo Scandolo2cc5b392021-05-03 09:33:18 -0700222 collectArtifacts("aborted")
Matteo Scandolo075740f2021-04-22 14:52:29 -0700223 }
224 failure {
Matteo Scandolo2cc5b392021-05-03 09:33:18 -0700225 collectArtifacts("failed")
Matteo Scandolo075740f2021-04-22 14:52:29 -0700226 }
227 always {
Matteo Scandolo2cc5b392021-05-03 09:33:18 -0700228 collectArtifacts("always")
Matteo Scandolo075740f2021-04-22 14:52:29 -0700229 }
230 }
231}