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=${WORKSPACE}/cvp
10 [ -d ${DOVETAIL_HOME} ] && sudo rm -rf ${DOVETAIL_HOME}
12 mkdir -p ${DOVETAIL_HOME}
14 DOVETAIL_CONFIG=${DOVETAIL_HOME}/pre_config
15 mkdir -p ${DOVETAIL_CONFIG}
18 # The path of openrc.sh is defined in fetch_os_creds.sh
19 OPENRC=${DOVETAIL_CONFIG}/env_config.sh
20 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
21 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
22 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
23 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
24 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
25 if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
26 #note: this happens only in opnfv-lf-pod1
27 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
28 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
30 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
31 # If production lab then creds may be retrieved dynamically
32 # creds are on the jumphost, always in the same folder
33 sudo cp $LAB_CONFIG/admin-openrc $OPENRC
34 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
35 # replace the default one by the customized one provided by jenkins config
38 # Set iptables rule to allow forwarding return traffic for container
39 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
40 sudo iptables -I FORWARD -j RETURN
43 releng_repo=${WORKSPACE}/releng
44 [ -d ${releng_repo} ] && sudo rm -rf ${releng_repo}
45 git clone https://gerrit.opnfv.org/gerrit/releng ${releng_repo} >/dev/null
47 if [[ ${INSTALLER_TYPE} != 'joid' ]]; then
48 ${releng_repo}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} >${redirect}
51 if [[ -f $OPENRC ]]; then
52 echo "INFO: openstack credentials path is $OPENRC"
55 echo "ERROR: cannot find file $OPENRC. Please check if it is existing."
56 sudo ls -al ${DOVETAIL_CONFIG}
60 sudo pip install virtualenv
62 cd ${releng_repo}/modules
64 source venv/bin/activate
65 sudo pip install -e ./ >/dev/null
66 sudo pip install netaddr
68 if [[ ${INSTALLER_TYPE} == compass ]]; then
69 options="-u root -p root"
70 elif [[ ${INSTALLER_TYPE} == fuel ]]; then
71 options="-u root -p r00tme"
73 echo "Don't support to generate pod.yaml on ${INSTALLER_TYPE} currently."
74 echo "HA test cases may not run properly."
77 cmd="sudo python ${releng_repo}/utils/create_pod_file.py -t ${INSTALLER_TYPE} \
78 -i ${INSTALLER_IP} ${options} -f ${DOVETAIL_CONFIG}/pod.yaml"
86 if [ -f ${DOVETAIL_CONFIG}/pod.yaml ]; then
87 echo "file ${DOVETAIL_CONFIG}/pod.yaml:"
88 cat ${DOVETAIL_CONFIG}/pod.yaml
90 echo "Error: cannot find file ${DOVETAIL_CONFIG}/pod.yaml. Please check if it is existing."
91 sudo ls -al ${DOVETAIL_CONFIG}
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 # sdnvpn test case needs to download this image first before running
103 echo "Download image ubuntu-16.04-server-cloudimg-amd64-disk1.img ..."
104 wget -q -nc http://artifacts.opnfv.org/sdnvpn/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ${DOVETAIL_CONFIG}
106 opts="--privileged=true -id"
108 docker_volume="-v /var/run/docker.sock:/var/run/docker.sock"
109 dovetail_home_volume="-v ${DOVETAIL_HOME}:${DOVETAIL_HOME}"
111 # Pull the image with correct tag
112 echo "Dovetail: Pulling image opnfv/dovetail:${DOCKER_TAG}"
113 docker pull opnfv/dovetail:$DOCKER_TAG >$redirect
115 cmd="docker run ${opts} -e DOVETAIL_HOME=${DOVETAIL_HOME} ${docker_volume} ${dovetail_home_volume} \
116 ${sshkey} opnfv/dovetail:${DOCKER_TAG} /bin/bash"
117 echo "Dovetail: running docker run command: ${cmd}"
120 container_id=$(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | awk '{print $1}' | head -1)
121 echo "Container ID=${container_id}"
122 if [ -z ${container_id} ]; then
123 echo "Cannot find opnfv/dovetail container ID ${container_id}. Please check if it is existing."
127 echo "Container Start: docker start ${container_id}"
128 docker start ${container_id}
130 docker ps >${redirect}
131 if [ $(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | wc -l) == 0 ]; then
132 echo "The container opnfv/dovetail with ID=${container_id} has not been properly started. Exiting..."
136 list_cmd="dovetail list ${TESTSUITE}"
137 run_cmd="dovetail run --testsuite ${TESTSUITE} -d"
138 echo "Container exec command: ${list_cmd}"
139 docker exec $container_id ${list_cmd}
140 echo "Container exec command: ${run_cmd}"
141 docker exec $container_id ${run_cmd}
143 sudo cp -r ${DOVETAIL_HOME}/results ./
144 # To make sure the file owner is the current user, for the copied results files in the above line
145 # if not, there will be error when next time to wipe workspace
146 # CURRENT_USER=${SUDO_USER:-$USER}
147 # PRIMARY_GROUP=$(id -gn $CURRENT_USER)
148 # sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ${WORKSPACE}/results
150 echo "Dovetail: done!"