Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 1 | // 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 | |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 16 | PROFILE="null" |
| 17 | CORE_CONTAINER="null" |
| 18 | |
Kailash Khalasi | 0ca1592 | 2018-04-03 09:40:04 -0700 | [diff] [blame] | 19 | node ('ubuntu16.04-basebuild-4c-8g') { |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 20 | stage('Config') { |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 21 | sh """ |
Kailash Khalasi | 3d272f8 | 2018-04-03 09:23:28 -0700 | [diff] [blame] | 22 | rm -rf ~/cord/ |
| 23 | rm -rf ~/cord_profile |
| 24 | rm -rf /opt/cord |
| 25 | rm -rf /opt/cord_profile |
| 26 | rm -rf /opt/credentials |
| 27 | rm -rf /opt/images |
| 28 | rm -rf /opt/pki |
| 29 | rm -rf ~/.repo/ |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 30 | mkdir ~/cord && cd ~/cord/ |
| 31 | repo init -u https://gerrit.opencord.org/manifest -b $GERRIT_BRANCH |
| 32 | repo sync |
| 33 | repo download $GERRIT_PROJECT $GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 34 | """ |
| 35 | } |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 36 | try { |
| 37 | stage('Build') { |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 38 | sh """ |
Kailash Khalasi | 1aa7994 | 2018-04-10 14:12:48 -0700 | [diff] [blame] | 39 | 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' = 'onos-service' ] || [ '$GERRIT_PROJECT' = 'olt-service' ] || [ '$GERRIT_PROJECT' = 'cord-tester' ]; then |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 40 | PROFILE=rcord-local.yml |
| 41 | fi |
| 42 | if [ '$GERRIT_PROJECT' = 'ecord' ] || [ '$GERRIT_PROJECT' = 'vEE' ] || [ '$GERRIT_PROJECT' = 'vEG' ]; then |
| 43 | PROFILE=ecord-local.yml |
| 44 | fi |
| 45 | if [ '$GERRIT_PROJECT' = 'mcord' ] || [ '$GERRIT_PROJECT' = 'vspgwu' ] || [ '$GERRIT_PROJECT' = 'venb' ] || [ '$GERRIT_PROJECT' = 'vspgwc' ] || [ '$GERRIT_PROJECT' = 'vEPC' ]; then |
| 46 | PROFILE=mcord-ng40-local.yml |
| 47 | fi |
| 48 | if [ '$GERRIT_PROJECT' = 'vMME' ] || [ '$GERRIT_PROJECT' = 'vHSS' ]; then |
| 49 | PROFILE=mcord-cavium-local.yml |
| 50 | fi |
| 51 | cd ~/cord/build/ |
| 52 | make PODCONFIG=\$PROFILE config |
| 53 | make -j4 build |
| 54 | """ |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 55 | } |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 56 | stage('Setup') { |
| 57 | try { |
| 58 | sh """ |
Kailash Khalasi | 1aa7994 | 2018-04-10 14:12:48 -0700 | [diff] [blame] | 59 | 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' = 'onos-service' ] || [ '$GERRIT_PROJECT' = 'olt-service' ] || [ '$GERRIT_PROJECT' = 'cord-tester' ]; then |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 60 | CORE_CONTAINER=rcord_xos_core_1 |
| 61 | fi |
| 62 | if [ '$GERRIT_PROJECT' = 'ecord' ] || [ '$GERRIT_PROJECT' = 'vEE' ] || [ '$GERRIT_PROJECT' = 'vEG' ]; then |
| 63 | CORE_CONTAINER=ecord_xos_core_1 |
| 64 | fi |
| 65 | if [ '$GERRIT_PROJECT' = 'mcord' ] || [ '$GERRIT_PROJECT' = 'vspgwu' ] || [ '$GERRIT_PROJECT' = 'venb' ] || [ '$GERRIT_PROJECT' = 'vspgwc' ] || [ '$GERRIT_PROJECT' = 'vEPC' ]; then |
| 66 | CORE_CONTAINER=mcordng40_xos_core_1 |
| 67 | fi |
| 68 | if [ '$GERRIT_PROJECT' = 'vMME' ] || [ '$GERRIT_PROJECT' = 'vHSS' ]; then |
| 69 | CORE_CONTAINER=mcordcavium_xos_core_1 |
| 70 | fi |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 71 | 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 Khalasi | 7a02c08 | 2018-05-02 09:27:53 -0700 | [diff] [blame] | 72 | 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 |
| 73 | 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 Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 74 | 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 |
| 75 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 76 | export testname=_service_api.robot |
Kailash Khalasi | ecf4d13 | 2018-05-02 09:32:26 -0700 | [diff] [blame] | 77 | export library=_library.robot |
Kailash Khalasi | 7261480 | 2018-05-02 09:21:23 -0700 | [diff] [blame] | 78 | 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'" > ~/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; done |
Kailash Khalasi | ecf4d13 | 2018-05-02 09:32:26 -0700 | [diff] [blame] | 79 | 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'" > ~/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$library; done |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 80 | """ |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 81 | } |
| 82 | catch(error) { currentBuild.result = 'FAILURE' } |
| 83 | } |
| 84 | stage('Test') { |
| 85 | try { |
| 86 | sh """ |
Kailash Khalasi | 1aa7994 | 2018-04-10 14:12:48 -0700 | [diff] [blame] | 87 | 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' = 'onos-service' ] || [ '$GERRIT_PROJECT' = 'olt-service' ] || [ '$GERRIT_PROJECT' = 'cord-tester' ]; then |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 88 | CORE_CONTAINER=rcord_xos_core_1 |
| 89 | fi |
| 90 | if [ '$GERRIT_PROJECT' = 'ecord' ] || [ '$GERRIT_PROJECT' = 'vEE' ] || [ '$GERRIT_PROJECT' = 'vEG' ]; then |
| 91 | CORE_CONTAINER=ecord_xos_core_1 |
| 92 | fi |
| 93 | if [ '$GERRIT_PROJECT' = 'mcord' ] || [ '$GERRIT_PROJECT' = 'vspgwu' ] || [ '$GERRIT_PROJECT' = 'venb' ] || [ '$GERRIT_PROJECT' = 'vspgwc' ] || [ '$GERRIT_PROJECT' = 'vEPC' ]; then |
| 94 | CORE_CONTAINER=mcordng40_xos_core_1 |
| 95 | fi |
| 96 | if [ '$GERRIT_PROJECT' = 'vMME' ] || [ '$GERRIT_PROJECT' = 'vHSS' ]; then |
| 97 | CORE_CONTAINER=mcordcavium_xos_core_1 |
| 98 | fi |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 99 | export testname=_service_api.robot |
Suchitra Vemuri | 7f26058 | 2018-05-02 14:42:17 -0700 | [diff] [blame] | 100 | export library=_library.robot |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 101 | SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}') |
| 102 | echo \$SERVICES |
Kailash Khalasi | 68f9f63 | 2018-04-11 08:09:19 -0700 | [diff] [blame] | 103 | export SERVER_IP=localhost |
| 104 | export SERVER_PORT=9101 |
| 105 | export XOS_USER=xosadmin@opencord.org |
| 106 | export XOS_PASSWD=\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org) |
| 107 | cd ~/cord/test/cord-tester/src/test/cord-api/Properties/ |
Kailash Khalasi | ef94796 | 2018-04-27 08:23:15 -0700 | [diff] [blame] | 108 | sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'127.0.0.1\'/\" RestApiProperties.py |
| 109 | sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py |
Kailash Khalasi | 68f9f63 | 2018-04-11 08:09:19 -0700 | [diff] [blame] | 110 | sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py |
Kailash Khalasi | e34a592 | 2018-04-19 19:28:07 -0700 | [diff] [blame] | 111 | sed -i \"s/^\\(PASSWD = \\).*/\\1\'\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py |
Kailash Khalasi | 68f9f63 | 2018-04-11 08:09:19 -0700 | [diff] [blame] | 112 | cd ~/cord/test/cord-tester/src/test/cord-api/Tests |
Kailash Khalasi | 4d3af73 | 2018-04-12 12:02:04 -0700 | [diff] [blame] | 113 | pybot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice -e ControllerUser XOSCoreAPITests.robot || true |
Suchitra Vemuri | 7f26058 | 2018-05-02 14:42:17 -0700 | [diff] [blame] | 114 | for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 115 | """ |
| 116 | } |
| 117 | catch(error) { currentBuild.result = 'FAILURE' } |
| 118 | } |
| 119 | stage('Publish') { |
| 120 | try { |
| 121 | sh """ |
| 122 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
| 123 | cp -r ~/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs |
| 124 | """ |
| 125 | step([$class: 'RobotPublisher', |
| 126 | disableArchiveOutput: false, |
| 127 | logFileName: 'RobotLogs/log*.html', |
| 128 | otherFiles: '', |
| 129 | outputFileName: 'RobotLogs/output*.xml', |
| 130 | outputPath: '.', |
Kailash Khalasi | a02d4aa | 2018-04-19 16:55:38 -0700 | [diff] [blame] | 131 | passThreshold: 90, |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 132 | reportFileName: 'RobotLogs/report*.html', |
| 133 | unstableThreshold: 0]); |
| 134 | }catch(error) {} |
| 135 | } |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 136 | } |
Kailash Khalasi | 97a6bc8 | 2018-04-03 09:09:12 -0700 | [diff] [blame] | 137 | finally { |
Kailash Khalasi | 0ca1592 | 2018-04-03 09:40:04 -0700 | [diff] [blame] | 138 | step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false]) |
Kailash Khalasi | 6a36e3c | 2018-03-28 09:19:39 -0700 | [diff] [blame] | 139 | } |
Suchitra Vemuri | 7f26058 | 2018-05-02 14:42:17 -0700 | [diff] [blame] | 140 | } |