yardstick: Remove iptables rules only if they exist
[releng.git] / jjb / yardstick / yardstick-ci-jobs.yml
1 ###################################
2 # job configuration for functest
3 ###################################
4 - project:
5     name: yardstick
6
7     project: '{name}'
8
9 #--------------------------------
10 # BRANCH ANCHORS
11 #--------------------------------
12     master: &master
13         stream: master
14         branch: '{stream}'
15         gs-pathname: ''
16     brahmaputra: &brahmaputra
17         stream: brahmaputra
18         branch: 'stable/{stream}'
19         gs-pathname: '{stream}'
20 #--------------------------------
21 # POD, INSTALLER, AND BRANCH MAPPING
22 #--------------------------------
23 #        brahmaputra
24 #--------------------------------
25     pod:
26         - opnfv-jump-1:
27             installer: apex
28             <<: *brahmaputra
29         - opnfv-jump-2:
30             installer: fuel
31             <<: *brahmaputra
32         - intel-pod5:
33             installer: joid
34             <<: *brahmaputra
35         - huawei-us-deploy-bare-1:
36             installer: compass
37             <<: *brahmaputra
38 #--------------------------------
39 #        master
40 #--------------------------------
41         - ericsson-pod1:
42             installer: fuel
43             <<: *master
44         - ericsson-pod2:
45             installer: fuel
46             <<: *master
47         - intel-pod6:
48             installer: joid
49             <<: *master
50         - intel-pod8:
51             installer: compass
52             <<: *master
53         - zte-build-1:
54             installer: fuel
55             <<: *master
56         - orange-pod2:
57             installer: joid
58             <<: *master
59         - opnfv-jump-1:
60             installer: apex
61             <<: *master
62 #--------------------------------
63     loop:
64         - daily
65
66     jobs:
67         - 'yardstick-{installer}-{pod}-{loop}-{stream}'
68
69 ################################
70 # job templates
71 ################################
72 - job-template:
73     name: 'yardstick-{installer}-{pod}-{loop}-{stream}'
74
75     disabled: false
76
77     wrappers:
78         - build-name:
79             name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO'
80
81     parameters:
82         - project-parameter:
83             project: '{project}'
84         - '{pod}-defaults'
85         - '{installer}-defaults'
86         - 'yardstick-params-{pod}'
87         - string:
88             name: YARDSTICK_SUITE_NAME
89             default: opnfv_${{NODE_NAME}}_{loop}.yaml
90             description: 'Path to test suite'
91         - string:
92             name: CI_DEBUG
93             default: 'false'
94             description: "Show debut output information"
95
96     scm:
97         - git-scm:
98             credentials-id: '{ssh-credentials}'
99             refspec: ''
100             branch: '{branch}'
101
102     builders:
103         - 'yardstick-cleanup'
104         #- 'yardstick-fetch-os-creds'
105         - 'yardstick-daily'
106
107     publishers:
108         - email:
109             recipients: ana.cunha@ericsson.com jorgen.w.karlsson@ericsson.com
110
111 ########################
112 # builder macros
113 ########################
114 - builder:
115     name: yardstick-daily
116     builders:
117         - shell: |
118             #!/bin/bash
119             set -e
120             [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
121
122             # labconfig is used only for joid
123             labconfig=""
124             sshkey=""
125             if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
126                 instack_mac=$(sudo virsh domiflist instack | grep default | \
127                               grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
128                 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
129                 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
130                 if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
131                     #note: this happens only in opnfv-lf-pod1
132                     sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
133                     sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
134                 fi
135             elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
136                 # If production lab then creds may be retrieved dynamically
137                 # creds are on the jumphost, always in the same folder
138                 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/openrc"
139                 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
140                 # replace the default one by the customized one provided by jenkins config
141             fi
142
143             opts="--privileged=true --rm"
144             envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NETWORK=${EXTERNAL_NETWORK} -e YARDSTICK_BRANCH=${GIT_BRANCH##origin/}"
145
146             # Pull the latest image
147             docker pull opnfv/yardstick >$redirect
148
149             # Run docker
150             cmd="sudo docker run ${opts} ${envs} ${labconfig} ${sshkey} opnfv/yardstick run_tests.sh ${YARDSTICK_DB_BACKEND} ${YARDSTICK_SUITE_NAME}"
151             echo "Yardstick: Running docker cmd: ${cmd}"
152             ${cmd}
153
154             echo "Yardstick: done!"
155
156 - builder:
157     name: yardstick-fetch-os-creds
158     builders:
159         - shell:
160             !include-raw: ../../utils/fetch_os_creds.sh
161
162 - builder:
163     name: yardstick-cleanup
164     builders:
165         - shell: |
166             #!/bin/bash
167             [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
168
169             echo "Cleaning up docker containers/images..."
170             # Remove previous running containers if exist
171             if [[ ! -z $(docker ps -a | grep opnfv/yardstick) ]]; then
172                 echo "Removing existing opnfv/yardstick containers..."
173                 docker ps -a | grep opnfv/yardstick | awk '{print $1}' | xargs docker rm -f >$redirect
174
175             fi
176
177             # Remove existing images if exist
178             if [[ ! -z $(docker images | grep opnfv/yardstick) ]]; then
179                 echo "Docker images to remove:"
180                 docker images | head -1 && docker images | grep opnfv/yardstick
181                 image_tags=($(docker images | grep opnfv/yardstick | awk '{print $2}'))
182                 for tag in "${image_tags[@]}"; do
183                     echo "Removing docker image opnfv/yardstick:$tag..."
184                     docker rmi opnfv/yardstick:$tag >$redirect
185
186                 done
187             fi
188 ########################
189 # parameter macros
190 ########################
191 - parameter:
192     name: 'yardstick-params-intel-pod5'
193     parameters:
194         - string:
195             name: YARDSTICK_DB_BACKEND
196             default: ''
197             description: 'Arguments to use in order to choose the backend DB'
198
199 - parameter:
200     name: 'yardstick-params-intel-pod6'
201     parameters:
202         - string:
203             name: YARDSTICK_DB_BACKEND
204             default: ''
205             description: 'Arguments to use in order to choose the backend DB'
206
207 - parameter:
208     name: 'yardstick-params-intel-pod8'
209     parameters:
210         - string:
211             name: YARDSTICK_DB_BACKEND
212             default: ''
213             description: 'Arguments to use in order to choose the backend DB'
214
215 - parameter:
216     name: 'yardstick-params-ericsson-pod1'
217     parameters:
218         - string:
219             name: YARDSTICK_DB_BACKEND
220             default: '-i 10.118.36.90:8086'
221             description: 'Arguments to use in order to choose the backend DB'
222
223 - parameter:
224     name: 'yardstick-params-ericsson-pod2'
225     parameters:
226         - string:
227             name: YARDSTICK_DB_BACKEND
228             default: '-i 10.118.36.90:8086'
229             description: 'Arguments to use in order to choose the backend DB'
230 - parameter:
231     name: 'yardstick-params-opnfv-jump-1'
232     parameters:
233         - string:
234             name: YARDSTICK_DB_BACKEND
235             default: '-r 213.77.62.197/results'
236             description: 'Arguments to use in order to choose the backend DB'
237 - parameter:
238     name: 'yardstick-params-opnfv-jump-2'
239     parameters:
240         - string:
241             name: YARDSTICK_DB_BACKEND
242             default: '-r 213.77.62.197/results'
243             description: 'Arguments to use in order to choose the backend DB'
244
245 - parameter:
246     name: 'yardstick-params-huawei-us-deploy-bare-1'
247     parameters:
248         - string:
249             name: YARDSTICK_DB_BACKEND
250             default: ''
251             description: 'Arguments to use in order to choose the backend DB'
252
253 - parameter:
254     name: 'yardstick-params-zte-build-1'
255     parameters:
256         - string:
257             name: YARDSTICK_DB_BACKEND
258             default: ''
259             description: 'Arguments to use in order to choose the backend DB'
260
261 - parameter:
262     name: 'yardstick-params-orange-pod2'
263     parameters:
264         - string:
265             name: YARDSTICK_DB_BACKEND
266             default: ''
267             description: 'Arguments to use in order to choose the backend DB'