mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Add test for failure when running inside a plain docker container
This commit is contained in:
@@ -2,14 +2,9 @@
|
|||||||
Test running bootstrap script in different circumstances
|
Test running bootstrap script in different circumstances
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
|
def run_bootstrap(container_name, image):
|
||||||
def test_ubuntu_too_old():
|
|
||||||
"""
|
|
||||||
Error with a useful message when running in older Ubuntu
|
|
||||||
"""
|
|
||||||
container_name = 'old-distro-test'
|
|
||||||
|
|
||||||
# stop container if it is already running
|
# stop container if it is already running
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
'docker', 'rm', '-f', container_name
|
'docker', 'rm', '-f', container_name
|
||||||
@@ -17,7 +12,7 @@ def test_ubuntu_too_old():
|
|||||||
|
|
||||||
# Start a detached Ubuntu 16.04 container
|
# Start a detached Ubuntu 16.04 container
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
'docker', 'run', '--detach', '--name', container_name, 'ubuntu:16.04',
|
'docker', 'run', '--detach', '--name', container_name, image,
|
||||||
'/bin/bash', '-c', 'sleep 1000s'
|
'/bin/bash', '-c', 'sleep 1000s'
|
||||||
])
|
])
|
||||||
# Install python3 inside the ubuntu container
|
# Install python3 inside the ubuntu container
|
||||||
@@ -35,10 +30,26 @@ def test_ubuntu_too_old():
|
|||||||
'bootstrap/', f'{container_name}:/srv'
|
'bootstrap/', f'{container_name}:/srv'
|
||||||
])
|
])
|
||||||
|
|
||||||
# Run bootstrap script, validate that it fails appropriately
|
# Run bootstrap script, return the output
|
||||||
output = subprocess.run([
|
return subprocess.run([
|
||||||
'docker', 'exec', '-i', container_name,
|
'docker', 'exec', '-i', container_name,
|
||||||
'python3', '/srv/bootstrap/bootstrap.py'
|
'python3', '/srv/bootstrap/bootstrap.py'
|
||||||
], check=False, stdout=subprocess.PIPE, encoding='utf-8')
|
], check=False, stdout=subprocess.PIPE, encoding='utf-8')
|
||||||
|
|
||||||
|
def test_ubuntu_too_old():
|
||||||
|
"""
|
||||||
|
Error with a useful message when running in older Ubuntu
|
||||||
|
"""
|
||||||
|
output = run_bootstrap('old-distro-test', 'ubuntu:16.04')
|
||||||
assert output.stdout == 'The Littlest JupyterHub requires Ubuntu 18.04 or higher\n'
|
assert output.stdout == 'The Littlest JupyterHub requires Ubuntu 18.04 or higher\n'
|
||||||
assert output.returncode == 1
|
assert output.returncode == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_inside_plain_docker():
|
||||||
|
output = run_bootstrap('plain-docker-test', 'ubuntu:18.04')
|
||||||
|
assert output.stdout.strip() == dedent("""
|
||||||
|
Systemd is required to run TLJH
|
||||||
|
Running inside a plain docker container isn't supported
|
||||||
|
For local development, see http://tljh.jupyter.org/en/latest/contributing/dev-setup.html
|
||||||
|
""").strip()
|
||||||
|
assert output.returncode == 1
|
||||||
|
|||||||
Reference in New Issue
Block a user