From bc49f02d832f2bf3d2e835583c1b8e3420fa4329 Mon Sep 17 00:00:00 2001 From: Peter Bandzi Date: Wed, 6 May 2015 09:42:46 +0200 Subject: Script for creating virtual environment added. Plus start_test script fixes JIRA: FUNCTEST-5 Change-Id: I015e3d8bfa7311437ca702f97c79d9e0bf3684ea Signed-off-by: Peter Bandzi --- testcases/Controllers/ODL/CI/create_venv.sh | 35 +++++++++++++++++++++++++++ testcases/Controllers/ODL/CI/requirements.pip | 4 +++ testcases/Controllers/ODL/CI/start_tests.sh | 24 +++++++++++++----- 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 testcases/Controllers/ODL/CI/create_venv.sh create mode 100644 testcases/Controllers/ODL/CI/requirements.pip (limited to 'testcases') diff --git a/testcases/Controllers/ODL/CI/create_venv.sh b/testcases/Controllers/ODL/CI/create_venv.sh new file mode 100644 index 00000000..5d0733a5 --- /dev/null +++ b/testcases/Controllers/ODL/CI/create_venv.sh @@ -0,0 +1,35 @@ +#!/bin/bash -e + +# Script checks that venv exists. If it doesn't it will be created +# It requires python2.7 and virtualenv packages installed + +BASEDIR=`dirname $0` + +function venv_install() { + if command -v virtualenv-2.7; then + virtualenv-2.7 $1 + elif command -v virtualenv2; then + virtualenv2 $1 + elif command -v virtualenv; then + virtualenv $1 + else + echo Please make sure virtualenv package is installed. + return 1 + fi +} + +# exit when something goes wrong during venv install +set -e +if [ ! -d "$BASEDIR/venv" ]; then + venv_install $BASEDIR/venv + echo "Virtualenv created." +fi + +if [ ! -f "$BASEDIR/venv/updated" -o $BASEDIR/requirements.pip -nt $BASEDIR/venv/updated ]; then + source $BASEDIR/venv/bin/activate + pip install -r $BASEDIR/requirements.pip + touch $BASEDIR/venv/updated + echo "Requirements installed." + deactivate +fi +set +e diff --git a/testcases/Controllers/ODL/CI/requirements.pip b/testcases/Controllers/ODL/CI/requirements.pip new file mode 100644 index 00000000..43845e25 --- /dev/null +++ b/testcases/Controllers/ODL/CI/requirements.pip @@ -0,0 +1,4 @@ +requests +robotframework +robotframework-requests +robotframework-sshlibrary diff --git a/testcases/Controllers/ODL/CI/start_tests.sh b/testcases/Controllers/ODL/CI/start_tests.sh index e2f94a65..367a075f 100644 --- a/testcases/Controllers/ODL/CI/start_tests.sh +++ b/testcases/Controllers/ODL/CI/start_tests.sh @@ -1,10 +1,13 @@ #!/bin/bash # Script requires that test environment is created already # it includes python2.7 virtual env with robot packages and git +# use create_env.sh script for creating python virtualenv +BASEDIR=`dirname $0` # Colors green='\033[0;32m' light_green='\033[1;32m' +red='\033[1;31m' nc='\033[0m' # No Color usage="Script for starting ODL tests. Tests to be executed are specified in test_list.txt file. @@ -14,7 +17,7 @@ usage: where: -h show this help text - var one of the following: OSTACK_IP, ODL_PORT, USER, PASS, PATH_TO_VENV + var one of the following: OSTACK_IP, ODL_PORT, USR_NAME, USR_PASSWORD value new value for var example: @@ -35,11 +38,10 @@ done echo -e "${green}Current environment parameters for ODL suite.${nc}" # Following vars might be also specified as CLI params set -x -PATH_TO_VENV=${PATH_TO_VENV:-~/.virtualenvs/robot/bin/activate} OSTACK_IP=${OSTACK_IP:-'oscontrol'} ODL_PORT=${ODL_PORT:-8081} USR_NAME=${USR_NAME:-'admin'} -PASS=${PASS:-'octopus'} +USR_PASSWORD=${USR_PASSWORD:-'octopus'} set +x echo -e "${green}Cloning ODL integration git repo.${nc}" @@ -53,14 +55,19 @@ else fi # Change openstack password for admin tenant in neutron suite -sed -i "s/\"password\": \"admin\"/\"password\": \"${PASS}\"/" integration/test/csit/suites/openstack/neutron/__init__.robot +sed -i "s/\"password\": \"admin\"/\"password\": \"${USR_PASSWORD}\"/" integration/test/csit/suites/openstack/neutron/__init__.robot -echo -e "${green}Activate python virtual env.${nc}" -source $PATH_TO_VENV +if source $BASEDIR/venv/bin/activate; then + echo -e "${green}Python virtualenv activated.${nc}" +else + echo -e "${red}ERROR${nc}" + exit 1 +fi # List of tests are specified in test_list.txt # those are relative paths to test directories from integartion suite echo -e "${green}Executing chosen tests.${nc}" +test_num=1 while read line do # skip comments @@ -70,6 +77,11 @@ do echo -e "${light_green}Starting test: $line ${nc}" pybot -v OPENSTACK:${OSTACK_IP} -v PORT:${ODL_PORT} -v CONTROLLER:${OSTACK_IP} $line + mkdir -p $BASEDIR/logs/${test_num} + mv log.html $BASEDIR/logs/${test_num}/ + mv report.html $BASEDIR/logs/${test_num}/ + mv output.xml $BASEDIR/logs/${test_num}/ + ((test_num++)) done < test_list.txt echo -e "${green}Deactivate venv.${nc}" -- cgit 1.2.3-korg