3 #the noun INSTALLER is used in community, here is just the example to run.
4 #multi-platforms are supported.
7 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
9 # labconfig is used only for joid
12 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
13 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
14 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
15 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
16 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
17 if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
18 #note: this happens only in opnfv-lf-pod1
19 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
20 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
22 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
23 # If production lab then creds may be retrieved dynamically
24 # creds are on the jumphost, always in the same folder
25 labconfig="-v $LAB_CONFIG/admin-openrc:/home/opnfv/functest/conf/openstack.creds"
26 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
27 # replace the default one by the customized one provided by jenkins config
30 # Set iptables rule to allow forwarding return traffic for container
31 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
32 sudo iptables -I FORWARD -j RETURN
35 opts="--privileged=true -id"
36 envs="-e CI_DEBUG=${CI_DEBUG} \
37 -e INSTALLER_TYPE=${INSTALLER_TYPE} \
38 -e INSTALLER_IP=${INSTALLER_IP} \
39 -e DEPLOY_SCENARIO=${DEPLOY_SCENARIO} \
40 -e DEPLOY_TYPE=${DEPLOY_TYPE}"
41 results_envs="-v /var/run/docker.sock:/var/run/docker.sock \
42 -v /home/opnfv/dovetail/results:/home/opnfv/dovetail/results"
44 # Pull the image with correct tag
45 echo "Dovetail: Pulling image opnfv/dovetail:${DOCKER_TAG}"
46 docker pull opnfv/dovetail:$DOCKER_TAG >$redirect
48 cmd="sudo docker run ${opts} ${envs} ${results_envs} ${labconfig} ${sshkey} \
49 opnfv/dovetail:${DOCKER_TAG} /bin/bash"
50 echo "Dovetail: running docker run command: ${cmd}"
53 container_id=$(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | awk '{print $1}' | head -1)
54 echo "Container ID=${container_id}"
55 if [ -z ${container_id} ]; then
56 echo "Cannot find opnfv/dovetail container ID ${container_id}. Please check if it is existing."
60 echo "Container Start: docker start ${container_id}"
61 docker start ${container_id}
63 docker ps >${redirect}
64 if [ $(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | wc -l) == 0 ]; then
65 echo "The container opnfv/dovetail with ID=${container_id} has not been properly started. Exiting..."
69 list_cmd="dovetail list ${TESTSUITE}"
70 run_cmd="dovetail run --testsuite ${TESTSUITE} -d true"
71 echo "Container exec command: ${list_cmd}"
72 docker exec $container_id ${list_cmd}
73 echo "Container exec command: ${run_cmd}"
74 docker exec $container_id ${run_cmd}
76 sudo cp -r ${DOVETAIL_REPO_DIR}/results ./
77 #To make sure the file owner is jenkins, for the copied results files in the above line
78 #if not, there will be error when next time to wipe workspace
79 sudo chown -R jenkins:jenkins ${WORKSPACE}/results
81 echo "Dovetail: done!"