blob: e80be81bc077a965e4e9b0c54c6e0789225d6132 [file] [log] [blame]
Kailash Khalasif0cb0822018-05-18 13:08:02 -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
15PROFILE="null"
16CORE_CONTAINER="null"
17
18pipeline {
19
20 /* no label, executor is determined by JJB */
21 agent {
22 label "${params.executorNode}"
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 """
Kailash Khalasibfa66bb2018-05-18 20:38:11 -070058 if [[ "$GERRIT_PROJECT" =~ ^(platform-install|xos|cord|rcord|vrouter|vsg|vtn|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|cord-tester|kubernetes-service)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -070059 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
67 if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS)\$ ]]; then
68 PROFILE=mcord-cavium-local.yml
69 fi
Kailash Khalasi82887f72018-05-18 13:28:29 -070070 cd $WORKSPACE/cord/build/
Kailash Khalasif0cb0822018-05-18 13:08:02 -070071 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 """
Kailash Khalasibfa66bb2018-05-18 20:38:11 -070082 if [[ "$GERRIT_PROJECT" =~ ^(platform-install|xos|cord|rcord|vrouter|vsg|vtn|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|cord-tester|kubernetes-service)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -070083 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
91 if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS)\$ ]]; then
92 CORE_CONTAINER=mcordcavium_xos_core_1
93 fi
Kailash Khalasi82887f72018-05-18 13:28:29 -070094 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 Khalasif0cb0822018-05-18 13:08:02 -070098 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 Khalasi82887f72018-05-18 13:28:29 -0700101 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 Khalasif0cb0822018-05-18 13:08:02 -0700103 """
104 }
105 }
106 stage('Test') {
107 steps {
108 sh """
Kailash Khalasibfa66bb2018-05-18 20:38:11 -0700109 if [[ "$GERRIT_PROJECT" =~ ^(platform-install|xos|cord|rcord|vrouter|vsg|vtn|vtr|fabric|openstack|chameleon|exampleservice|simpleexampleservice|onos-service|olt-service|cord-tester|kubernetes-service)\$ ]]; then
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700110 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
118 if [[ "$GERRIT_PROJECT" =~ ^(vMME|vHSS)\$ ]]; then
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 Khalasi82887f72018-05-18 13:28:29 -0700128 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 Khalasif0cb0822018-05-18 13:08:02 -0700130 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 Khalasi82887f72018-05-18 13:28:29 -0700133 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 Khalasif0cb0822018-05-18 13:08:02 -0700136 pybot -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 "pybot -d Log -T -e AddressManagerServiceInstance -v TESTLIBRARY:\$i\$library \$i\$testname"; sleep 2; done || true
138 """
139 }
140 }
141 stage('Publish') {
142 steps {
143 sh """
144 if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
Kailash Khalasi82887f72018-05-18 13:28:29 -0700145 cp -r $WORKSPACE/cord/test/cord-tester/src/test/cord-api/Tests/Log/*ml ./RobotLogs
Kailash Khalasif0cb0822018-05-18 13:08:02 -0700146 """
147 step([$class: 'RobotPublisher',
148 disableArchiveOutput: false,
149 logFileName: 'RobotLogs/log*.html',
150 otherFiles: '',
151 outputFileName: 'RobotLogs/output*.xml',
152 outputPath: '.',
153 passThreshold: 95,
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}