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