2 ##############################################################################
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 #the noun INSTALLER is used in community, here is just the example to run.
11 #multi-platforms are supported.
14 [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
16 DOVETAIL_HOME=${WORKSPACE}/cvp
17 if [ -d ${DOVETAIL_HOME} ]; then
18 sudo rm -rf ${DOVETAIL_HOME}/*
20 sudo mkdir -p ${DOVETAIL_HOME}
23 DOVETAIL_CONFIG=${DOVETAIL_HOME}/pre_config
24 sudo mkdir -p ${DOVETAIL_CONFIG}
27 # The path of openrc.sh is defined in fetch_os_creds.sh
28 OPENRC=${DOVETAIL_CONFIG}/env_config.sh
29 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
30 instack_mac=$(sudo virsh domiflist undercloud | grep default | \
31 grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
32 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
33 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
34 if [[ -n $(sudo iptables -L FORWARD |grep "REJECT"|grep "reject-with icmp-port-unreachable") ]]; then
35 #note: this happens only in opnfv-lf-pod1
36 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
37 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
39 elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
40 # If production lab then creds may be retrieved dynamically
41 # creds are on the jumphost, always in the same folder
42 sudo cp $LAB_CONFIG/admin-openrc $OPENRC
43 # If dev lab, credentials may not be the default ones, just provide a path to put them into docker
44 # replace the default one by the customized one provided by jenkins config
47 # Set iptables rule to allow forwarding return traffic for container
48 if ! sudo iptables -C FORWARD -j RETURN 2> ${redirect} || ! sudo iptables -L FORWARD | awk 'NR==3' | grep RETURN 2> ${redirect}; then
49 sudo iptables -I FORWARD -j RETURN
52 releng_repo=${WORKSPACE}/releng
53 [ -d ${releng_repo} ] && sudo rm -rf ${releng_repo}
54 git clone https://gerrit.opnfv.org/gerrit/releng ${releng_repo} >/dev/null
56 if [[ ${INSTALLER_TYPE} != 'joid' ]]; then
57 ${releng_repo}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} >${redirect}
60 if [[ -f $OPENRC ]]; then
61 echo "INFO: openstack credentials path is $OPENRC"
64 echo "ERROR: cannot find file $OPENRC. Please check if it is existing."
65 sudo ls -al ${DOVETAIL_CONFIG}
69 sudo pip install virtualenv
71 cd ${releng_repo}/modules
73 source venv/bin/activate
74 sudo pip install -e ./ >/dev/null
75 sudo pip install netaddr
77 if [[ ${INSTALLER_TYPE} == compass ]]; then
78 options="-u root -p root"
79 elif [[ ${INSTALLER_TYPE} == fuel ]]; then
80 options="-u root -p r00tme"
82 echo "Don't support to generate pod.yaml on ${INSTALLER_TYPE} currently."
83 echo "HA test cases may not run properly."
86 cmd="sudo python ${releng_repo}/utils/create_pod_file.py -t ${INSTALLER_TYPE} \
87 -i ${INSTALLER_IP} ${options} -f ${DOVETAIL_CONFIG}/pod.yaml"
95 if [ -f ${DOVETAIL_CONFIG}/pod.yaml ]; then
96 echo "file ${DOVETAIL_CONFIG}/pod.yaml:"
97 cat ${DOVETAIL_CONFIG}/pod.yaml
99 echo "Error: cannot find file ${DOVETAIL_CONFIG}/pod.yaml. Please check if it is existing."
100 sudo ls -al ${DOVETAIL_CONFIG}
101 echo "HA test cases may not run properly."
104 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
106 if [ "$INSTALLER_TYPE" == "fuel" ]; then
107 echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
108 sshpass -p r00tme sudo scp $ssh_options root@${INSTALLER_IP}:~/.ssh/id_rsa ${DOVETAIL_CONFIG}/id_rsa
111 # sdnvpn test case needs to download this image first before running
112 sudo wget -nc http://artifacts.opnfv.org/sdnvpn/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ${DOVETAIL_CONFIG}
114 opts="--privileged=true -id"
116 docker_volume="-v /var/run/docker.sock:/var/run/docker.sock"
117 dovetail_home_volume="-v ${DOVETAIL_HOME}:${DOVETAIL_HOME}"
119 # Pull the image with correct tag
120 echo "Dovetail: Pulling image opnfv/dovetail:${DOCKER_TAG}"
121 docker pull opnfv/dovetail:$DOCKER_TAG >$redirect
123 cmd="docker run ${opts} -e DOVETAIL_HOME=${DOVETAIL_HOME} ${docker_volume} ${dovetail_home_volume} \
124 ${sshkey} opnfv/dovetail:${DOCKER_TAG} /bin/bash"
125 echo "Dovetail: running docker run command: ${cmd}"
128 container_id=$(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | awk '{print $1}' | head -1)
129 echo "Container ID=${container_id}"
130 if [ -z ${container_id} ]; then
131 echo "Cannot find opnfv/dovetail container ID ${container_id}. Please check if it is existing."
135 echo "Container Start: docker start ${container_id}"
136 docker start ${container_id}
138 docker ps >${redirect}
139 if [ $(docker ps | grep "opnfv/dovetail:${DOCKER_TAG}" | wc -l) == 0 ]; then
140 echo "The container opnfv/dovetail with ID=${container_id} has not been properly started. Exiting..."
144 list_cmd="dovetail list ${TESTSUITE}"
145 run_cmd="dovetail run --testsuite ${TESTSUITE} -d"
146 echo "Container exec command: ${list_cmd}"
147 docker exec $container_id ${list_cmd}
148 echo "Container exec command: ${run_cmd}"
149 docker exec $container_id ${run_cmd}
151 sudo cp -r ${DOVETAIL_HOME}/results ./
152 # To make sure the file owner is the current user, for the copied results files in the above line
153 # if not, there will be error when next time to wipe workspace
154 # CURRENT_USER=${SUDO_USER:-$USER}
155 # PRIMARY_GROUP=$(id -gn $CURRENT_USER)
156 # sudo chown -R ${CURRENT_USER}:${PRIMARY_GROUP} ${WORKSPACE}/results
158 echo "Dovetail: done!"