blob: 51b6795c11d0a0ea609ff1426156d796c35ab6b6 [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 Khalasi97a6bc82018-04-03 09:09:12 -070019node ('ubuntu16.04-basebuild-1c-2g') {
20 stage('Config') {
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -070021 sh """
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070022 sudo rm -rf ~/cord/
23 sudo rm -rf ~/cord_profile
24 sudo rm -rf /opt/cord
25 sudo rm -rf /opt/cord_profile
26 sudo rm -rf /opt/credentials
27 sudo rm -rf /opt/images
28 sudo rm -rf /opt/pki
29 sudo rm -rf ~/.repo/
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 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 Khalasi97a6bc82018-04-03 09:09:12 -070039 if [ '$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
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 Khalasi6a36e3c2018-03-28 09:19:39 -070055 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070056 stage('Setup') {
57 try {
58 sh """
59 if [ '$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 cd ~/cord/test/cord-tester/src/test/cord-api/Properties/
72 sed -i \"s/^\\(SERVER_IP = \\).*/\\1\'127.0.0.1\'/\" RestApiProperties.py
73 sed -i \"s/^\\(SERVER_PORT = \\).*/\\1\'9101\'/\" RestApiProperties.py
74 sed -i \"s/^\\(PASSWD = \\).*/\\1\'\$(cat ~/cord/build/platform-install/credentials/xosadmin@opencord.org)\'/\" RestApiProperties.py
75 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
76 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
77 SERVICES=\$(docker exec -i \$CORE_CONTAINER /bin/bash -c "cd /opt/xos/dynamic_services/;find -name '*.xproto'" | awk -F[//] '{print \$2}')
78 export testname=_service_api.robot
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/./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 -070080 """
Kailash Khalasi97a6bc82018-04-03 09:09:12 -070081 }
82 catch(error) { currentBuild.result = 'FAILURE' }
83 }
84 stage('Test') {
85 try {
86 sh """
87 if [ '$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
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
99 cd ~/cord/test/cord-tester/src/test/cord-api/Tests
100 export testname=_service_api.robot
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
103 pybot -d Log -T -e TenantWithContainer -e Port -e ControllerImages -e ControllerNetwork -e ControllerSlice XOSCoreAPITests.robot || true
104 for i in \$SERVICES; do bash -c "pybot -d Log -T -e AddressManagerServiceInstance -v xos_service:\$i \$i\$testname"; done || true
105 """
106 }
107 catch(error) { currentBuild.result = 'FAILURE' }
108 }
109 stage('Publish') {
110 try {
111 sh """
112 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
113 cp -r ~/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
114 """
115 step([$class: 'RobotPublisher',
116 disableArchiveOutput: false,
117 logFileName: 'RobotLogs/log*.html',
118 otherFiles: '',
119 outputFileName: 'RobotLogs/output*.xml',
120 outputPath: '.',
121 passThreshold: 100,
122 reportFileName: 'RobotLogs/report*.html',
123 unstableThreshold: 0]);
124 }catch(error) {}
125 }
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -0700126 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700127 finally {
128 stage('Cleanup') {
129 sh """
130 cd /home/sdn/cord/build/
131 make PODCONFIG=\$PROFILE config
132 make xos-teardown
133 make clean-local
134 docker images
135 """
136 }
137 step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${RECIPIENTS}", sendToIndividuals: false])
Kailash Khalasi6a36e3c2018-03-28 09:19:39 -0700138 }
Kailash Khalasi97a6bc82018-04-03 09:09:12 -0700139}