Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jan 2, 2023
1 parent aa67093 commit ff3751a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
from selenium.webdriver.common.by import By


def is_responsive(url):
def is_notebook_responsive(ip, port):
return any(
is_url_responsive(f"{protocol}://{ip}:{port}") for protocol in ("http", "https")
)


def is_url_responsive(url):
try:
response = requests.get(url)
if response.status_code == 200:
Expand Down Expand Up @@ -61,10 +67,9 @@ def notebook_service(docker_ip, docker_services, aiidalab_exec, nb_user, appdir)

# `port_for` takes a container port and returns the corresponding host port
port = docker_services.port_for("aiidalab", 8888)
url = f"http://{docker_ip}:{port}"
token = os.environ["JUPYTER_TOKEN"]
docker_services.wait_until_responsive(
timeout=30.0, pause=0.1, check=lambda: is_responsive(url)
timeout=30.0, pause=0.2, check=lambda: is_notebook_responsive(docker_ip, port)
)
return url, token

Expand Down

0 comments on commit ff3751a

Please sign in to comment.