1 ###################################
2 # job configuration for functest
3 ###################################
10 - intel-us-deploy-virtual-2:
18 - huawei-us-deploy-bare-1:
28 - 'functest-{installer}-{pod}-{testsuite}-{stream}'
29 - 'functest-verify-{stream}'
36 # branch: 'stable/brahmaputra'
37 # gs-pathname: '/brahmaputra'
39 ################################
41 ################################
43 name: 'functest-{installer}-{pod}-{testsuite}-{stream}'
47 name: '$BUILD_NUMBER: $FUNCTEST_SUITE_NAME'
53 - '{installer}-defaults'
54 - 'functest-{testsuite}-parameter'
59 credentials-id: '{ssh-credentials}'
64 - 'functest-{testsuite}-builder'
67 name: 'functest-verify-{stream}'
76 credentials-id: '{ssh-credentials}'
77 refspec: '$GERRIT_REFSPEC'
78 choosing-strategy: 'gerrit'
83 - patchset-created-event:
84 exclude-drafts: 'false'
85 exclude-trivial-rebase: 'false'
86 exclude-no-code-change: 'false'
87 - draft-published-event
88 - comment-added-contains-event:
89 comment-contains-value: 'recheck'
90 - comment-added-contains-event:
91 comment-contains-value: 'reverify'
93 - project-compare-type: 'ANT'
94 project-pattern: 'functest'
96 - branch-compare-type: 'ANT'
97 branch-pattern: '**/{branch}'
101 echo "Nothing to verify!"
103 ########################
105 ########################
107 name: functest-daily-parameter
110 name: FUNCTEST_SUITE_NAME
112 description: "Suite name to run"
114 name: functest-suite-parameter
117 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"
139 ########################
141 ########################
143 name: 'functest-master'
145 - pollscm: "H 9 * * *"
146 ########################
148 ########################
150 name: functest-daily-builder
155 - 'functest-store-results'
158 name: functest-suite-builder
164 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
167 echo "Functest: run $FUNCTEST_SUITE_NAME"
168 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flag}"
169 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
170 docker exec $container_id $cmd
179 if [ "${PUSH_RESULTS_TO_DB}" == "true" ]; then
182 echo "Functest: running all the tests"
183 cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh ${flag}"
184 container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
185 docker exec $container_id $cmd
188 name: set-functest-env
193 # labconfig is used only for joid
195 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
196 INSTALLER_IP=$(grep instack /var/lib/libvirt/dnsmasq/default.leases \
197 |awk '{print $3}' | head -n 1)
198 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
199 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
200 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
201 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
202 # If production lab then creds may be retrieved dynamically
203 # creds are on the jumphost, always in the same folder
204 labconfig="-v ${HOME}/joid_config/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
205 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
206 # replace the default one by the customized one provided by jenkins config
207 if [ -n "${LAB_CONFIG}" ]; then
208 labconfig="-v ${LAB_CONFIG}:/home/opnfv/functest/conf/openstack.creds"
211 echo "Functest: Start Docker and prepare environment"
212 envs="INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} -e NODE_NAME=${NODE_NAME}"
214 dir_result="${HOME}/opnfv/functest/reports"
215 mkdir -f ${dir_result}
216 rm -rf ${dir_result}/*
217 $res_volume="-v ${dir_result}:/home/opnfv/functest/results"
219 docker pull opnfv/functest:latest_stable
220 cmd="docker run -id -e $envs ${labconfig} ${sshkey} ${res_volume} opnfv/functest:latest_stable /bin/bash"
221 echo "Functest: Running docker run command: ${cmd}"
225 container_id=$(docker ps | grep 'opnfv/functest:latest_stable' | awk '{print $1}' | head -1)
226 echo "Container ID=${container_id}"
227 if [ -z ${container_id} ]; then
228 echo "Cannot find opnfv/functest container ID ${container_id}. Please check if it is existing."
232 echo "Starting the container: docker start ${container_id}"
233 docker start ${container_id}
236 if [ $(docker ps | grep 'opnfv/functest:latest_stable' | wc -l) == 0 ]; then
237 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
240 cmd="${FUNCTEST_REPO_DIR}/docker/prepare_env.sh"
241 echo "Executing command inside the docker: ${cmd}"
242 docker exec ${container_id} ${cmd}
245 name: functest-store-results
248 !include-raw res-build.sh
251 name: functest-cleanup
256 echo "Cleaning up docker containers/images..."
258 # Remove previous running containers if exist
259 if [[ ! -z $(docker ps -a | grep opnfv/functest) ]]; then
260 echo "Removing existing opnfv/functest containers..."
261 docker ps | grep opnfv/functest | awk '{print $1}' | xargs docker stop
262 docker ps -a | grep opnfv/functest | awk '{print $1}' | xargs docker rm
265 # Remove existing images if exist
266 if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
267 echo "Docker images to remove:"
268 docker images | head -1 && docker images | grep opnfv/functest
269 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
270 for tag in "${image_tags[@]}"; do
271 echo "Removing docker image opnfv/functest:$tag..."
272 docker rmi opnfv/functest:$tag