Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install full system Python 3 for testing #719

Merged
merged 1 commit into from Sep 21, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Install full system Python 3 for testing

Travis has changed their pyenv configuration such that the default
Python comes first in the PATH, instead of a custom Python 3.5.
It's a good idea to use the system Python for a few reasons:
  - pyenv is not used on macOS, and we don't have it inside Docker
  - This makes it easier to run on stock hosts without pyenv,
    which is useful for running tests on e.g. our real build machines

Unfortunately, the Ubuntu images do not have the necessary python3
virtualenv package installed, and the name differs between Ubuntu
versions, so these configs require some additional snowflake steps.

Use the Salt python SLS file to ensure that the system Python is
configured appropriately before running the test suite,
which allows encapsulating the complexity into the Salt code for reuse.
Make sure to install Salt first if it is not already installed.
  • Loading branch information
aneeshusa committed Sep 16, 2017
commit e5433505ced33a539d8286c58e5d2392394f118c
@@ -23,16 +23,21 @@ travis_fold_end() {
printf "travis_fold:end:%s\n" "${1}"
}

run_salt() {
install_salt() {
travis_fold_start "salt.install.$1" 'Installing and configuring Salt'
.travis/install_salt.sh -F -c .travis -- "${TRAVIS_OS_NAME}"
travis_fold_end "salt.install.$1"
}

run_salt() {
install_salt "${1}"

travis_fold_start "grains.items.$1" 'Printing Salt grains for debugging'
salt_call grains.items
travis_fold_end "grains.items.$1"

travis_fold_start "state.show_highstate.$1" 'Performing basic YAML and Jinja validation'
travis_fold_start "state.show_highstate.$1" \
'Performing basic YAML and Jinja validation'
salt_call --retcode-passthrough state.show_highstate
travis_fold_end "state.show_highstate.$1"

@@ -58,16 +63,30 @@ run_inside_docker() {
}


setup_venv() {
local -r VENV_DIR="/tmp/saltfs-venv3"
setup_test_venv() {
if ! which salt-call >/dev/null; then
install_salt 'test_venv'
fi
travis_fold_start 'test_venv.install_python3' \
'Setting up Python 3 virtualenv for testing'
# Use the system Python 3 to make it easy to run tests on fresh hosts
# Make sure dependencies are installed (like `python3-venv` on Debian derivatives)
salt_call --retcode-passthrough state.sls python
travis_fold_end 'test_venv.install_python3'


printf "Using %s at %s\n" "$(python3 --version)" "$(which python3)"

travis_fold_start 'test_venv.install_requirements' \
'Installing pip dependencies for testing'
local -r VENV_DIR="/tmp/saltfs-venv3"
python3 -m venv "${VENV_DIR}"
set +o nounset
source "${VENV_DIR}/bin/activate"
set -o nounset
pip install wheel
pip install -r requirements.txt
travis_fold_end 'test_venv.install_requirements'
}


@@ -79,7 +98,7 @@ fi

if [[ "${SALT_NODE_ID}" == "test" ]]; then
# Run test suite separately for parallelism
setup_venv
setup_test_venv
./test.py
elif [[ -n "${SALT_DOCKER_IMAGE:-}" ]]; then # macOS bash is too old for `-v`
printf "Using %s\n" "$(docker -v)"
@@ -108,7 +127,7 @@ else
fi

# Only run tests against the new configuration
setup_venv
setup_test_venv

# TODO: don't hard-code this
if [[ "${SALT_NODE_ID}" == "servo-master1" ]]; then
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.