mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
test refactor: show logs from jupyterhub and traefik after tests
This commit is contained in:
55
.github/integration-test.py
vendored
55
.github/integration-test.py
vendored
@@ -25,7 +25,7 @@ def _cli(args, log_failure=True):
|
|||||||
return subprocess.check_output(cmd, text=True, stderr=subprocess.STDOUT)
|
return subprocess.check_output(cmd, text=True, stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
if log_failure:
|
if log_failure:
|
||||||
print(f"{cmd} failed!")
|
print(f"{cmd} failed!", flush=True)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ def stop_container(container_name):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def run_command(container_name, cmd):
|
def run_command(container_name, command):
|
||||||
"""
|
"""
|
||||||
Run a bash command in a running container and error if it fails
|
Run a bash command in a running container and error if it fails
|
||||||
"""
|
"""
|
||||||
@@ -125,8 +125,9 @@ def run_command(container_name, cmd):
|
|||||||
container_name,
|
container_name,
|
||||||
"/bin/bash",
|
"/bin/bash",
|
||||||
"-c",
|
"-c",
|
||||||
cmd,
|
command,
|
||||||
]
|
]
|
||||||
|
print(f"\nRunning: {cmd}\n----------------------------------------", flush=True)
|
||||||
subprocess.run(cmd, check=True, text=True)
|
subprocess.run(cmd, check=True, text=True)
|
||||||
|
|
||||||
|
|
||||||
@@ -163,36 +164,25 @@ def run_test(
|
|||||||
# released version), and from a previous major-like version.
|
# released version), and from a previous major-like version.
|
||||||
#
|
#
|
||||||
if upgrade_from:
|
if upgrade_from:
|
||||||
run_command(
|
command = f"python3 /srv/src/bootstrap/bootstrap.py --version={upgrade_from}"
|
||||||
container_name,
|
run_command(container_name, command)
|
||||||
f"python3 /srv/src/bootstrap/bootstrap.py --version={upgrade_from}",
|
|
||||||
)
|
command = f"python3 /srv/src/bootstrap/bootstrap.py {installer_args}"
|
||||||
run_command(
|
run_command(container_name, command)
|
||||||
container_name, f"python3 /srv/src/bootstrap/bootstrap.py {installer_args}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install pkgs from requirements in hub's pip, where
|
# Install pkgs from requirements in hub's pip, where
|
||||||
# the bootstrap script installed the others
|
# the bootstrap script installed the others
|
||||||
run_command(
|
command = "/opt/tljh/hub/bin/python3 -m pip install -r /srv/src/integration-tests/requirements.txt"
|
||||||
container_name,
|
run_command(container_name, command)
|
||||||
"/opt/tljh/hub/bin/python3 -m pip install -r /srv/src/integration-tests/requirements.txt",
|
|
||||||
)
|
|
||||||
|
|
||||||
# show environment
|
# show environment
|
||||||
run_command(
|
command = "/opt/tljh/hub/bin/python3 -m pip freeze"
|
||||||
container_name,
|
run_command(container_name, command)
|
||||||
"/opt/tljh/hub/bin/python3 -m pip freeze",
|
|
||||||
)
|
|
||||||
|
|
||||||
# run tests
|
# run tests
|
||||||
run_command(
|
test_files = " ".join([f"/srv/src/integration-tests/{f}" for f in test_files])
|
||||||
container_name,
|
command = f"/opt/tljh/hub/bin/python3 -m pytest {test_files}"
|
||||||
"/opt/tljh/hub/bin/python3 -m pytest {}".format(
|
run_command(container_name, command)
|
||||||
" ".join(
|
|
||||||
[os.path.join("/srv/src/integration-tests/", f) for f in test_files]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def show_logs(container_name):
|
def show_logs(container_name):
|
||||||
@@ -201,16 +191,9 @@ def show_logs(container_name):
|
|||||||
|
|
||||||
tljh logs ref: https://tljh.jupyter.org/en/latest/troubleshooting/logs.html
|
tljh logs ref: https://tljh.jupyter.org/en/latest/troubleshooting/logs.html
|
||||||
"""
|
"""
|
||||||
systemctl = run_command(
|
run_command(container_name, "systemctl --no-pager status jupyterhub traefik")
|
||||||
container_name, "systemctl --no-pager status jupyterhub traefik"
|
run_command(container_name, "journalctl --no-pager -u jupyterhub")
|
||||||
)
|
run_command(container_name, "journalctl --no-pager -u traefik")
|
||||||
print(systemctl)
|
|
||||||
|
|
||||||
jupyterhub_logs = run_command(container_name, "journalctl --no-pager -u jupyterhub")
|
|
||||||
print(jupyterhub_logs)
|
|
||||||
|
|
||||||
traefik_logs = run_command(container_name, "journalctl --no-pager -u traefik")
|
|
||||||
print(traefik_logs)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
4
.github/workflows/integration-test.yaml
vendored
4
.github/workflows/integration-test.yaml
vendored
@@ -89,6 +89,7 @@ jobs:
|
|||||||
# script.
|
# script.
|
||||||
#
|
#
|
||||||
- name: pytest integration-tests/
|
- name: pytest integration-tests/
|
||||||
|
id: basic-tests
|
||||||
run: |
|
run: |
|
||||||
.github/integration-test.py run-test basic-tests \
|
.github/integration-test.py run-test basic-tests \
|
||||||
${{ matrix.extra_flags }} \
|
${{ matrix.extra_flags }} \
|
||||||
@@ -98,10 +99,12 @@ jobs:
|
|||||||
test_extensions.py
|
test_extensions.py
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
- name: show logs
|
- name: show logs
|
||||||
|
if: always() && steps.basic-tests.outcome != 'skipped'
|
||||||
run: |
|
run: |
|
||||||
.github/integration-test.py show-logs basic-tests
|
.github/integration-test.py show-logs basic-tests
|
||||||
|
|
||||||
- name: pytest integration-tests/test_simplest_plugin.py integration-tests/test_admin_installer.py
|
- name: pytest integration-tests/test_simplest_plugin.py integration-tests/test_admin_installer.py
|
||||||
|
id: admin-plugin-tests
|
||||||
run: |
|
run: |
|
||||||
.github/integration-test.py run-test admin-plugin-tests \
|
.github/integration-test.py run-test admin-plugin-tests \
|
||||||
--installer-args "--admin admin:admin --plugin /srv/src/integration-tests/plugins/simplest" \
|
--installer-args "--admin admin:admin --plugin /srv/src/integration-tests/plugins/simplest" \
|
||||||
@@ -110,5 +113,6 @@ jobs:
|
|||||||
test_simplest_plugin.py
|
test_simplest_plugin.py
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
- name: show logs
|
- name: show logs
|
||||||
|
if: always() && steps.admin-plugin-tests.outcome != 'skipped'
|
||||||
run: |
|
run: |
|
||||||
.github/integration-test.py show-logs admin-plugin-tests
|
.github/integration-test.py show-logs admin-plugin-tests
|
||||||
|
|||||||
Reference in New Issue
Block a user