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'
85 gs-pathname: '{gs-pathname}'
89 credentials-id: '{ssh-credentials}'
94 - 'functest-{testsuite}-builder'
96 ########################
98 ########################
100 name: functest-daily-parameter
103 name: FUNCTEST_SUITE_NAME
105 description: "Suite name to run"
107 name: functest-suite-parameter
110 name: FUNCTEST_SUITE_NAME
118 name: functest-parameter
122 default: '{gs-pathname}'
123 description: "Version directory where the opnfv documents will be stored in gs repository"
125 name: FUNCTEST_REPO_DIR
126 default: "/home/opnfv/repos/functest"
127 description: "Directory where the Functest repository is cloned"
129 name: PUSH_RESULTS_TO_DB
131 description: "Push the results of all the tests to the resultDB"
132 ########################
134 ########################
136 name: 'functest-master'
140 ########################
142 ########################
144 name: functest-daily-builder
149 - 'functest-store-results'
152 name: functest-suite-builder
158 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
161 echo "Functest: run $FUNCTEST_SUITE_NAME"
162 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flag}"
163 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
164 docker exec $container_id $cmd
173 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
176 echo "Functest: running all the tests"
177 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flag}"
178 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
179 docker exec $container_id $cmd
182 name: set-functest-env
187 # labconfig is used only for joid
189 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
190 instack_mac=$(sudo virsh domiflist instack | grep default | \
191 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
192 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
193 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
194 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
195 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
196 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
197 # If production lab then creds may be retrieved dynamically
198 # creds are on the jumphost, always in the same folder
199 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
200 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
201 # replace the default one by the customized one provided by jenkins config
203 echo "Functest: Start Docker and prepare environment"
204 envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
205 -e NODE_NAME=${NODE_NAME} -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO}"
207 dir_result="${HOME}/opnfv/functest/reports"
208 mkdir -p ${dir_result}
209 rm -rf ${dir_result}/*
210 $res_volume="-v ${dir_result}:/home/opnfv/functest/results"
212 docker pull opnfv/functest:latest_stable
213 cmd="sudo docker run --privileged=true -id -e $envs ${labconfig} ${sshkey} ${res_volume} opnfv/functest:latest_stable /bin/bash"
214 echo "Functest: Running docker run command: ${cmd}"
218 container_id=$(docker ps | grep 'opnfv/functest:latest_stable' | awk '{print $1}' | head -1)
219 echo "Container ID=${container_id}"
220 if [ -z ${container_id} ]; then
221 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
225 echo "Starting the container: docker start ${container_id}"
226 docker start ${container_id}
229 if [ $(docker ps | grep 'opnfv/functest:latest_stable' | wc -l) == 0 ]; then
230 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
233 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
234 echo "Executing command inside the docker: ${cmd}"
235 docker exec ${container_id} ${cmd}
238 name: functest-store-results
241 !include-raw: res-build.sh
244 name: functest-cleanup
249 echo "Cleaning up docker containers/images..."
251 # Remove previous running containers if exist
252 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
253 echo "Removing existing opnfv/functest containers..."
254 docker ps | grep opnfv/functest | awk '{print $1}' | xargs docker stop
255 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm
258 # Remove existing images if exist
259 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
260 echo "Docker images to remove:"
261 docker images | head -1 && docker images | grep opnfv/functest
262 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
263 for tag in "${image_tags[@]}"; do
264 echo "Removing docker image opnfv/functest:$tag..."
265 docker rmi opnfv/functest:$tag