Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -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 | PROFILE="null" |
| 16 | CORE_CONTAINER="null" |
| 17 | |
| 18 | pipeline { |
| 19 | |
| 20 | /* no label, executor is determined by JJB */ |
| 21 | agent { |
Zack Williams | b329208 | 2019-10-11 17:15:18 -0700 | [diff] [blame] | 22 | label "${params.buildNode}" |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 23 | } |
| 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 |
| 49 | PROJECT_PATH=\$(xmllint --xpath "string(//project[@name=\\\"${gerritProject}\\\"]/@path)" .repo/manifest.xml) |
| 50 | repo download "\$PROJECT_PATH" "${gerritChangeNumber}/${gerritPatchsetNumber}" |
| 51 | popd |
| 52 | """ |
| 53 | } |
| 54 | } |
| 55 | stage('Build') { |
| 56 | steps { |
| 57 | sh """ |
Zack Williams | c4152f8 | 2018-07-03 17:12:29 -0700 | [diff] [blame] | 58 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 59 | 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 Khalasi | 16e96ca | 2018-05-30 20:15:55 -0700 | [diff] [blame] | 67 | if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS|hss_db|epc-service|internetemulator|sdn-controller)\$ ]]; then |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 68 | PROFILE=mcord-cavium-local.yml |
| 69 | fi |
Kailash Khalasi | 82887f7 | 2018-05-18 13:28:29 -0700 | [diff] [blame] | 70 | cd $WORKSPACE/cord/build/ |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 71 | 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 Williams | c4152f8 | 2018-07-03 17:12:29 -0700 | [diff] [blame] | 82 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 83 | 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 Khalasi | 16e96ca | 2018-05-30 20:15:55 -0700 | [diff] [blame] | 91 | if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS|hss_db|epc-service|internetemulator|sdn-controller)\$ ]]; then |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 92 | CORE_CONTAINER=mcordcavium_xos_core_1 |
| 93 | fi |
Kailash Khalasi | 82887f7 | 2018-05-18 13:28:29 -0700 | [diff] [blame] | 94 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 98 | 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 Khalasi | 82887f7 | 2018-05-18 13:28:29 -0700 | [diff] [blame] | 101 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 103 | """ |
| 104 | } |
| 105 | } |
| 106 | stage('Test') { |
| 107 | steps { |
| 108 | sh """ |
Zack Williams | c4152f8 | 2018-07-03 17:12:29 -0700 | [diff] [blame] | 109 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 110 | 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 Khalasi | 16e96ca | 2018-05-30 20:15:55 -0700 | [diff] [blame] | 118 | if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS|hss_db|epc-service|internetemulator|sdn-controller)\$ ]]; then |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 119 | 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 Khalasi | 82887f7 | 2018-05-18 13:28:29 -0700 | [diff] [blame] | 128 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 130 | 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 Khalasi | 82887f7 | 2018-05-18 13:28:29 -0700 | [diff] [blame] | 133 | 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 |
Kailash | f14606e | 2018-12-06 14:11:11 -0800 | [diff] [blame] | 136 | 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 Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 138 | """ |
| 139 | } |
| 140 | } |
| 141 | stage('Publish') { |
| 142 | steps { |
| 143 | sh """ |
| 144 | if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs |
Kailash Khalasi | 82887f7 | 2018-05-18 13:28:29 -0700 | [diff] [blame] | 145 | cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 146 | """ |
| 147 | step([$class: 'RobotPublisher', |
| 148 | disableArchiveOutput: false, |
| 149 | logFileName: 'RobotLogs/log*.html', |
| 150 | otherFiles: '', |
| 151 | outputFileName: 'RobotLogs/output*.xml', |
| 152 | outputPath: '.', |
Zack Williams | e82f12d | 2018-07-02 10:08:10 -0700 | [diff] [blame] | 153 | passThreshold: 100, |
Kailash Khalasi | f0cb082 | 2018-05-18 13:08:02 -0700 | [diff] [blame] | 154 | 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 | } |