From 66c6a2ad58508fe8c3aa1e753ab3f64cafcb0209 Mon Sep 17 00:00:00 2001 From: Duk Loi Date: Fri, 25 Mar 2016 21:21:28 -0400 Subject: [PATCH] Remove install of horizon from test-requirements The entry to install horizon in the test requirements is problematic when installing in devstack. Users have reported issues with multiple requirements for horizon or a problem with not being able to access git on some machines to pull down the horizon code. However, the tox tests still require the horizon code so that the unit tests can run against the horizon code. The solution is to remove the horizon entry in the test-requirements.txt. Also added the pip-install.sh script (which is "borrowed" from Sahara to which we express our most heartfelt thanks) to perform the pip install along with the pull of the horizon code from git. Finally, invoked the pip-install.sh script in the tox.ini file. Change-Id: Idb5edf32a461ada99aa1f189635ef34e9cbe1a58 Closes-Bug: #1562081 --- test-requirements.txt | 2 -- tools/pip_install.sh | 56 +++++++++++++++++++++++++++++++++++++++++++ tox.ini | 2 +- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100755 tools/pip_install.sh diff --git a/test-requirements.txt b/test-requirements.txt index e1b87d8..fbe4058 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,8 +2,6 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. --e git://github.com/openstack/horizon.git#egg=horizon - hacking<0.11,>=0.10.0 coverage>=3.6 ddt>=0.7.0 diff --git a/tools/pip_install.sh b/tools/pip_install.sh new file mode 100755 index 0000000..7596c16 --- /dev/null +++ b/tools/pip_install.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# This script is borrowed from Sahara who borrowed from neutron-* repos. + +# Many of horizon's repos suffer from the problem of depending on horizon, +# but it not existing on pypi. + +# This wrapper for tox's package installer will use the existing package +# if it exists, else use zuul-cloner if that program exists, else grab it +# from horizon master via a hard-coded URL. That last case should only +# happen with devs running unit tests locally. + +# From the tox.ini config page: +# install_command=ARGV +# default: +# pip install {opts} {packages} + +ZUUL_CLONER=/usr/zuul-env/bin/zuul-cloner +BRANCH_NAME=master +horizon_installed=$(echo "import horizon" | python 2>/dev/null ; echo $?) + +set -e + +install_cmd="pip install" +if [ "$1" = "constrained" ]; then + install_cmd="$install_cmd $2" + shift +fi +shift + +if [ $horizon_installed -eq 0 ]; then + echo "ALREADY INSTALLED" > /tmp/tox_install.txt + echo "Horizon already installed; using existing package" +elif [ -x "$ZUUL_CLONER" ]; then + export ZUUL_BRANCH=${ZUUL_BRANCH-$BRANCH} + echo "ZUUL CLONER" > /tmp/tox_install.txt + cwd=$(/bin/pwd) + cd /tmp + $ZUUL_CLONER --cache-dir \ + /opt/git \ + --branch $BRANCH_NAME \ + git://git.openstack.org \ + openstack/horizon + cd openstack/horizon + $install_cmd -e . + cd "$cwd" +else + echo "PIP HARDCODE" > /tmp/tox_install.txt + if [ -z "$HORIZON_PIP_LOCATION" ]; then + HORIZON_PIP_LOCATION="git+https://git.openstack.org/openstack/horizon@$BRANCH_NAME#egg=horizon" + fi + $install_cmd -U -e ${HORIZON_PIP_LOCATION} +fi + +$install_cmd -U $* +exit $? diff --git a/tox.ini b/tox.ini index e6950e8..895a33a 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ skipsdist = True [testenv] usedevelop = True -install_command = pip install -U {opts} {packages} +install_command = {toxinidir}/tools/pip_install.sh unconstrained {opts} {packages} setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt