Merge pull request #886 from minrk/test-hub-version

add integration test for hub version
This commit is contained in:
Erik Sundell
2023-05-11 23:16:44 +02:00
committed by GitHub
2 changed files with 20 additions and 5 deletions

View File

@@ -178,6 +178,13 @@ def run_test(
test_name, test_name,
"/opt/tljh/hub/bin/python3 -m pip install -r /srv/src/integration-tests/requirements.txt", "/opt/tljh/hub/bin/python3 -m pip install -r /srv/src/integration-tests/requirements.txt",
) )
# show environment
run_container_command(
test_name,
"/opt/tljh/hub/bin/python3 -m pip freeze",
)
run_container_command( run_container_command(
test_name, test_name,
# We abort pytest after two failures as a compromise between wanting to # We abort pytest after two failures as a compromise between wanting to

View File

@@ -11,26 +11,34 @@ import grp
import subprocess import subprocess
from os import system from os import system
from tljh.normalize import generate_system_username from tljh.normalize import generate_system_username
from packaging.version import Version as V
# Use sudo to invoke it, since this is how users invoke it. # Use sudo to invoke it, since this is how users invoke it.
# This catches issues with PATH # This catches issues with PATH
TLJH_CONFIG_PATH = ["sudo", "tljh-config"] TLJH_CONFIG_PATH = ["sudo", "tljh-config"]
# This *must* be localhost, not an IP
# aiohttp throws away cookies if we are connecting to an IP!
hub_url = "http://localhost"
def test_hub_up(): def test_hub_up():
r = requests.get("http://127.0.0.1") r = requests.get(hub_url)
r.raise_for_status() r.raise_for_status()
def test_hub_version():
r = requests.get(hub_url + "/hub/api")
r.raise_for_status()
info = r.json()
assert V("3.0") <= V(info["version"]) <= V("4.0")
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_user_code_execute(): async def test_user_code_execute():
""" """
User logs in, starts a server & executes code 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) username = secrets.token_hex(8)
assert ( assert (