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 #--------------------------------
25 # everything runs against master branch
26 #--------------------------------
28 - huawei-us-deploy-bare-1:
34 - intel-us-deploy-virtual-2:
46 #--------------------------------
49 #--------------------------------
51 #--------------------------------
52 # - huawei-us-deploy-bare-1:
64 #--------------------------------
66 #--------------------------------
70 # - intelpod2-jumphost:
85 #--------------------------------
92 - 'functest-{installer}-{pod}-{testsuite}-{stream}'
94 ################################
96 ################################
98 name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
102 name: '$BUILD_NUMBER Suite: $FUNCTEST_SUITE_NAME SDN: $SDN_CONTROLLER Feature: $OPNFV_FEATURE'
108 - '{installer}-defaults'
109 - 'functest-{testsuite}-parameter'
114 credentials-id: '{ssh-credentials}'
119 - 'functest-{testsuite}-builder'
121 ########################
123 ########################
125 name: functest-daily-parameter
128 name: FUNCTEST_SUITE_NAME
130 description: "Suite name to run"
132 name: functest-suite-parameter
135 name: FUNCTEST_SUITE_NAME
143 name: functest-parameter
147 default: '{gs-pathname}'
148 description: "Version directory where the opnfv documents will be stored in gs repository"
150 name: FUNCTEST_REPO_DIR
151 default: "/home/opnfv/repos/functest"
152 description: "Directory where the Functest repository is cloned"
154 name: PUSH_RESULTS_TO_DB
156 description: "Push the results of all the tests to the resultDB"
157 ########################
159 ########################
161 name: 'functest-master'
163 - pollscm: "H 9 * * *"
164 ########################
166 ########################
168 name: functest-daily-builder
173 - 'functest-store-results'
176 name: functest-suite-builder
182 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
185 echo "Functest: run $FUNCTEST_SUITE_NAME"
186 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flag}"
187 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
188 docker exec $container_id $cmd
197 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
200 echo "Functest: running all the tests"
201 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flag}"
202 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
203 docker exec $container_id $cmd
206 name: set-functest-env
211 # labconfig is used only for joid
213 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
214 INSTALLER_IP=$(grep instack /var/lib/libvirt/dnsmasq/default.leases \
215 |awk '{print $3}' | head -n 1)
216 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
217 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
218 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
219 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
220 # If production lab then creds may be retrieved dynamically
221 # creds are on the jumphost, always in the same folder
222 labconfig="-v /var/lib/jenkins/joid_config/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
223 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
224 # replace the default one by the customized one provided by jenkins config
225 if [ -n "${LAB_CONFIG}" ]; then
226 labconfig="-v ${LAB_CONFIG}:/home/opnfv/functest/conf/openstack.creds"
229 echo "Functest: Start Docker and prepare environment"
230 envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME}"
232 dir_result="${HOME}/opnfv/functest/reports"
233 mkdir -f ${dir_result}
234 rm -rf ${dir_result}/*
235 $res_volume="-v ${dir_result}:/home/opnfv/functest/results"
237 docker pull opnfv/functest:latest_stable
238 cmd="docker run -id -e $envs ${labconfig} ${sshkey} ${res_volume} opnfv/functest:latest_stable /bin/bash"
239 echo "Functest: Running docker run command: ${cmd}"
243 container_id=$(docker ps | grep 'opnfv/functest:latest_stable' | awk '{print $1}' | head -1)
244 echo "Container ID=${container_id}"
245 if [ -z ${container_id} ]; then
246 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
250 echo "Starting the container: docker start ${container_id}"
251 docker start ${container_id}
254 if [ $(docker ps | grep 'opnfv/functest:latest_stable' | wc -l) == 0 ]; then
255 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
258 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
259 echo "Executing command inside the docker: ${cmd}"
260 docker exec ${container_id} ${cmd}
263 name: functest-store-results
266 !include-raw res-build.sh
269 name: functest-cleanup
274 echo "Cleaning up docker containers/images..."
276 # Remove previous running containers if exist
277 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
278 echo "Removing existing opnfv/functest containers..."
279 docker ps | grep opnfv/functest | awk '{print $1}' | xargs docker stop
280 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm
283 # Remove existing images if exist
284 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
285 echo "Docker images to remove:"
286 docker images | head -1 && docker images | grep opnfv/functest
287 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
288 for tag in "${image_tags[@]}"; do
289 echo "Removing docker image opnfv/functest:$tag..."
290 docker rmi opnfv/functest:$tag