diff --git a/doc/source/ref/run_tests.rst b/doc/source/ref/run_tests.rst index 55c3d56281..6cff42b1b7 100644 --- a/doc/source/ref/run_tests.rst +++ b/doc/source/ref/run_tests.rst @@ -253,9 +253,9 @@ The environment backup is stored in ``/tmp/.horizon_environment/``. Environment Versioning ====================== -Horizon keeps track of changes to the environment by incrementing an -``environment_version`` integer at the top of ``run_tests.sh``. - -If you do anything which changes the environment (adding new dependencies -or renaming directories are both great examples) be sure to increment the -``environment_version`` counter as well. +Horizon keeps track of changes to the environment by comparing the +current requirements files (``requirements.txt`` and +``test-requirements.txt``) and the files last time the virtual +environment was created or updated. If there is any difference, +the virtual environment will be update automatically when you run +``run_tests.sh``. diff --git a/run_tests.sh b/run_tests.sh index dfe95ed824..ba3e2dd803 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -2,13 +2,6 @@ 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 { echo "Usage: $0 [OPTION]..." echo "Run Horizon's test suite(s)" @@ -60,6 +53,7 @@ function usage { # root=`pwd -P` venv=$root/.venv +venv_env_version=$venv/environments with_venv=tools/with_venv.sh included_dirs="openstack_dashboard horizon" @@ -221,21 +215,20 @@ function destroy_venv { echo "Removing virtualenv..." rm -rf $venv echo "Virtualenv removed." - rm -f .environment_version - echo "Environment cleaned." } function environment_check { echo "Checking environment." - if [ -f .environment_version ]; then - ENV_VERS=`cat .environment_version` - if [ $ENV_VERS -eq $environment_version ]; then - if [ -e ${venv} ]; then - # If the environment exists and is up-to-date then set our variables - command_wrapper="${root}/${with_venv}" - echo "Environment is up to date." - return 0 - fi + if [ -f $venv_env_version ]; then + set +o errexit + cat requirements.txt test-requirements.txt | cmp $venv_env_version - > /dev/null + local env_check_result=$? + set -o errexit + if [ $env_check_result -eq 0 ]; then + # If the environment exists and is up-to-date then set our variables + command_wrapper="${root}/${with_venv}" + echo "Environment is up to date." + return 0 fi fi @@ -284,7 +277,6 @@ function backup_environment { fi mkdir -p /tmp/.horizon_environment/$JOB_NAME cp -r $venv /tmp/.horizon_environment/$JOB_NAME/ - cp .environment_version /tmp/.horizon_environment/$JOB_NAME/ # Remove the backup now that we've completed successfully rm -rf /tmp/.horizon_environment/$JOB_NAME.old echo "Backup completed" @@ -300,7 +292,6 @@ function restore_environment { fi cp -r /tmp/.horizon_environment/$JOB_NAME/.venv ./ || true - cp -r /tmp/.horizon_environment/$JOB_NAME/.environment_version ./ || true echo "Environment restored successfully." fi @@ -320,7 +311,7 @@ function install_venv { # Make sure it worked and record the environment version sanity_check chmod -R 754 $venv - echo $environment_version > .environment_version + cat requirements.txt test-requirements.txt > $venv_env_version } function run_tests {