blob: 5fd03fe53a82743630d2e1341d0714dc18bfd28e [file] [log] [blame]
Kailash Khalasi97a6bc82018-04-03 09:09:12 -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
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070015PROFILE="null"
16CORE_CONTAINER="null"
17
Kailash Khalasi0ca15922018-04-03 09:40:04 -070018node ('ubuntu16.04-basebuild-4c-8g') {
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070019 stage('Config') {
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070020 sh """
Kailash Khalasia3119722018-05-08 12:22:57 -070021 rm -rf ~/cord/
22 rm -rf ~/cord_profile
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070023 mkdir ~/cord && cd ~/cord/
24 repo init -u https://gerrit.opencord.org/manifest -b $GERRIT_BRANCH
25 repo sync
26 repo download $GERRIT_PROJECT $GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070027 """
28 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070029 try {
30 stage('Build') {
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070031 sh """
Kailash Khalasi945df962018-05-11 06:36:58 -040032 if [ '$GERRIT_PROJECT' = 'platform-install' ] || [ '$GERRIT_PROJECT' = 'xos' ] || [ '$GERRIT_PROJECT' = 'cord' ] || [ '$GERRIT_PROJECT' = 'rcord' ] || [ '$GERRIT_PROJECT' = 'vrouter' ] || [ '$GERRIT_PROJECT' = 'vsg' ] || [ '$GERRIT_PROJECT' = 'vtn' ] || [ '$GERRIT_PROJECT' = 'vtr' ] || [ '$GERRIT_PROJECT' = 'fabric' ] || [ '$GERRIT_PROJECT' = 'openstack' ] || [ '$GERRIT_PROJECT' = 'chameleon' ] || [ '$GERRIT_PROJECT' = 'exampleservice' ] || [ '$GERRIT_PROJECT' = 'simpleexampleservice' ] || [ '$GERRIT_PROJECT' = 'onos-service' ] || [ '$GERRIT_PROJECT' = 'olt-service' ] || [ '$GERRIT_PROJECT' = 'cord-tester' ]; then
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070033 PROFILE=rcord-local.yml
34 fi
35 if [ '$GERRIT_PROJECT' = 'ecord' ] || [ '$GERRIT_PROJECT' = 'vEE' ] || [ '$GERRIT_PROJECT' = 'vEG' ]; then
36 PROFILE=ecord-local.yml
37 fi
38 if [ '$GERRIT_PROJECT' = 'mcord' ] || [ '$GERRIT_PROJECT' = 'vspgwu' ] || [ '$GERRIT_PROJECT' = 'venb' ] || [ '$GERRIT_PROJECT' = 'vspgwc' ] || [ '$GERRIT_PROJECT' = 'vEPC' ]; then
39 PROFILE=mcord-ng40-local.yml
40 fi
41 if [ '$GERRIT_PROJECT' = 'vMME' ] || [ '$GERRIT_PROJECT' = 'vHSS' ]; then
42 PROFILE=mcord-cavium-local.yml
43 fi
44 cd ~/cord/build/
45 make PODCONFIG=\$PROFILE config
46 make -j4 build
Zack Williamsd4f38b12018-05-04 10:15:39 -070047 if [ '$GERRIT_BRANCH' = 'master' ]; then
48 make xos-wait-dynamicload
49 fi
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070050 """
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070051 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070052 stage('Setup') {
53 try {
54 sh """
Kailash Khalasi945df962018-05-11 06:36:58 -040055 if [ '$GERRIT_PROJECT' = 'platform-install' ] || [ '$GERRIT_PROJECT' = 'xos' ] || [ '$GERRIT_PROJECT' = 'cord' ] || [ '$GERRIT_PROJECT' = 'rcord' ] || [ '$GERRIT_PROJECT' = 'vrouter' ] || [ '$GERRIT_PROJECT' = 'vsg' ] || [ '$GERRIT_PROJECT' = 'vtn' ] || [ '$GERRIT_PROJECT' = 'vtr' ] || [ '$GERRIT_PROJECT' = 'fabric' ] || [ '$GERRIT_PROJECT' = 'openstack' ] || [ '$GERRIT_PROJECT' = 'chameleon' ] || [ '$GERRIT_PROJECT' = 'exampleservice' ] || [ '$GERRIT_PROJECT' = 'simpleexampleservice' ] || [ '$GERRIT_PROJECT' = 'onos-service' ] || [ '$GERRIT_PROJECT' = 'olt-service' ] || [ '$GERRIT_PROJECT' = 'cord-tester' ]; then
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070056 CORE_CONTAINER=rcord_xos_core_1
57 fi
58 if [ '$GERRIT_PROJECT' = 'ecord' ] || [ '$GERRIT_PROJECT' = 'vEE' ] || [ '$GERRIT_PROJECT' = 'vEG' ]; then
59 CORE_CONTAINER=ecord_xos_core_1
60 fi
61 if [ '$GERRIT_PROJECT' = 'mcord' ] || [ '$GERRIT_PROJECT' = 'vspgwu' ] || [ '$GERRIT_PROJECT' = 'venb' ] || [ '$GERRIT_PROJECT' = 'vspgwc' ] || [ '$GERRIT_PROJECT' = 'vEPC' ]; then
62 CORE_CONTAINER=mcordng40_xos_core_1
63 fi
64 if [ '$GERRIT_PROJECT' = 'vMME' ] || [ '$GERRIT_PROJECT' = 'vHSS' ]; then
65 CORE_CONTAINER=mcordcavium_xos_core_1
66 fi
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070067 docker cp ~/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosapitests.xtarget
Kailash Khalasi7a02c082018-05-02 09:27:53 -070068 docker cp ~/cord/test/cord-tester/src/test/cord-api/Tests/targets/xosserviceapitests.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xosserviceapitests.xtarget
69 docker cp ~/cord/test/cord-tester/src/test/cord-api/Tests/targets/xoslibrary.xtarget \$CORE_CONTAINER:/opt/xos/lib/xos-genx/xosgenx/targets/xoslibrary.xtarget
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070070 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" > ~/cord/test/cord-tester/src/test/cord-api/Tests/XOSCoreAPITests.robot
71 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
72 export testname=_service_api.robot
Kailash Khalasiecf4d132018-05-02 09:32:26 -070073 export library=_library.robot
Suchitra Vemuri114677f2018-05-02 16:57:17 -070074 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'" > ~/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done
75 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'" > ~/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$library; done
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070076 """
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070077 }
78 catch(error) { currentBuild.result = 'FAILURE' }
79 }
80 stage('Test') {
81 try {
82 sh """
Kailash Khalasi945df962018-05-11 06:36:58 -040083 if [ '$GERRIT_PROJECT' = 'platform-install' ] || [ '$GERRIT_PROJECT' = 'xos' ] || [ '$GERRIT_PROJECT' = 'cord' ] || [ '$GERRIT_PROJECT' = 'rcord' ] || [ '$GERRIT_PROJECT' = 'vrouter' ] || [ '$GERRIT_PROJECT' = 'vsg' ] || [ '$GERRIT_PROJECT' = 'vtn' ] || [ '$GERRIT_PROJECT' = 'vtr' ] || [ '$GERRIT_PROJECT' = 'fabric' ] || [ '$GERRIT_PROJECT' = 'openstack' ] || [ '$GERRIT_PROJECT' = 'chameleon' ] || [ '$GERRIT_PROJECT' = 'exampleservice' ] || [ '$GERRIT_PROJECT' = 'simpleexampleservice' ] || [ '$GERRIT_PROJECT' = 'onos-service' ] || [ '$GERRIT_PROJECT' = 'olt-service' ] || [ '$GERRIT_PROJECT' = 'cord-tester' ]; then
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070084 CORE_CONTAINER=rcord_xos_core_1
85 fi
86 if [ '$GERRIT_PROJECT' = 'ecord' ] || [ '$GERRIT_PROJECT' = 'vEE' ] || [ '$GERRIT_PROJECT' = 'vEG' ]; then
87 CORE_CONTAINER=ecord_xos_core_1
88 fi
89 if [ '$GERRIT_PROJECT' = 'mcord' ] || [ '$GERRIT_PROJECT' = 'vspgwu' ] || [ '$GERRIT_PROJECT' = 'venb' ] || [ '$GERRIT_PROJECT' = 'vspgwc' ] || [ '$GERRIT_PROJECT' = 'vEPC' ]; then
90 CORE_CONTAINER=mcordng40_xos_core_1
91 fi
92 if [ '$GERRIT_PROJECT' = 'vMME' ] || [ '$GERRIT_PROJECT' = 'vHSS' ]; then
93 CORE_CONTAINER=mcordcavium_xos_core_1
94 fi
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070095 export testname=_service_api.robot
Suchitra Vemuri7f260582018-05-02 14:42:17 -070096 export library=_library.robot
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070097 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
98 echo \$SERVICES
Kailash Khalasi68f9f632018-04-11 08:09:19 -070099 export SERVER_IP=localhost
100 export SERVER_PORT=9101
101 export XOS_USER=xosadmin@opencord.org
102 export XOS_PASSWD=\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)
103 cd ~/cord/test/cord-tester/src/test/cord-api/Properties/
Kailash Khalasief947962018-04-27 08:23:15 -0700104 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'127.0.0.1\'/\" RestApiProperties.py
105 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
Kailash Khalasife6c5392018-05-11 07:01:30 -0400106 sed -i \"s/^\\(XOS_USER = \\).*/\\1\'xosadmin@opencord.org\'/\" RestApiProperties.py
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700107 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
Kailash Khalasie34a5922018-04-19 19:28:07 -0700108 sed -i \"s/^\\(PASSWD = \\).*/\\1\'\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
Kailash Khalasi68f9f632018-04-11 08:09:19 -0700109 cd ~/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi4d3af732018-04-12 12:02:04 -0700110 pybot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice -e ControllerUser XOSCoreAPITests.robot || true
Suchitra Vemuri7f260582018-05-02 14:42:17 -0700111 for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700112 """
113 }
114 catch(error) { currentBuild.result = 'FAILURE' }
115 }
116 stage('Publish') {
117 try {
118 sh """
119 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
120 cp -r ~/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
121 """
122 step([$class: 'RobotPublisher',
123 disableArchiveOutput: false,
124 logFileName: 'RobotLogs/log*.html',
125 otherFiles: '',
126 outputFileName: 'RobotLogs/output*.xml',
127 outputPath: '.',
Kailash Khalasi913daaf2018-05-08 12:58:41 -0700128 passThreshold: 95,
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700129 reportFileName: 'RobotLogs/report*.html',
130 unstableThreshold: 0]);
131 }catch(error) {}
132 }
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -0700133 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700134 finally {
Kailash Khalasi0ca15922018-04-03 09:40:04 -0700135 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -0700136 }
Suchitra Vemuri7f260582018-05-02 14:42:17 -0700137}