blob: 1830770031c10d49a3068716d69be6d421c7eeec [file] [log] [blame]
Joey Armstrong518f3572024-02-11 07:56:25 -05001// Copyright 2017-2024 Open Networking Foundation (ONF) and the ONF Contributors
Kailash Khalasif0cb0822018-05-18 13:08:02 -07002//
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
15PROFILE="null"
16CORE_CONTAINER="null"
17
18pipeline {
19
20 /* no label, executor is determined by JJB */
21 agent {
Zack Williamsb3292082019-10-11 17:15:18 -070022 label "${params.buildNode}"
Kailash Khalasif0cb0822018-05-18 13:08:02 -070023 }
24
25 stages {
26
27 stage('repo') {
28 steps {
29 checkout(changelog: false, \
30 poll: false,
31 scm: [$class: 'RepoScm', \
32 manifestRepositoryUrl: "${params.manifestUrl}", \
33 manifestBranch: "${params.manifestBranch}", \
34 currentBranch: true, \
35 destinationDir: 'cord', \
36 forceSync: true,
37 resetFirst: true, \
38 quiet: true, \
39 jobs: 4, \
40 showAllChanges: true] \
41 )
42 }
43 }
44
45 stage('patch') {
46 steps {
47 sh """
48 pushd cord
Zack Williamsde1c6212020-02-24 17:00:17 -070049 PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifests/default.xml)
Kailash Khalasif0cb0822018-05-18 13:08:02 -070050 repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}"
51 popd
52 """
53 }
54 }
55 stage('Build') {
56 steps {
57 sh """
Zack Williamsc4152f82018-07-03 17:12:29 -070058 if [[ "$GERRIT_PROJECT" =~ ^(platform-install|xos|cord|rcord|vrouter|vsg|vtn-service|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|cord-tester|kubernetes-service)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -070059 PROFILE=rcord-local.yml
60 fi
61 if [[ "$GERRIT_PROJECT" =~ ^(ecord|vEE|vEG)\$ ]]; then
62 PROFILE=ecord-local.yml
63 fi
64 if [[ "$GERRIT_PROJECT" =~ ^(mcord|vspgwu|venb|vspgwc|vEPC)\$ ]]; then
65 PROFILE=mcord-ng40-local.yml
66 fi
Kailash Khalasi16e96ca2018-05-30 20:15:55 -070067 if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS|hss_db|epc-service|internetemulator|sdn-controller)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -070068 PROFILE=mcord-cavium-local.yml
69 fi
Kailash Khalasi82887f72018-05-18 13:28:29 -070070 cd $WORKSPACE/cord/build/
Kailash Khalasif0cb0822018-05-18 13:08:02 -070071 make PODCONFIG=\$PROFILE config
72 make -j4 build
73 if [ '$GERRIT_BRANCH' = 'master' ]; then
74 make xos-wait-dynamicload
75 fi
76 """
77 }
78 }
79 stage('Setup') {
80 steps {
81 sh """
Zack Williamsc4152f82018-07-03 17:12:29 -070082 if [[ "$GERRIT_PROJECT" =~ ^(platform-install|xos|cord|rcord|vrouter|vsg|vtn-service|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|cord-tester|kubernetes-service)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -070083 CORE_CONTAINER=rcord_xos_core_1
84 fi
85 if [[ "$GERRIT_PROJECT" =~ ^(ecord|vEE|vEG)\$ ]]; then
86 CORE_CONTAINER=ecord_xos_core_1
87 fi
88 if [[ "$GERRIT_PROJECT" =~ ^(mcord|vspgwu|venb|vspgwc|vEPC)\$ ]]; then
89 CORE_CONTAINER=mcordng40_xos_core_1
90 fi
Kailash Khalasi16e96ca2018-05-30 20:15:55 -070091 if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS|hss_db|epc-service|internetemulator|sdn-controller)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -070092 CORE_CONTAINER=mcordcavium_xos_core_1
93 fi
Kailash Khalasi82887f72018-05-18 13:28:29 -070094 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosapitests.xtarget
95 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
96 docker cp $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
97 docker exec -i \$CORE_CONTAINER /bin/bash -c "xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosapitests.xtarget /opt/xos/core/models/core.xproto" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
Kailash Khalasif0cb0822018-05-18 13:08:02 -070098 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
99 export testname=_service_api.robot
100 export library=_library.robot
Kailash Khalasi82887f72018-05-18 13:28:29 -0700101 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xosserviceapitests.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done
102 for i in \$SERVICES; do bash -c "docker exec -i \$CORE_CONTAINER /bin/bash -c 'xosgenx --target /opt/xos/lib/xos-genx/xosgenx/targets/./xoslibrary.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto /opt/xos/core/models/core.xproto'" > $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$library; done
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700103 """
104 }
105 }
106 stage('Test') {
107 steps {
108 sh """
Zack Williamsc4152f82018-07-03 17:12:29 -0700109 if [[ "$GERRIT_PROJECT" =~ ^(platform-install|xos|cord|rcord|vrouter|vsg|vtn-service|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|cord-tester|kubernetes-service)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700110 CORE_CONTAINER=rcord_xos_core_1
111 fi
112 if [[ "$GERRIT_PROJECT" =~ ^(ecord|vEE|vEG)\$ ]]; then
113 CORE_CONTAINER=ecord_xos_core_1
114 fi
115 if [[ "$GERRIT_PROJECT" =~ ^(mcord|vspgwu|venb|vspgwc|vEPC)\$ ]]; then
116 CORE_CONTAINER=mcordng40_xos_core_1
117 fi
Kailash Khalasi16e96ca2018-05-30 20:15:55 -0700118 if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS|hss_db|epc-service|internetemulator|sdn-controller)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700119 CORE_CONTAINER=mcordcavium_xos_core_1
120 fi
121 export testname=_service_api.robot
122 export library=_library.robot
123 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
124 echo \$SERVICES
125 export SERVER_IP=localhost
126 export SERVER_PORT=9101
127 export XOS_USER=xosadmin@opencord.org
Kailash Khalasi82887f72018-05-18 13:28:29 -0700128 export XOS_PASSWD=\$(cat $WORKSPACE/cord/build/platform-install/credentials/xosadmin@opencord.org)
129 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Properties/
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700130 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'127.0.0.1\'/\" RestApiProperties.py
131 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
132 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'xosadmin@opencord.org\'/\" RestApiProperties.py
Kailash Khalasi82887f72018-05-18 13:28:29 -0700133 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'\$(cat $WORKSPACE/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
134 sed -i \"s/^\\(PASSWD = \\).*/\\1\'\$(cat $WORKSPACE/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
135 cd $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests
Kailashf14606e2018-12-06 14:11:11 -0800136 robot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice -e ControllerUser XOSCoreAPITests.robot || true
137 for i in \$SERVICES; do bash -c "robot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700138 """
139 }
140 }
141 stage('Publish') {
142 steps {
143 sh """
144 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailash Khalasi82887f72018-05-18 13:28:29 -0700145 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700146 """
147 step([$class: 'RobotPublisher',
148 disableArchiveOutput: false,
149 logFileName: 'RobotLogs/log*.html',
150 otherFiles: '',
151 outputFileName: 'RobotLogs/output*.xml',
152 outputPath: '.',
Zack Williamse82f12d2018-07-02 10:08:10 -0700153 passThreshold: 100,
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700154 reportFileName: 'RobotLogs/report*.html',
155 unstableThreshold: 0]);
156 }
157 }
158 }
159 post {
160 always {
161 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
162 }
163 }
164}