1 ###################################
2 # job configuration for functest
3 ###################################
9 #--------------------------------
11 #--------------------------------
16 brahmaputra: &brahmaputra
18 branch: 'stable/{stream}'
19 gs-pathname: '/{stream}'
20 #--------------------------------
21 # POD, INSTALLER, AND BRANCH MAPPING
22 #--------------------------------
24 #--------------------------------
32 - huawei-us-deploy-bare-1:
35 #--------------------------------
37 #--------------------------------
59 #--------------------------------
66 - 'functest-{installer}-{pod}-{testsuite}-{stream}'
68 ################################
70 ################################
72 name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
76 name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME Scenario: $DEPLOY_SCENARIO'
82 - '{installer}-defaults'
83 - 'functest-{testsuite}-parameter'
86 default: 'os-odl_l2-nofeature-ha'
88 gs-pathname: '{gs-pathname}'
92 credentials-id: '{ssh-credentials}'
97 - 'functest-{testsuite}-builder'
99 ########################
101 ########################
103 name: functest-daily-parameter
106 name: FUNCTEST_SUITE_NAME
108 description: "Suite name to run"
110 name: functest-suite-parameter
113 name: FUNCTEST_SUITE_NAME
125 name: functest-parameter
129 default: '{gs-pathname}'
130 description: "Version directory where the opnfv documents will be stored in gs repository"
132 name: FUNCTEST_REPO_DIR
133 default: "/home/opnfv/repos/functest"
134 description: "Directory where the Functest repository is cloned"
136 name: PUSH_RESULTS_TO_DB
138 description: "Push the results of all the tests to the resultDB"
142 description: "Show debug output information"
143 ########################
145 ########################
147 name: 'functest-master'
151 ########################
153 ########################
155 name: functest-daily-builder
160 - 'functest-store-results'
163 name: functest-suite-builder
169 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
172 echo "Functest: run $FUNCTEST_SUITE_NAME"
173 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flag}"
174 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
175 docker exec $container_id $cmd
184 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
187 echo "Functest: running all the tests"
188 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flag}"
189 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
190 docker exec $container_id $cmd
193 name: set-functest-env
198 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
199 # labconfig is used only for joid
201 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
202 instack_mac=$(sudo virsh domiflist instack | grep default | \
203 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
204 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
205 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
206 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
207 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
208 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
209 # If production lab then creds may be retrieved dynamically
210 # creds are on the jumphost, always in the same folder
211 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
212 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
213 # replace the default one by the customized one provided by jenkins config
215 echo "Functest: Start Docker and prepare environment"
216 envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
217 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
218 -e CI_DEBUG=${CI_DEBUG}"
220 dir_result="${HOME}/opnfv/functest/reports"
221 mkdir -p ${dir_result}
222 sudo rm -rf ${dir_result}/*
223 res_volume="-v ${dir_result}:/home/opnfv/functest/results"
225 docker pull opnfv/functest:latest_stable >$redirect
226 cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:latest_stable /bin/bash"
227 echo "Functest: Running docker run command: ${cmd}"
231 container_id=$(docker ps | grep 'opnfv/functest:latest_stable' | awk '{print $1}' | head -1)
232 echo "Container ID=${container_id}"
233 if [ -z ${container_id} ]; then
234 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
238 echo "Starting the container: docker start ${container_id}"
239 docker start ${container_id}
242 if [ $(docker ps | grep 'opnfv/functest:latest_stable' | wc -l) == 0 ]; then
243 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
246 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
247 echo "Executing command inside the docker: ${cmd}"
248 docker exec ${container_id} ${cmd}
251 name: functest-store-results
254 !include-raw: res-build.sh
257 name: functest-cleanup
261 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
263 echo "Cleaning up docker containers/images..."
264 # Remove previous running containers if exist
265 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
266 echo "Removing existing opnfv/functest containers..."
267 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm -f >$redirect
270 # Remove existing images if exist
271 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
272 echo "Docker images to remove:"
273 docker images | head -1 && docker images | grep opnfv/functest
274 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
275 for tag in "${image_tags[@]}"; do
276 echo "Removing docker image opnfv/functest:$tag..."
277 docker rmi opnfv/functest:$tag >$redirect