ODL test suite requirements.pip moved to general requirements
[functest.git] / docker / start.sh
1 #!/bin/bash
2
3 #
4 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
5 #
6 # Installs the Functest framework within the Docker container
7 # and run the tests automatically
8 #
9
10
11 config_file=$(find / -name config_functest.yaml)
12
13 REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
14 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
15 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
16 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
17
18 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
19 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
20 FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
21 FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
22 RALLY_VENV=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
23 RALLY_COMMIT=$(cat $config_file | grep -w rally_stable_commit | awk 'END {print $NF}')
24
25
26 echo "REPOS_DIR=${REPOS_DIR}"
27 echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
28 echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
29 echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
30 echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
31 echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
32 echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
33 echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
34 echo "RALLY_VENV=${RALLY_VENV}"
35 echo "RALLY_COMMIT=${RALLY_COMMIT}"
36
37
38 info ()  {
39     logger -s -t "start.info" "$*"
40 }
41
42
43 error () {
44     logger -s -t "start.error" "$*"
45     exit 1
46 }
47
48 # Check if environment variables are set
49 if [ -z ${INSTALLER_TYPE} ]; then
50     error "Environment variable 'INSTALLER_TYPE' is not defined."
51 elif [ "${INSTALLER_TYPE}" != "fuel" ] && [ "${INSTALLER_TYPE}" != "foreman" ]; then
52     error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
53 fi
54
55 if [ -z ${INSTALLER_IP} ]; then
56     error "Environment variable 'INSTALLER_IP' is not defined."
57 fi
58
59
60 # Update repos
61 cd ${FUNCTEST_REPO_DIR}
62 git pull
63 cd ${RELENG_REPO_DIR}
64 git pull
65 cd ${RALLY_REPO_DIR}
66 git reset --hard ${RALLY_COMMIT}
67
68
69 # Create directories
70 mkdir -p ${FUNCTEST_CONF_DIR}
71 mkdir -p ${FUNCTEST_DATA_DIR}
72 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
73
74 # Detect type of installer
75 # NOTE: this is tricky, since the IPs will have to be the same ALWAYS
76
77
78 # Create Openstack credentials file
79 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
80     -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
81 retval=$?
82 if [ $retval != 0 ]; then
83     echo "Cannot retrieve credentials file from installation. Check logs."
84     exit $retval
85 fi
86
87
88 # Source credentials
89 source ${FUNCTEST_CONF_DIR}/openstack.creds
90
91
92 # Prepare Functest Environment
93 echo "Functest: prepare Functest environment"
94 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start
95 retval=$?
96 if [ $retval != 0 ]; then
97     echo "Error when configuring Functest environment"
98     exit $retval
99 fi
100
101 # vPing
102 echo "Functest: run vPing"
103 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py --debug ${FUNCTEST_REPO_DIR}/ -r
104
105 # ODL
106 echo "Functest: run ODL suite"
107
108 if [ $INSTALLER_TYPE == "fuel" ]; then
109     odl_ip=$(keystone catalog --service network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
110     neutron_ip=$(keystone catalog --service identity | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
111     usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
112     pass=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
113     odl_port=8181
114     ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$pass \
115     ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
116 elif [ $INSTALLER_TYPE == "foreman" ]; then
117     #odl_port=8081
118     ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
119 else
120     echo "INSTALLER_TYPE not valid."
121     exit 1
122 fi
123
124 # rally
125 echo "Functest: run Functest Rally Bench suites"
126 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally.py --debug ${FUNCTEST_REPO_DIR}/ all
127
128 # tempest
129 echo "Functest: run Tempest suite"
130 rally verify start smoke
131 rally verify list
132
133 # collect results
134 echo "Functest: copy results and clean Functest environment"
135
136 # save ODL results
137 cp -Rf ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/logs ${FUNCTEST_RESULTS_DIR}/ODL
138
139 # save tempest.conf for further troubleshooting
140 cp $RALLY_VENV/tempest/for-deployment-*/tempest.conf ${FUNCTEST_CONF_DIR}
141
142