blob: 1010e80d0e37042073c597ff4dd219d2fc151fc3 [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 }
41 // stop logging
42 sh """
43 P_IDS="\$(ps e -ww -A | grep "_TAG=kail-${workflow}" | grep -v grep | awk '{print \$1}')"
44 if [ -n "\$P_IDS" ]; then
45 echo \$P_IDS
46 for P_ID in \$P_IDS; do
47 kill -9 \$P_ID
48 done
49 fi
50 """
51 }
52 }
53 stage('Deploy Voltha') {
54 timeout(20) {
55 script {
56
57 // if we're downloading a voltha-helm-charts patch, then install from a local copy of the charts
58 def localCharts = false
59 if (volthaHelmChartsChange != "") {
60 localCharts = true
61 }
62
63 // NOTE temporary workaround expose ONOS node ports
64 def localHelmFlags = extraHelmFlags + " --set onos-classic.onosSshPort=30115 " +
65 " --set onos-classic.onosApiPort=30120 " +
66 " --set onos-classic.onosOfPort=31653 " +
67 " --set onos-classic.individualOpenFlowNodePorts=true " + testSpecificHelmFlags
68 volthaDeploy([
69 infraNamespace: infraNamespace,
70 volthaNamespace: volthaNamespace,
71 workflow: workflow.toLowerCase(),
72 extraHelmFlags: localHelmFlags,
73 localCharts: localCharts,
74 bbsimReplica: olts.toInteger(),
75 dockerRegistry: "mirror.registry.opennetworking.org"
76 ])
77 }
78 // start logging
79 sh """
80 mkdir -p ${outputDir}
81 _TAG=kail-${workflow} kail -n infra -n voltha > ${outputDir}/onos-voltha-combined.log &
82 """
83 sh """
84 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"&
85 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"&
86 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"&
87 ps aux | grep port-forward
88 """
89 getPodsInfo("${outputDir}")
90 }
91 }
92 stage('Run test ' + testTarget + ' on ' + workflow + ' workFlow') {
93 sh """
94 mkdir -p $WORKSPACE/${robotLogsDir}/${testName}
95 export ROBOT_MISC_ARGS="-d $WORKSPACE/${robotLogsDir}/${testName} "
96 ROBOT_MISC_ARGS+="-v ONOS_SSH_PORT:30115 -v ONOS_REST_PORT:30120"
97 export KVSTOREPREFIX=voltha/voltha_voltha
98
99 make -C $WORKSPACE/voltha-system-tests ${testTarget} || true
100 """
101 }
102}
103
104pipeline {
105
106 /* no label, executor is determined by JJB */
107 agent {
108 label "${params.buildNode}"
109 }
110 options {
111 timeout(time: 130, unit: 'MINUTES')
112 }
113 environment {
114 KUBECONFIG="$HOME/.kube/kind-${clusterName}"
115 VOLTCONFIG="$HOME/.volt/config"
116 PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
117 ROBOT_MISC_ARGS="-e PowerSwitch ${params.extraRobotArgs}"
118 DIAGS_PROFILE="VOLTHA_PROFILE"
119 }
120 stages {
121 stage('Download Code') {
122 steps {
123 getVolthaCode([
124 branch: "${branch}",
125 gerritProject: "${gerritProject}",
126 gerritRefspec: "${gerritRefspec}",
127 volthaSystemTestsChange: "${volthaSystemTestsChange}",
128 volthaHelmChartsChange: "${volthaHelmChartsChange}",
129 ])
130 }
131 }
132 stage('Create K8s Cluster') {
133 steps {
134 script {
135 def clusterExists = sh returnStdout: true, script: """
136 kind get clusters | grep ${clusterName} | wc -l
137 """
138 if (clusterExists.trim() == "0") {
139 createKubernetesCluster([nodes: 3, name: clusterName])
140 }
141 }
142 }
143 }
144
145 stage('Run E2E Tests 1t1gem') {
146 steps {
147 execute_test("1t1gem", "att", makeTarget, "$WORKSPACE/1t1gem")
148 }
149 }
150
151 stage('Run E2E Tests 1t4gem') {
152 steps {
153 execute_test("1t4gem", "att", make1t4gemTestTarget, "$WORKSPACE/1t4gem")
154 }
155 }
156
157 stage('Run E2E Tests 1t8gem') {
158 steps {
159 execute_test("1t8gem", "att", make1t8gemTestTarget, "$WORKSPACE/1t8gem")
160 }
161 }
162
163 stage('Run MIB Upload Tests') {
164 when { beforeAgent true; expression { return "${olts}" == "1" } }
165 steps {
166 script {
167 def mibUploadHelmFlags = "--set pon=2,onu=2,controlledActivation=only-onu "
168 execute_test("1t8gem", "att", "mib-upload-templating-openonu-go-adapter-test", "$WORKSPACE/mibupload", mibUploadHelmFlags)
169 }
170 }
171 }
172
173 stage('Reconcile DT workflow') {
174 steps {
175 script {
176 execute_test("ReconcileDT", "dt", makeReconcileDtTestTarget, "$WORKSPACE/ReconcileDT")
177 }
178 }
179 }
180
181 stage('Reconcile ATT workflow') {
182 steps {
183 script {
184 execute_test("ReconcileATT", "att", makeReconcileTestTarget, "$WORKSPACE/ReconcileATT")
185 }
186 }
187 }
188
189 stage('Reconcile TT workflow') {
190 steps {
191 script {
192 execute_test("ReconcileTT", "tt", makeReconcileTtTestTarget, "$WORKSPACE/ReconcileTT")
193 }
194 }
195 }
196 }
197 post {
198 aborted {
199 getPodsInfo("$WORKSPACE/failed")
200 sh """
201 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log
202 """
203 archiveArtifacts artifacts: '**/*.log,**/*.txt,**/*.html'
204 }
205 failure {
206 getPodsInfo("$WORKSPACE/failed")
207 sh """
208 kubectl logs -n voltha -l app.kubernetes.io/part-of=voltha > $WORKSPACE/failed/voltha.log
209 """
210 archiveArtifacts artifacts: '**/*.log,**/*.txt,**/*.html'
211 }
212 always {
213 step([$class: 'RobotPublisher',
214 disableArchiveOutput: false,
215 logFileName: "RobotLogs/*/log*.html",
216 otherFiles: '',
217 outputFileName: "RobotLogs/*/output*.xml",
218 outputPath: '.',
219 passThreshold: 100,
220 reportFileName: "RobotLogs/*/report*.html",
221 unstableThreshold: 0]);
222 archiveArtifacts artifacts: '**/*.log,**/*.gz,**/*.txt,**/*.html'
223 sh '''
224 sync
225 pkill kail || true
226 which voltctl
227 md5sum $(which voltctl)
228 '''
229 }
230 }
231}