From 9f538775e02c833b1267a52f774bb5283d0fc64f Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Fri, 14 Sep 2018 10:48:35 -0700 Subject: [PATCH] Print hub logs if hubtraf fails in integration tests --- integration-tests/test_hub.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/integration-tests/test_hub.py b/integration-tests/test_hub.py index a4e8704..30965d2 100644 --- a/integration-tests/test_hub.py +++ b/integration-tests/test_hub.py @@ -132,12 +132,21 @@ async def test_long_username(): # FIXME: wait for reload to finish & hub to come up # Should be part of tljh-config reload await asyncio.sleep(1) - async with User(username, hub_url, partial(login_dummy, password='')) as u: - await u.login() - await u.ensure_server() + try: + async with User(username, hub_url, partial(login_dummy, password='')) as u: + await u.login() + await u.ensure_server() - # Assert that the user exists - system_username = generate_system_username(f'jupyter-{username}') - assert pwd.getpwnam(system_username) is not None + # Assert that the user exists + system_username = generate_system_username(f'jupyter-{username}') + assert pwd.getpwnam(system_username) is not None - await u.stop_server() \ No newline at end of file + await u.stop_server() + except: + # If we have any errors, print jupyterhub logs before exiting + subprocess.check_call([ + 'journalctl', + '-u', 'jupyterhub', + '--no-pager' + ]) + raise \ No newline at end of file