Merge "Bottlenecks: run env preparation inside the container"
[releng.git] / jjb / bottlenecks / bottlenecks-ci-jobs.yml
1 ####################################
2 # job configuration for bottlenecks
3 ####################################
4 - project:
5     name: bottlenecks-ci-jobs
6
7     project: 'bottlenecks'
8
9 #--------------------------------
10 # BRANCH ANCHORS
11 #--------------------------------
12     master: &master
13         stream: master
14         branch: '{stream}'
15         #This is used for common project file storage
16         gs-pathname: ''
17         #This is used for different test suite dependent packages storage
18         gs-packagepath: '/{suite}'
19         #docker tag used for version control
20         docker-tag: 'latest'
21     brahmaputra: &brahmaputra
22         stream: brahmaputra
23         branch: 'stable/{stream}'
24         gs-pathname: '/{stream}'
25         gs-packagepath: '/{stream}/{suite}'
26         docker-tag: 'brahmaputra'
27 #--------------------------------
28 # POD, INSTALLER, AND BRANCH MAPPING
29 #--------------------------------
30 #        brahmaputra
31 #--------------------------------
32     pod:
33         - opnfv-jump-2:
34             installer: fuel
35             <<: *brahmaputra
36         - intel-pod5:
37             installer: joid
38             <<: *brahmaputra
39         - huawei-us-deploy-bare-1:
40             installer: compass
41             <<: *brahmaputra
42 #--------------------------------
43 #        master
44 #--------------------------------
45         - ericsson-pod1:
46             installer: fuel
47             <<: *master
48         - ericsson-pod2:
49             installer: fuel
50             <<: *master
51         - intel-pod6:
52             installer: joid
53             <<: *master
54         - intel-pod8:
55             installer: compass
56             <<: *master
57         - zte-build-1:
58             installer: fuel
59             <<: *master
60         - orange-pod2:
61             installer: joid
62             <<: *master
63 #--------------------------------
64     suite:
65         - 'rubbos'
66         - 'vstf'
67
68     jobs:
69         - 'bottlenecks-{installer}-{suite}-{pod}-daily-{stream}'
70
71 ################################
72 # job templates
73 ################################
74 - job-template:
75     name: 'bottlenecks-{installer}-{suite}-{pod}-daily-{stream}'
76
77     disabled: false
78
79     wrappers:
80         - build-name:
81             name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO'
82
83     parameters:
84         - project-parameter:
85             project: '{project}'
86         - '{pod}-defaults'
87         - '{installer}-defaults'
88         - 'bottlenecks-params-{pod}'
89         - string:
90             name: REPO_DIR
91             default: "/home/opnfv/bottlenecks"
92             description: "Directory where the repository is cloned"
93         - string:
94             name: DEPLOY_SCENARIO
95             default: 'os-odl_l2-nofeature-ha'
96         - string:
97             name: GERRIT_REFSPEC_DEBUG
98             default: 'false'
99             description: "Gerrit refspec for debug."
100         - string:
101             name: SUITE_NAME
102             default: '{suite}'
103             description: "test suite name."
104         - string:
105             name: DOCKER_TAG
106             default: '{docker-tag}'
107             description: "docker image tag used for version control"
108
109     scm:
110         - git-scm:
111             credentials-id: '{ssh-credentials}'
112             refspec: ''
113             branch: '{branch}'
114
115     builders:
116         - 'bottlenecks-env-cleanup'
117         - 'bottlenecks-run-suite'
118
119     publishers:
120         - email:
121             recipients: hongbo.tianhongbo@huawei.com matthew.lijun@huawei.com liangqi1@huawei.com sunshine.wang@huawei.com
122
123 ########################
124 # builder macros
125 ########################
126 - builder:
127     name: bottlenecks-env-cleanup
128     builders:
129         - shell: |
130             #!/bin/bash
131             set -e
132             [[ $GERRIT_REFSPEC_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
133
134             echo "Bottlenecks: docker containers/images cleaning up"
135             if [[ ! -z $(docker ps -a | grep opnfv/bottlenecks) ]]; then
136                 echo "removing existing opnfv/bottlenecks containers"
137                 docker ps -a | grep opnfv/bottlenecks | awk '{print $1}' | xargs docker rm -f >$redirect
138             fi
139
140             if [[ ! -z $(docker images | grep opnfv/bottlenecks) ]]; then
141                 echo "Bottlenecks: docker images to remove:"
142                 docker images | head -1 && docker images | grep opnfv/bottlenecks
143                 image_tags=($(docker images | grep opnfv/bottlenecks | awk '{print $2}'))
144                 for tag in "${image_tags[@]}"; do
145                     echo "Removing docker image opnfv/bottlenecks:$tag..."
146                     docker rmi opnfv/bottlenecks:$tag >$redirect
147                 done
148             fi
149
150 - builder:
151     name: bottlenecks-run-suite
152     builders:
153         - shell: |
154             #!/bin/bash
155             set -e
156             [[ $GERRIT_REFSPEC_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
157
158             echo "Bottlenecks: to pull image opnfv/bottlenecks:${DOCKER_TAG}"
159             docker pull opnfv/bottlenecks:$DOCKER_TAG >${redirect}
160
161             echo "Bottlenecks: docker start running"
162             opts="--privileged=true -id"
163             envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
164                   -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NET=${EXTERNAL_NETWORK} \
165                   -e BOTTLENECKS_BRANCH=${BOTTLENECKS_BRANCH} -e GERRIT_REFSPEC_DEBUG=${GERRIT_REFSPEC_DEBUG} \
166                   -e BOTTLENECKS_DB_TARGET=${BOTTLENECKS_DB_TARGET} -e PACKAGE_URL=${PACKAGE_URL}"
167             cmd="sudo docker run ${opts} ${envs} opnfv/bottlenecks:${DOCKER_TAG} /bin/bash"
168             echo "Bottlenecks: docker cmd running ${cmd}"
169             ${cmd} >${redirect}
170
171             echo "Bottlenecks: obtain docker id"
172             container_id=$(docker ps | grep "opnfv/bottlenecks:${DOCKER_TAG}" | awk '{print $1}' | head -1)
173             if [ -z ${container_id} ]; then
174                 echo "Cannot find opnfv/bottlenecks container ID ${container_id}. Please check if it exists."
175                 docker ps -a
176                 exit 1
177             fi
178
179             echo "Bottlenecks: to prepare openstack environment"
180             prepare_env="${REPO_DIR}/ci/prepare_env.sh"
181             echo "Bottlenecks: docker cmd running: ${prepare_env}"
182             sudo docker exec ${container_id} ${prepare_env}
183
184             echo "Bottlenecks: to run testsuite ${SUITE_NAME}"
185             run_testsuite="${REPO_DIR}/run_tests.sh -s ${SUITE_NAME}"
186             echo "Bottlenecks: docker cmd running: ${run_testsuite}"
187             sudo docker exec ${container_id} ${run_testsuite}
188
189 ####################
190 # parameter macros
191 ####################
192
193 - parameter:
194     name: 'bottlenecks-params-intel-pod5'
195     parameters:
196         - string:
197             name: BOTTLENECKS_DB_TARGET
198             default: '213.77.62.197'
199             description: 'Arguments to use in order to choose the backend DB'
200
201 - parameter:
202     name: 'bottlenecks-params-intel-pod6'
203     parameters:
204         - string:
205             name: BOTTLENECKS_DB_TARGET
206             default: '213.77.62.197'
207             description: 'Arguments to use in order to choose the backend DB'
208
209 - parameter:
210     name: 'bottlenecks-params-intel-pod8'
211     parameters:
212         - string:
213             name: BOTTLENECKS_DB_TARGET
214             default: '213.77.62.197'
215             description: 'Arguments to use in order to choose the backend DB'
216
217 - parameter:
218     name: 'bottlenecks-params-ericsson-pod1'
219     parameters:
220         - string:
221             name: BOTTLENECKS_DB_TARGET
222             default: '213.77.62.197'
223             description: 'Arguments to use in order to choose the backend DB'
224
225 - parameter:
226     name: 'bottlenecks-params-ericsson-pod2'
227     parameters:
228         - string:
229             name: BOTTLENECKS_DB_TARGET
230             default: '213.77.62.197'
231             description: 'Arguments to use in order to choose the backend DB'
232
233 - parameter:
234     name: 'bottlenecks-params-opnfv-jump-2'
235     parameters:
236         - string:
237             name: BOTTLENECKS_DB_TARGET
238             default: '213.77.62.197'
239             description: 'Arguments to use in order to choose the backend DB'
240
241 - parameter:
242     name: 'bottlenecks-params-huawei-us-deploy-bare-1'
243     parameters:
244         - string:
245             name: BOTTLENECKS_DB_TARGET
246             default: '213.77.62.197'
247             description: 'Arguments to use in order to choose the backend DB'
248
249 - parameter:
250     name: 'bottlenecks-params-zte-build-1'
251     parameters:
252         - string:
253             name: BOTTLENECKS_DB_TARGET
254             default: '213.77.62.197'
255             description: 'Arguments to use in order to choose the backend DB'
256
257 - parameter:
258     name: 'bottlenecks-params-orange-pod2'
259     parameters:
260         - string:
261             name: BOTTLENECKS_DB_TARGET
262             default: '213.77.62.197'
263             description: 'Arguments to use in order to choose the backend DB'