Synced run_tests.sh with horizon, requirements cleanup

Change-Id: Ie6631a61316d3364427dc3116f8636dcebd59896
This commit is contained in:
Jiri Tomasek 2015-05-26 14:27:57 +02:00
parent 0bb836ccc1
commit 7fcacc334f
3 changed files with 120 additions and 56 deletions

View File

@ -1,25 +1,6 @@
# The order of packages is significant, because pip processes them in the order # The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
pbr>=0.11,<2.0
# Horizon Core Requirements
Django>=1.4.2,<1.8
django_compressor>=1.4
django_openstack_auth>=1.1.7,!=1.1.8
eventlet>=0.17.3
kombu>=3.0.7
iso8601>=0.1.9
netaddr>=0.7.12
os-cloud-config os-cloud-config
python-cinderclient>=1.2.1
python-glanceclient>=0.17.1
python-heatclient>=0.3.0
python-keystoneclient>=1.3.0
python-novaclient>=2.22.0
python-neutronclient>=2.3.11,<3
python-swiftclient>=2.2.0
python-ceilometerclient>=1.0.13
pytz>=2013.6
python-ironicclient>=0.2.1 python-ironicclient>=0.2.1
ironic-discoverd>=1.0.0 # Apache-2.0 ironic-discoverd>=1.0.0 # Apache-2.0

View File

@ -2,13 +2,6 @@
set -o errexit set -o errexit
# ---------------UPDATE ME-------------------------------#
# Increment me any time the environment should be rebuilt.
# This includes dependency changes, directory renames, etc.
# Simple integer sequence: 1, 2, 3...
environment_version=47
#--------------------------------------------------------#
function usage { function usage {
echo "Usage: $0 [OPTION]..." echo "Usage: $0 [OPTION]..."
echo "Run Horizon's test suite(s)" echo "Run Horizon's test suite(s)"
@ -22,17 +15,26 @@ function usage {
echo " environment. Useful when dependencies have" echo " environment. Useful when dependencies have"
echo " been added." echo " been added."
echo " -m, --manage Run a Django management command." echo " -m, --manage Run a Django management command."
echo " --makemessages Update all translation files." echo " --makemessages Create/Update English translation files."
echo " --compilemessages Compile all translation files." echo " --compilemessages Compile all translation files."
echo " --check-only Do not update translation files (--makemessages only)."
echo " --pseudo Pseudo translate a language."
echo " -p, --pep8 Just run pep8" echo " -p, --pep8 Just run pep8"
echo " -8, --pep8-changed [<basecommit>]"
echo " Just run PEP8 and HACKING compliance check"
echo " on files changed since HEAD~1 (or <basecommit>)"
echo " -P, --no-pep8 Don't run pep8 by default"
echo " -t, --tabs Check for tab characters in files." echo " -t, --tabs Check for tab characters in files."
echo " -y, --pylint Just run pylint" echo " -y, --pylint Just run pylint"
echo " -j, --jshint Just run jshint" echo " -j, --jshint Just run jshint"
echo " -s, --jscs Just run jscs"
echo " -q, --quiet Run non-interactively. (Relatively) quiet." echo " -q, --quiet Run non-interactively. (Relatively) quiet."
echo " Implies -V if -N is not set." echo " Implies -V if -N is not set."
echo " --only-selenium Run only the Selenium unit tests" echo " --only-selenium Run only the Selenium unit tests"
echo " --with-selenium Run unit tests including Selenium tests" echo " --with-selenium Run unit tests including Selenium tests"
echo " --selenium-headless Run Selenium tests headless" echo " --selenium-headless Run Selenium tests headless"
echo " --integration Run the integration tests (requires a running "
echo " OpenStack environment)"
echo " --runserver Run the Django development server for" echo " --runserver Run the Django development server for"
echo " openstack_dashboard in the virtual" echo " openstack_dashboard in the virtual"
echo " environment." echo " environment."
@ -51,8 +53,9 @@ function usage {
# DEFAULTS FOR RUN_TESTS.SH # DEFAULTS FOR RUN_TESTS.SH
# #
root=`pwd` root=`pwd -P`
venv=$root/.venv venv=$root/.venv
venv_env_version=$venv/environments
with_venv=tools/with_venv.sh with_venv=tools/with_venv.sh
included_dirs="tuskar_ui" included_dirs="tuskar_ui"
@ -62,9 +65,12 @@ command_wrapper=""
destroy=0 destroy=0
force=0 force=0
just_pep8=0 just_pep8=0
just_pep8_changed=0
no_pep8=0
just_pylint=0 just_pylint=0
just_docs=0 just_docs=0
just_tabs=0 just_tabs=0
just_jscs=0
just_jshint=0 just_jshint=0
never_venv=0 never_venv=0
quiet=0 quiet=0
@ -73,15 +79,16 @@ runserver=0
only_selenium=0 only_selenium=0
with_selenium=0 with_selenium=0
selenium_headless=0 selenium_headless=0
integration=0
testopts="" testopts=""
testargs="" testargs=""
with_coverage=0 with_coverage=0
makemessages=0 makemessages=0
compilemessages=0 compilemessages=0
check_only=0
pseudo=0
manage=0 manage=0
COVERAGE_CMD="python -m coverage.__main__"
# Jenkins sets a "JOB_NAME" variable, if it's not set, we'll make it "default" # Jenkins sets a "JOB_NAME" variable, if it's not set, we'll make it "default"
[ "$JOB_NAME" ] || JOB_NAME="default" [ "$JOB_NAME" ] || JOB_NAME="default"
@ -97,8 +104,11 @@ function process_option {
-V|--virtual-env) always_venv=1; never_venv=0;; -V|--virtual-env) always_venv=1; never_venv=0;;
-N|--no-virtual-env) always_venv=0; never_venv=1;; -N|--no-virtual-env) always_venv=0; never_venv=1;;
-p|--pep8) just_pep8=1;; -p|--pep8) just_pep8=1;;
-8|--pep8-changed) just_pep8_changed=1;;
-P|--no-pep8) no_pep8=1;;
-y|--pylint) just_pylint=1;; -y|--pylint) just_pylint=1;;
-j|--jshint) just_jshint=1;; -j|--jshint) just_jshint=1;;
-s|--jscs) just_jscs=1;;
-f|--force) force=1;; -f|--force) force=1;;
-t|--tabs) just_tabs=1;; -t|--tabs) just_tabs=1;;
-q|--quiet) quiet=1;; -q|--quiet) quiet=1;;
@ -106,9 +116,12 @@ function process_option {
-m|--manage) manage=1;; -m|--manage) manage=1;;
--makemessages) makemessages=1;; --makemessages) makemessages=1;;
--compilemessages) compilemessages=1;; --compilemessages) compilemessages=1;;
--check-only) check_only=1;;
--pseudo) pseudo=1;;
--only-selenium) only_selenium=1;; --only-selenium) only_selenium=1;;
--with-selenium) with_selenium=1;; --with-selenium) with_selenium=1;;
--selenium-headless) selenium_headless=1;; --selenium-headless) selenium_headless=1;;
--integration) integration=1;;
--docs) just_docs=1;; --docs) just_docs=1;;
--runserver) runserver=1;; --runserver) runserver=1;;
--backup-environment) backup_env=1;; --backup-environment) backup_env=1;;
@ -148,11 +161,48 @@ function run_jshint {
jshint tuskar_ui/infrastructure/static/infrastructure jshint tuskar_ui/infrastructure/static/infrastructure
} }
function run_jscs {
echo "Running jscs ..."
if [ "`which jscs`" == '' ] ; then
echo "jscs is not present; please install, e.g. sudo npm install jscs -g"
else
jscs tuskar_ui/infrastructure/static/infrastructure/js \
tuskar_ui/infrastructure/static/infrastructure/tests
fi
}
function warn_on_flake8_without_venv {
set +o errexit
${command_wrapper} python -c "import hacking" 2>/dev/null
no_hacking=$?
set -o errexit
if [ $never_venv -eq 1 -a $no_hacking -eq 1 ]; then
echo "**WARNING**:" >&2
echo "OpenStack hacking is not installed on your host. Its detection will be missed." >&2
echo "Please install or use virtual env if you need OpenStack hacking detection." >&2
fi
}
function run_pep8 { function run_pep8 {
echo "Running flake8 ..." echo "Running flake8 ..."
warn_on_flake8_without_venv
DJANGO_SETTINGS_MODULE=tuskar_ui.test.settings ${command_wrapper} flake8 $included_dirs DJANGO_SETTINGS_MODULE=tuskar_ui.test.settings ${command_wrapper} flake8 $included_dirs
} }
function run_pep8_changed {
# NOTE(gilliard) We want use flake8 to check the entirety of every file that has
# a change in it. Unfortunately the --filenames argument to flake8 only accepts
# file *names* and there are no files named (eg) "nova/compute/manager.py". The
# --diff argument behaves surprisingly as well, because although you feed it a
# diff, it actually checks the file on disk anyway.
local base_commit=${testargs:-HEAD~1}
files=$(git diff --name-only $base_commit | tr '\n' ' ')
echo "Running flake8 on ${files}"
warn_on_flake8_without_venv
diff -u --from-file /dev/null ${files} | DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings ${command_wrapper} flake8 --diff
exit
}
function run_sphinx { function run_sphinx {
echo "Building sphinx..." echo "Building sphinx..."
export DJANGO_SETTINGS_MODULE=openstack_dashboard.settings export DJANGO_SETTINGS_MODULE=openstack_dashboard.settings
@ -181,21 +231,20 @@ function destroy_venv {
echo "Removing virtualenv..." echo "Removing virtualenv..."
rm -rf $venv rm -rf $venv
echo "Virtualenv removed." echo "Virtualenv removed."
rm -f .environment_version
echo "Environment cleaned."
} }
function environment_check { function environment_check {
echo "Checking environment." echo "Checking environment."
if [ -f .environment_version ]; then if [ -f $venv_env_version ]; then
ENV_VERS=`cat .environment_version` set +o errexit
if [ $ENV_VERS -eq $environment_version ]; then cat requirements.txt test-requirements.txt | cmp $venv_env_version - > /dev/null
if [ -e ${venv} ]; then local env_check_result=$?
# If the environment exists and is up-to-date then set our variables set -o errexit
command_wrapper="${root}/${with_venv}" if [ $env_check_result -eq 0 ]; then
echo "Environment is up to date." # If the environment exists and is up-to-date then set our variables
return 0 command_wrapper="${root}/${with_venv}"
fi echo "Environment is up to date."
return 0
fi fi
fi fi
@ -260,7 +309,6 @@ function restore_environment {
fi fi
cp -r /tmp/.horizon_environment/$JOB_NAME/.venv ./ || true cp -r /tmp/.horizon_environment/$JOB_NAME/.venv ./ || true
cp -r /tmp/.horizon_environment/$JOB_NAME/.environment_version ./ || true
echo "Environment restored successfully." echo "Environment restored successfully."
fi fi
@ -280,7 +328,7 @@ function install_venv {
# Make sure it worked and record the environment version # Make sure it worked and record the environment version
sanity_check sanity_check
chmod -R 754 $venv chmod -R 754 $venv
echo $environment_version > .environment_version cat requirements.txt test-requirements.txt > $venv_env_version
} }
function run_tests { function run_tests {
@ -293,6 +341,10 @@ function run_tests {
export SKIP_UNITTESTS=1 export SKIP_UNITTESTS=1
fi fi
if [ $with_selenium -eq 0 -a $integration -eq 0 ]; then
testopts="$testopts --exclude-dir=tuskar_ui/test/integration_tests"
fi
if [ $selenium_headless -eq 1 ]; then if [ $selenium_headless -eq 1 ]; then
export SELENIUM_HEADLESS=1 export SELENIUM_HEADLESS=1
fi fi
@ -315,16 +367,19 @@ function run_tests_all {
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then
export NOSE_HTML_OUT_FILE='tuskar_ui_nose_results.html' export NOSE_HTML_OUT_FILE='tuskar_ui_nose_results.html'
fi fi
${command_wrapper} ${COVERAGE_CMD} erase if [ $with_coverage -eq 1 ]; then
${command_wrapper} ${COVERAGE_CMD} run -p $root/manage.py test tuskar_ui --settings=tuskar_ui.test.settings $testopts ${command_wrapper} python -m coverage.__main__ erase
coverage_run="python -m coverage.__main__ run -p"
fi
${command_wrapper} ${coverage_run} $root/manage.py test tuskar_ui --settings=tuskar_ui.test.settings $testopts
# get results of the Horizon tests # get results of the Horizon tests
TUSKAR_UI_RESULT=$? TUSKAR_UI_RESULT=$?
if [ $with_coverage -eq 1 ]; then if [ $with_coverage -eq 1 ]; then
echo "Generating coverage reports" echo "Generating coverage reports"
${command_wrapper} ${COVERAGE_CMD} combine ${command_wrapper} python -m coverage.__main__ combine
${command_wrapper} ${COVERAGE_CMD} xml -i --omit='/usr*,setup.py,*egg*,.venv/*' ${command_wrapper} python -m coverage.__main__ xml -i --include="tuskar_ui/*" --omit='/usr*,setup.py,*egg*,.venv/*'
${command_wrapper} ${COVERAGE_CMD} html -i --omit='/usr*,setup.py,*egg*,.venv/*' -d reports ${command_wrapper} python -m coverage.__main__ html -i --include="tuskar_ui/*" --omit='/usr*,setup.py,*egg*,.venv/*' -d reports
fi fi
# Remove the leftover coverage files from the -p flag earlier. # Remove the leftover coverage files from the -p flag earlier.
rm -f .coverage.* rm -f .coverage.*
@ -341,7 +396,23 @@ function run_tests_all {
else else
echo "Tests failed." echo "Tests failed."
fi fi
exit $(($TUSKAR_UI_RESULT)) exit $TEST_RESULT
}
function run_integration_tests {
export INTEGRATION_TESTS=1
if [ $selenium_headless -eq 1 ]; then
export SELENIUM_HEADLESS=1
fi
echo "Running Tuskar-UI integration tests..."
if [ -z "$testargs" ]; then
${command_wrapper} nosetests tuskar_ui/test/integration_tests/tests
else
${command_wrapper} nosetests $testargs
fi
exit 0
} }
function run_makemessages { function run_makemessages {
@ -441,15 +512,14 @@ if [ $just_pep8 -eq 1 ]; then
exit $? exit $?
fi fi
# Pylint if [ $just_pep8_changed -eq 1 ]; then
if [ $just_pylint -eq 1 ]; then run_pep8_changed
run_pylint
exit $? exit $?
fi fi
# Tab checker # Pylint
if [ $just_tabs -eq 1 ]; then if [ $just_pylint -eq 1 ]; then
tab_check run_pylint
exit $? exit $?
fi fi
@ -459,6 +529,19 @@ if [ $just_jshint -eq 1 ]; then
exit $? exit $?
fi fi
# Jscs
if [ $just_jscs -eq 1 ]; then
run_jscs
exit $?
fi
# Tab checker
if [ $just_tabs -eq 1 ]; then
tab_check
exit $?
fi
# Django development server # Django development server
if [ $runserver -eq 1 ]; then if [ $runserver -eq 1 ]; then
run_server run_server

View File

@ -2,7 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking==0.10.1 hacking>=0.10.0,<0.11
# Testing Requirements # Testing Requirements
http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon
http://tarballs.openstack.org/python-tuskarclient/python-tuskarclient-master.tar.gz#egg=python-tuskarclient http://tarballs.openstack.org/python-tuskarclient/python-tuskarclient-master.tar.gz#egg=python-tuskarclient