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