blob: 811bde4a7c9e19cde0e4731bc7d2509ebc8a4c58 [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
15
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070016PROFILE="null"
17CORE_CONTAINER="null"
18
Kailash Khalasi0ca15922018-04-03 09:40:04 -070019node ('ubuntu16.04-basebuild-4c-8g') {
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070020 stage('Config') {
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070021 sh """
Kailash Khalasi3d272f82018-04-03 09:23:28 -070022 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 Khalasi97a6bc82018-04-03 09:09:12 -070030 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 Khalasi6a36e3c2018-03-28 09:19:39 -070034 """
35 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070036 try {
37 stage('Build') {
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070038 sh """
Kailash Khalasi1aa79942018-04-10 14:12:48 -070039 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 Khalasi97a6bc82018-04-03 09:09:12 -070040 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 Khalasi6a36e3c2018-03-28 09:19:39 -070055 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070056 stage('Setup') {
57 try {
58 sh """
Kailash Khalasi1aa79942018-04-10 14:12:48 -070059 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 Khalasi6a36e3c2018-03-28 09:19:39 -070060 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 Khalasi97a6bc82018-04-03 09:09:12 -070071 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
72 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
73 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
74 export testname=_service_api.robot
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/./xosapitests.xtarget /opt/xos/dynamic_services/\$i/\$i.xproto'" > ~/cord/test/cord-tester/src/test/cord-api/Tests/\$i\$testname; 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 Khalasi1aa79942018-04-10 14:12:48 -070083 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 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
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 Khalasi68f9f632018-04-11 08:09:19 -070098 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/
103 sed -i \"s/^\\(XOS_PASSWD = \\).*/\\1\'\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
104 cd ~/cord/test/cord-tester/src/test/cord-api/Tests
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700105 pybot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice XOSCoreAPITests.robot || true
106 for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v xos_service:\$i \$i\$testname"; done || true
107 """
108 }
109 catch(error) { currentBuild.result = 'FAILURE' }
110 }
111 stage('Publish') {
112 try {
113 sh """
114 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
115 cp -r ~/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
116 """
117 step([$class: 'RobotPublisher',
118 disableArchiveOutput: false,
119 logFileName: 'RobotLogs/log*.html',
120 otherFiles: '',
121 outputFileName: 'RobotLogs/output*.xml',
122 outputPath: '.',
123 passThreshold: 100,
124 reportFileName: 'RobotLogs/report*.html',
125 unstableThreshold: 0]);
126 }catch(error) {}
127 }
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -0700128 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700129 finally {
Kailash Khalasi0ca15922018-04-03 09:40:04 -0700130 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "kailash@opennetworking.org", sendToIndividuals: false])
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -0700131 }
Kailash Khalasi56264a32018-04-07 15:14:54 -0700132}