The role has been using python-tempestconf master branch when gating refstack-client or python-tempestconf patches. This patch adds a new argument to setup_env script which can be used to specify a path to python-tempestconf source code. This argument is used, when running the setup_env script from the role, to point the script to the zuul source of python-tempestconf code which contains the newest commits. Change-Id: I65f9043a7bb0e6f045b6442679dd99dbd6aeb2de
		
			
				
	
	
		
			191 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			191 lines
		
	
	
		
			6.7 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash -x
 | 
						|
 | 
						|
#Default Tempest commit: SHA 8316f962c52b01edc5be466b18e54904e2a1248a (Sept 2018)
 | 
						|
CHECKOUT_POINT=8316f962c52b01edc5be466b18e54904e2a1248a
 | 
						|
PY_VERSION="2.7.8"
 | 
						|
 | 
						|
# Prints help
 | 
						|
function usage {
 | 
						|
    set +x
 | 
						|
    SCRIPT_NAME="basename ${BASH_SOURCE[0]}"
 | 
						|
    echo "Usage: ${SCRIPT_NAME} [OPTION]..."
 | 
						|
    echo "Setup RefStack client with test environment"
 | 
						|
    echo ""
 | 
						|
    echo "  -h  Print this usage message"
 | 
						|
    echo "  -c  Tempest test runner commit. You can specify SHA or branch here"
 | 
						|
    echo "      If no commit or tag is specified, tempest will be install from commit"
 | 
						|
    echo "  -p  [ 2 | 3 ] - Uses either python 2.7 or 3.5. Default to python 2.7"
 | 
						|
    echo "  -q  Run quietly. If .tempest folder exists, refstack-client is considered as installed"
 | 
						|
    echo "  -s  Use python-tempestconf from the given source (path), used when running f.e. in Zuul"
 | 
						|
    echo "  -t  Tempest test runner tag. You can specify tag here"
 | 
						|
    echo "      ${CHECKOUT_POINT}"
 | 
						|
    exit 1
 | 
						|
}
 | 
						|
 | 
						|
# Check that parameter is a valid tag in tempest repository
 | 
						|
function check_tag {
 | 
						|
        tags="$(git tag)"
 | 
						|
        for tag in ${tags}; do
 | 
						|
                [[ "${tag}" == "$1" ]] && return 0;
 | 
						|
        done
 | 
						|
        return 1
 | 
						|
}
 | 
						|
 | 
						|
# By default tempest uses commit ${CHECKOUT_POINT}
 | 
						|
 | 
						|
while getopts c:p:t:qs:h FLAG; do
 | 
						|
    case ${FLAG} in
 | 
						|
        c)
 | 
						|
            CHECKOUT_POINT=${OPTARG}
 | 
						|
            ;;
 | 
						|
        p)
 | 
						|
            if [ ${OPTARG} == '3' ]; then
 | 
						|
                PY_VERSION="3.5.2"
 | 
						|
            fi
 | 
						|
            ;;
 | 
						|
        t)
 | 
						|
            CHECKOUT_POINT="-q ${OPTARG}"
 | 
						|
            ;;
 | 
						|
        q)  #show help
 | 
						|
            QUIET_MODE=true
 | 
						|
            ;;
 | 
						|
        s)  #show help
 | 
						|
            TEMPESTCONF_SOURCE=${OPTARG}
 | 
						|
            ;;
 | 
						|
        h)  #show help
 | 
						|
            usage
 | 
						|
            ;;
 | 
						|
        \?) #unrecognized option - show help
 | 
						|
            echo -e \\n"Option -$OPTARG not allowed."
 | 
						|
            usage
 | 
						|
            ;;
 | 
						|
    esac
 | 
						|
done
 | 
						|
 | 
						|
# Install git
 | 
						|
WORKDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 | 
						|
 | 
						|
TEMPEST_DIR=${REFSTACK_CLIENT_TEMPEST_DIR:-${WORKDIR}/.tempest}
 | 
						|
if [ -z ${TEMPESTCONF_SOURCE} ]; then
 | 
						|
    TEMPESTCONF_DIR=${REFSTACK_CLIENT_TEMPEST_DIR:-${WORKDIR}/.tempestconf}
 | 
						|
else
 | 
						|
    TEMPESTCONF_DIR=${TEMPESTCONF_SOURCE}
 | 
						|
fi
 | 
						|
 | 
						|
# Checkout tempest on specified tag
 | 
						|
if [ -d "${TEMPEST_DIR}" ]; then
 | 
						|
    [ ${QUIET_MODE} ] && echo 'Looks like RefStack client is already installed' && exit 0
 | 
						|
    while true; do
 | 
						|
        read -p "Existing tempest installation found. We should remove it. All data from previous test runs will be deleted. Continue (y/n) ?" yn
 | 
						|
        case ${yn} in
 | 
						|
            [Yy]* ) rm -rf ${TEMPEST_DIR}; break;;
 | 
						|
            [Nn]* ) exit 1;;
 | 
						|
            * ) echo "Please answer yes or no.";;
 | 
						|
        esac
 | 
						|
    done
 | 
						|
fi
 | 
						|
 | 
						|
if [ -n "$(command -v apt-get)" ]; then
 | 
						|
    # For apt-get-based Linux distributions (Ubuntu, Debian)
 | 
						|
    # If we run script in container we need sudo
 | 
						|
    if [ ! -n "$(command -v sudo)" ]; then
 | 
						|
        apt-get update || if [ $? -ne 0 ]; then exit 1; fi
 | 
						|
        apt-get -y install sudo
 | 
						|
    else
 | 
						|
        sudo apt-get update || if [ $? -ne 0 ]; then exit 1; fi
 | 
						|
    fi
 | 
						|
    sudo apt-get -y install git
 | 
						|
elif [ -n "$(command -v yum)" ]; then
 | 
						|
    # For yum-based distributions (RHEL, Centos)
 | 
						|
    # If we run script in container we need sudo
 | 
						|
    if [ ! -f sudo ]; then
 | 
						|
        yum -y install sudo
 | 
						|
    fi
 | 
						|
    sudo yum -y install git
 | 
						|
elif [ -n "$(command -v zypper)" ]; then
 | 
						|
    # For zypper-based distributions (openSUSE, SELS)
 | 
						|
    # If we run script in container we need sudo
 | 
						|
    if [ ! -f sudo ]; then
 | 
						|
        zypper --gpg-auto-import-keys --non-interactive refresh
 | 
						|
        zypper --non-interactive install sudo
 | 
						|
    else
 | 
						|
        sudo zypper --gpg-auto-import-keys --non-interactive refresh
 | 
						|
    fi
 | 
						|
    sudo zypper --non-interactive install git
 | 
						|
else
 | 
						|
    echo "Neither apt-get, nor yum, nor zypper found"
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
if [ -z ${TEMPESTCONF_SOURCE} ]; then
 | 
						|
    git clone https://git.openstack.org/openstack/python-tempestconf.git ${TEMPESTCONF_DIR}
 | 
						|
fi
 | 
						|
 | 
						|
git clone https://git.openstack.org/openstack/tempest.git ${TEMPEST_DIR}
 | 
						|
cd ${TEMPEST_DIR}
 | 
						|
 | 
						|
git checkout $CHECKOUT_POINT || if [ $? -ne 0 ]; then exit 1; fi
 | 
						|
cd ${WORKDIR}
 | 
						|
 | 
						|
# Setup binary requirements
 | 
						|
if [ -n "$(command -v apt-get)" ]; then
 | 
						|
    # For apt-get-based Linux distributions (Ubuntu, Debian)
 | 
						|
    sudo apt-get -y install curl wget tar unzip python-dev build-essential libssl-dev libxslt-dev libsasl2-dev libffi-dev libbz2-dev libyaml-dev python3-dev
 | 
						|
elif [ -n "$(command -v yum)" ]; then
 | 
						|
    # For yum-based distributions (RHEL, Centos)
 | 
						|
    sudo yum -y install curl wget tar unzip make python-devel.x86_64 gcc gcc-c++ libffi-devel libxml2-devel bzip2-devel libxslt-devel openssl-devel libyaml-devel python3-devel
 | 
						|
elif [ -n "$(command -v zypper)" ]; then
 | 
						|
    # For zypper-based distributions (openSUSE, SELS)
 | 
						|
    sudo zypper --non-interactive install curl wget tar unzip make python-devel.x86_64 gcc gcc-c++ libffi-devel libxml2-devel zlib-devel libxslt-devel libopenssl-devel python-xml libyaml-devel
 | 
						|
else
 | 
						|
    echo "Neither apt-get, nor yum, nor zypper found."
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
# Build local python interpreter if needed
 | 
						|
sub_pystr="python$(echo $PY_VERSION | cut -c 1-3)"
 | 
						|
if [ ! -n "$(command -v $sub_pystr)" ]; then
 | 
						|
    echo "$sub_pystr not found. Building python ${PY_VERSION}..."
 | 
						|
    mkdir ${WORKDIR}/.localpython
 | 
						|
    mkdir ${WORKDIR}/.python_src
 | 
						|
    cd ${WORKDIR}/.python_src
 | 
						|
    wget http://www.python.org/ftp/python/${PY_VERSION}/Python-${PY_VERSION}.tgz
 | 
						|
    tar zxvf Python-${PY_VERSION}.tgz
 | 
						|
    cd Python-${PY_VERSION}
 | 
						|
 | 
						|
    ./configure --prefix=${WORKDIR}/.localpython --without-pymalloc
 | 
						|
    make && make install
 | 
						|
    cd ${WORKDIR}
 | 
						|
    rm -rf ${WORKDIR}/.python_src
 | 
						|
    PYPATH="${WORKDIR}/.localpython/bin/$sub_pystr"
 | 
						|
else
 | 
						|
    echo "$sub_pystr found!"
 | 
						|
    PYPATH="$sub_pystr"
 | 
						|
fi
 | 
						|
 | 
						|
# Setup virtual environments for refstack-client and tempest
 | 
						|
VENV_VERSION='15.0.3'
 | 
						|
wget https://github.com/pypa/virtualenv/archive/${VENV_VERSION}.tar.gz
 | 
						|
tar xvfz ${VENV_VERSION}.tar.gz
 | 
						|
rm ${VENV_VERSION}.tar.gz
 | 
						|
cd virtualenv-${VENV_VERSION}
 | 
						|
if [ -d ${WORKDIR}/.venv ]; then
 | 
						|
    rm -rf ${WORKDIR}/.venv
 | 
						|
fi
 | 
						|
python virtualenv.py ${WORKDIR}/.venv --python="${PYPATH}"
 | 
						|
python virtualenv.py ${TEMPEST_DIR}/.venv --python="${PYPATH}"
 | 
						|
cd ..
 | 
						|
rm -rf virtualenv-${VENV_VERSION}
 | 
						|
rm virtualenv-${VENV_VERSION}.tar.gz
 | 
						|
${WORKDIR}/.venv/bin/python -m pip install -e .
 | 
						|
cd ${TEMPESTCONF_DIR}
 | 
						|
${WORKDIR}/.venv/bin/python -m pip install -e .
 | 
						|
cd ..
 | 
						|
${TEMPEST_DIR}/.venv/bin/python -m pip install ${TEMPEST_DIR}
 | 
						|
 | 
						|
# Add additional packages to find more tests by tempest
 | 
						|
# Note: Since there are no requirements in tempest-additional-requirements.txt by default,
 | 
						|
# this line is commented out to prevent errors from being returned. Uncomment this line if
 | 
						|
# there are requirements in tempest-additonal-requirements.txt.
 | 
						|
# ${TEMPEST_DIR}/.venv/bin/pip install -r ${WORKDIR}/tempest-additional-requirements.txt
 |