Merge "Create run_tempest out of run_rally"
[functest.git] / docker / demo.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 # DO NOT USE FOR PRODUCTION.
10 # Changes:
11 #     It runs only 1 Rally bench scenario
12 #
13
14
15 config_file=$(find / -name config_functest.yaml)
16
17 REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
18 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
19 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
20 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
21
22 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
23 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
24 FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
25 FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
26 RALLY_VENV=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
27 RALLY_COMMIT=$(cat $config_file | grep -w rally_stable_commit | awk 'END {print $NF}')
28
29
30 info ()  {
31     logger -s -t "start.info" "$*"
32 }
33
34
35 error () {
36     logger -s -t "start.error" "$*"
37     exit 1
38 }
39
40 # Check if environment variables are set
41 if [ -z ${INSTALLER_TYPE} ]; then
42     error "Environment variable 'INSTALLER_TYPE' is not defined."
43 elif [ "${INSTALLER_TYPE}" != "fuel" ] && [ "${INSTALLER_TYPE}" != "foreman" ]; then
44     error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
45 fi
46
47 if [ -z ${INSTALLER_IP} ]; then
48     error "Environment variable 'INSTALLER_IP' is not defined."
49 fi
50
51 echo "#############################################"
52 echo "############### FUNCTEST DEMO ###############"
53 echo "#############################################"
54
55 # Update repos
56 echo "---------- Updating repositories ----------"
57 cd ${FUNCTEST_REPO_DIR}
58 git pull
59 echo "Functest repository updated."
60 cd ${RELENG_REPO_DIR}
61 git pull
62 echo "Releng repository updated."
63 cd ${RALLY_REPO_DIR}
64 git reset --hard ${RALLY_COMMIT}
65 echo "Rally repository reset to commit ${RALLY_COMMIT}."
66
67
68 # Create directories
69 echo "---------- Creating directories ----------"
70 mkdir -p ${FUNCTEST_CONF_DIR}
71 echo "${FUNCTEST_CONF_DIR} created."
72 mkdir -p ${FUNCTEST_DATA_DIR}
73 echo "${FUNCTEST_DATA_DIR} created."
74 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
75 echo "${FUNCTEST_RESULTS_DIR}/ODL created."
76
77
78
79 # Create Openstack credentials file
80 echo "---------- Retrieving Credentials from Fuel ----------"
81 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
82     -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
83 retval=$?
84 if [ $retval != 0 ]; then
85     echo "Cannot retrieve credentials file from installation. Check logs."
86     exit $retval
87 fi
88 echo "Credentials succesfully stored in ${FUNCTEST_CONF_DIR}/openstack.creds"
89
90 # Source credentials
91 echo "---------- Sourcing Openstack Credentials  ----------"
92 source ${FUNCTEST_CONF_DIR}/openstack.creds
93
94
95 # Prepare Functest Environment
96 echo "---------- Preparing Functest environment  ----------"
97 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start
98 retval=$?
99 if [ $retval != 0 ]; then
100     echo "Error when configuring Functest environment"
101     exit $retval
102 fi
103
104 # vPing
105 echo "----------------------------------------------"
106 echo "---------- Running vPING test case  ----------"
107 echo "----------------------------------------------"
108 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py --debug ${FUNCTEST_REPO_DIR}/ -r
109
110 # ODL
111 echo "----------------------------------------------"
112 echo "---------- Running ODL test case  ----------"
113 echo "----------------------------------------------"
114 if [ $INSTALLER_TYPE == "fuel" ]; then
115     odl_ip=$(keystone catalog --service network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
116     neutron_ip=$(keystone catalog --service identity | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
117     usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
118     pass=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
119     odl_port=8181
120     ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$pass \
121     ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
122 elif [ $INSTALLER_TYPE == "foreman" ]; then
123     #odl_port=8081
124     ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
125 else
126     echo "INSTALLER_TYPE not valid."
127     exit 1
128 fi
129
130 # rally
131 echo "----------------------------------------------"
132 echo "------- Running Rally bench test case  -------"
133 echo "----------------------------------------------"
134 echo "Functest: run Functest Rally Bench suites"
135 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally.py --debug ${FUNCTEST_REPO_DIR}/ glance
136
137 # tempest
138 echo "----------------------------------------------"
139 echo "-------- Running Tempest smoke tests  --------"
140 echo "----------------------------------------------"
141 echo "Functest: run Tempest suite"
142 rally verify start smoke
143 rally verify list