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 DOVETAIL_HOME=/home/opnfv/cvp
10 if [ -d ${DOVETAIL_HOME} ]; then
11 sudo rm -rf ${DOVETAIL_HOME}/*
13 sudo mkdir -p ${DOVETAIL_HOME}
16 DOVETAIL_CONFIG=${DOVETAIL_HOME}/pre_config
17 sudo mkdir -p ${DOVETAIL_CONFIG}
20 # The path of openrc.sh is defined in fetch_os_creds.sh
21 OPENRC=${DOVETAIL_CONFIG}/env_config.sh
22 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
23 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
24 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
25 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
26 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
27 if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
28 #note: this happens only in opnfv-lf-pod1
29 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
30 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
32 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
33 # If production lab then creds may be retrieved dynamically
34 # creds are on the jumphost, always in the same folder
35 sudo cp $LAB_CONFIG/admin-openrc $OPENRC
36 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
37 # replace the default one by the customized one provided by jenkins config
40 # Set iptables rule to allow forwarding return traffic for container
41 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
42 sudo iptables -I FORWARD -j RETURN
45 releng_repo=${WORKSPACE}/releng
46 [ -d ${releng_repo} ] && sudo rm -rf ${releng_repo}
47 git clone https://gerrit.opnfv.org/gerrit/releng ${releng_repo} >/dev/null
49 if [[ ${INSTALLER_TYPE} != 'joid' ]]; then
50 ${releng_repo}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} >${redirect}
53 if [[ -f $OPENRC ]]; then
54 echo "INFO: openstack credentials path is $OPENRC"
57 echo "ERROR: file $OPENRC does not exist."
61 sudo pip install virtualenv
63 cd ${releng_repo}/modules
65 source venv/bin/activate
66 sudo pip install -e ./ >/dev/null
67 sudo pip install netaddr
69 if [[ ${INSTALLER_TYPE} == compass ]]; then
70 options="-u root -p root"
71 elif [[ ${INSTALLER_TYPE} == fuel ]]; then
72 options="-u root -p r00tme"
74 echo "Don't support to generate pod.yaml on ${INSTALLER_TYPE} currently."
75 echo "HA test cases may not run properly."
78 cmd="sudo python ${releng_repo}/utils/create_pod_file.py -t ${INSTALLER_TYPE} \
79 -i ${INSTALLER_IP} ${options} -f ${DOVETAIL_CONFIG}/pod.yaml"
87 if [ -f ${DOVETAIL_CONFIG}/pod.yaml ]; then
88 echo "file ${DOVETAIL_CONFIG}/pod.yaml:"
89 cat ${DOVETAIL_CONFIG}/pod.yaml
91 echo "Error: There doesn't exist file ${DOVETAIL_CONFIG}/pod.yaml."
92 echo "HA test cases may not run properly."
95 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
97 if [ "$INSTALLER_TYPE" == "fuel" ]; then
98 echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
99 sshpass -p r00tme sudo scp $ssh_options root@${INSTALLER_IP}:~/.ssh/id_rsa ${DOVETAIL_CONFIG}/id_rsa
102 opts="--privileged=true -id"
104 docker_volume="-v /var/run/docker.sock:/var/run/docker.sock"
105 dovetail_home_volume="-v ${DOVETAIL_HOME}:${DOVETAIL_HOME}"
107 # Pull the image with correct tag
108 echo "Dovetail: Pulling image opnfv/dovetail:${DOCKER_TAG}"
109 docker pull opnfv/dovetail:$DOCKER_TAG >$redirect
111 cmd="docker run ${opts} -e ${DOVETAIL_HOME} ${docker_volume} ${dovetail_home_volume} \
112 ${sshkey} opnfv/dovetail:${DOCKER_TAG} /bin/bash"
113 echo "Dovetail: running docker run command: ${cmd}"
116 container_id=$(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | awk '{print $1}' | head -1)
117 echo "Container ID=${container_id}"
118 if [ -z ${container_id} ]; then
119 echo "Cannot find opnfv/dovetail container ID ${container_id}. Please check if it is existing."
123 echo "Container Start: docker start ${container_id}"
124 docker start ${container_id}
126 docker ps >${redirect}
127 if [ $(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | wc -l) == 0 ]; then
128 echo "The container opnfv/dovetail with ID=${container_id} has not been properly started. Exiting..."
132 list_cmd="dovetail list ${TESTSUITE}"
133 run_cmd="dovetail run --testsuite ${TESTSUITE} -d"
134 echo "Container exec command: ${list_cmd}"
135 docker exec $container_id ${list_cmd}
136 echo "Container exec command: ${run_cmd}"
137 docker exec $container_id ${run_cmd}
139 sudo cp -r ${DOVETAIL_HOME}/results ./
140 # To make sure the file owner is the current user, for the copied results files in the above line
141 # if not, there will be error when next time to wipe workspace
142 # CURRENT_USER=${SUDO_USER:-$USER}
143 # PRIMARY_GROUP=$(id -gn $CURRENT_USER)
144 # sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ${WORKSPACE}/results
146 echo "Dovetail: done!"