Add full integration test with hubtraf

- Fully simulates what a user would be doing
- Also tests tljh-config set and reload functionality
This commit is contained in:
yuvipanda
2018-07-28 00:52:02 -07:00
parent fad3e70116
commit 6f99da5d95
3 changed files with 36 additions and 1 deletions

View File

@@ -77,6 +77,13 @@ jobs:
python3 .circleci/integration-test.py copy . /srv/src python3 .circleci/integration-test.py copy . /srv/src
python3 .circleci/integration-test.py run 'python3 /srv/src/bootstrap/bootstrap.py' python3 .circleci/integration-test.py run 'python3 /srv/src/bootstrap/bootstrap.py'
- run:
name: switch to dummyauthenticator
command: |
python3 .circleci/integration-test.py run '/opt/tljh/hub/bin/tljh-config set auth.type dummyauthenticator.DummyAuthenticator'
python3 .circleci/integration-test.py run '/opt/tljh/hub/bin/tljh-config reload'
- run: - run:
name: print systemd status + logs name: print systemd status + logs
command: | command: |

View File

@@ -1,2 +1,3 @@
pytest pytest
requests pytest-asyncio
git+https://github.com/yuvipanda/hubtraf.git

View File

@@ -1,5 +1,32 @@
import requests import requests
from hubtraf.user import User
from hubtraf.auth.dummy import login_dummy
import secrets
import pytest
from functools import partial
import pwd
def test_hub_up(): def test_hub_up():
r = requests.get('http://127.0.0.1') r = requests.get('http://127.0.0.1')
r.raise_for_status() r.raise_for_status()
@pytest.mark.asyncio
async def test_user_code_execute():
"""
User logs in, starts a server & executes code
"""
# This *must* be localhost, not an IP
# aiohttp throws away cookies if we are connecting to an IP!
hub_url = 'http://localhost'
username = secrets.token_hex(8)
async with User(username, hub_url, partial(login_dummy, password='')) as u:
await u.login()
await u.ensure_server()
await u.start_kernel()
await u.assert_code_output("5 * 4", "20", 5, 5)
# Assert that the user exists
assert pwd.getpwnam(f'jupyter-{username}') is not None