2021-04-03 18:18:50 -04:00
|
|
|
# This script is sourced by CI scripts to launch httpbin.
|
|
|
|
#
|
|
|
|
# Do not run it directly.
|
|
|
|
|
|
|
|
httpbin_launch() {
|
|
|
|
echo 'Launching httpbin...'
|
|
|
|
|
|
|
|
case "$(uname -s)" in
|
|
|
|
Linux)
|
|
|
|
dist_codename=$(lsb_release --codename --short)
|
|
|
|
;;
|
2021-04-03 18:29:27 -04:00
|
|
|
|
|
|
|
Darwin)
|
|
|
|
dist_codename='macOS'
|
|
|
|
;;
|
2021-04-03 18:18:50 -04:00
|
|
|
esac
|
|
|
|
|
|
|
|
case "$dist_codename" in
|
|
|
|
trusty)
|
2021-04-05 09:37:50 -04:00
|
|
|
# Python 2.7.6 is too old to support SNI and can't be used.
|
|
|
|
PY3=3
|
2021-04-03 18:29:27 -04:00
|
|
|
|
2021-04-05 09:37:50 -04:00
|
|
|
# Current decorator (>= 5) is incompatible with Python 3.4 used
|
|
|
|
# here, so explicitly use a version which is known to work.
|
|
|
|
pip_decorator_arg='decorator==4.4.2'
|
2021-04-03 18:18:50 -04:00
|
|
|
;;
|
|
|
|
|
2021-04-03 18:29:27 -04:00
|
|
|
macOS)
|
2021-04-05 09:37:50 -04:00
|
|
|
# We use Python 2 under macOS 10.11 which doesn't have Python 3,
|
|
|
|
# and decorator >= 5 is incompatible with it too.
|
2021-04-03 18:18:50 -04:00
|
|
|
pip_decorator_arg='decorator==4.4.2'
|
|
|
|
;;
|
2021-04-03 18:29:27 -04:00
|
|
|
|
|
|
|
*)
|
|
|
|
# Elsewhere just use Python 3.
|
|
|
|
PY3=3
|
|
|
|
;;
|
2021-04-03 18:18:50 -04:00
|
|
|
esac
|
|
|
|
|
2021-04-05 09:37:50 -04:00
|
|
|
if [ "$PY3" = 3 ]; then
|
|
|
|
# Ensure that we have at least some version of pip.
|
|
|
|
if ! python3 -m pip; then
|
|
|
|
sudo apt-get -q -o=Dpkg::Use-Pty=0 install python3-pip
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Running pip install fails with weird errors out of the box when
|
|
|
|
# using old pip version because it attempts to use python rather
|
|
|
|
# than python3, so upgrade it to fix this.
|
|
|
|
#
|
|
|
|
# However don't upgrade to a version which is too new because then
|
|
|
|
# it may not support Python version that we actually have (this one
|
|
|
|
# still works with 3.4, 20.0.1 is the last one to support 3.5).
|
|
|
|
python3 -m pip install --user --upgrade pip==19.1.1
|
|
|
|
fi
|
|
|
|
|
2021-04-03 19:45:01 -04:00
|
|
|
echo "Installing using `python$PY3 -m pip --version`"
|
|
|
|
|
2021-04-05 09:37:50 -04:00
|
|
|
python$PY3 -m pip install $pip_decorator_arg httpbin --user
|
2021-04-03 18:29:27 -04:00
|
|
|
python$PY3 -m httpbin.core 2>&1 >httpbin.log &
|
2021-04-03 18:18:50 -04:00
|
|
|
WX_TEST_WEBREQUEST_URL="http://localhost:5000"
|
|
|
|
|
|
|
|
export WX_TEST_WEBREQUEST_URL
|
|
|
|
}
|
|
|
|
|
|
|
|
httpbin_show_log() {
|
|
|
|
echo '*** Tests failed, contents of httpbin.log follows: ***'
|
|
|
|
echo '-----------------------------------------------------------'
|
|
|
|
cat httpbin.log
|
|
|
|
echo '-----------------------------------------------------------'
|
|
|
|
}
|