diff --git a/.circleci/config.yml b/.circleci/config.yml index 572bcd2..c57ad61 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,7 @@ jobs: - run: name: setup python3 command: | - apk add --no-cache python3 + apk add --no-cache python3 pytest - checkout - setup_remote_docker @@ -79,6 +79,12 @@ jobs: --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ plugins test_simplest_plugin.py + - run: + name: Run distro check test + command: | + py.test integration-tests/test_distro.py + + documentation: docker: diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 324dae9..78fe7fe 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -8,15 +8,24 @@ This script is run as: curl | sudo python3 - Constraints: - - Be compatible with Python 3.4 (since we support Ubuntu 16.04) + - Entire script should be compatible with Python 3.6 (We run on Ubuntu 18.04+) + - Script should parse in Python 3.4 (since we exit with useful error message on Ubuntu 14.04+) - Use stdlib modules only """ import os import subprocess import sys import logging +import platform - +# Support only Ubuntu 18.04+ +distro, version, _ = platform.linux_distribution() +if distro != 'Ubuntu': + print('The Littlest JupyterHub currently supports Ubuntu Linux only') + sys.exit(1) +elif float(version) < 18.04: + print('The Littlest JupyterHub requires Ubuntu 18.04 or higher') + sys.exit(1) def main(): install_prefix = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh') diff --git a/docs/index.rst b/docs/index.rst index ea10e01..3bc5597 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -6,6 +6,7 @@ A simple `JupyterHub `_ distribution f a small (0-100) number of users on a single server. We recommend reading :ref:`topic/whentouse` to determine if this is the right tool for you. + Development Status ================== @@ -18,7 +19,8 @@ Installation ============ The Littlest JupyterHub (TLJH) can run on any server that is running at least -Ubuntu 18.04. We have a bunch of tutorials to get you started. +**Ubuntu 18.04**. Earlier versions of Ubuntu are not supported. +We have a bunch of tutorials to get you started. - Tutorials to create a new server from scratch on a cloud provider & run TLJH on it. These are **recommended** if you do not have much experience setting up diff --git a/integration-tests/test_distro.py b/integration-tests/test_distro.py new file mode 100644 index 0000000..cf237f1 --- /dev/null +++ b/integration-tests/test_distro.py @@ -0,0 +1,40 @@ +""" +Test running on non-supported distros +""" +import subprocess + +def test_ubuntu_too_old(): + container_name = 'old-distro-test' + + # stop container if it is already running + subprocess.run([ + 'docker', 'rm', '-f', container_name + ]) + + # Start a detached Ubuntu 16.04 container + subprocess.check_call([ + 'docker', 'run', '--detach', '--name', container_name, 'ubuntu:16.04', + '/bin/bash', '-c', 'sleep 1000s' + ]) + # Install python3 inside the ubuntu container + # There is no trusted Ubuntu+Python3 container we can use + subprocess.check_output([ + 'docker', 'exec', container_name, 'apt-get', 'update' + ]) + subprocess.check_output([ + 'docker', 'exec', container_name, 'apt-get', 'install', '--yes', 'python3' + ]) + # Copy only the bootstrap script to container, so this is faster + subprocess.check_call([ + 'docker', + 'cp', + 'bootstrap/', f'{container_name}:/srv' + ]) + + # Run bootstrap script, validate that it fails appropriately + output = subprocess.run([ + 'docker', 'exec', '-i', container_name, + 'python3', '/srv/bootstrap/bootstrap.py' + ], check=False, stdout=subprocess.PIPE, encoding='utf-8') + assert output.stdout == 'The Littlest JupyterHub requires Ubuntu 18.04 or higher\n' + assert output.returncode == 1 \ No newline at end of file