diff --git a/.circleci/config.yml b/.circleci/config.yml index 734ae7f..2aa989d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -110,7 +110,6 @@ commands: - run: name: Run bootstrap checks command: | - python3 -m pip install requests py.test integration-tests/test_bootstrap.py -s diff --git a/integration-tests/test_bootstrap.py b/integration-tests/test_bootstrap.py index 8a16f60..4d3aea5 100644 --- a/integration-tests/test_bootstrap.py +++ b/integration-tests/test_bootstrap.py @@ -3,36 +3,17 @@ Test running bootstrap script in different circumstances """ import concurrent.futures import os -import requests import subprocess from textwrap import dedent import time -def start_container(container_name, image, show_progress_page): - run_flags = [ - "--detach", - "--name", - container_name, - image, - "/bin/bash", - "-c", - "sleep 1000s", - ] - if show_progress_page: - # Use port-forwarding to be able to access the progress page when it starts - run_flags = ["--publish", "12000:80"] + run_flags - - # Start a detached container - subprocess.check_call(["docker", "run"] + run_flags) - - def install_pkgs(container_name, show_progress_page): # Install python3 inside the ubuntu container # There is no trusted Ubuntu+Python3 container we can use pkgs = ["python3"] if show_progress_page: - pkgs += ["systemd", "git"] + pkgs += ["systemd", "git", "curl"] # Create the sudoers dir, so that the installer succesfully gets to the # point of starting jupyterhub and stopping the progress page server. subprocess.check_output( @@ -63,7 +44,21 @@ def run_bootstrap(container_name, image, show_progress_page=False): # stop container if it is already running subprocess.run(["docker", "rm", "-f", container_name]) - start_container(container_name, image, show_progress_page) + # Start a detached container + subprocess.check_call( + [ + "docker", + "run", + "--detach", + "--name", + container_name, + image, + "/bin/bash", + "-c", + "sleep 1000s", + ] + ) + install_pkgs(container_name, show_progress_page) bootstrap_script = get_bootstrap_script_location(container_name, show_progress_page) @@ -115,12 +110,20 @@ def verify_progress_page(expected_status_code, timeout): start = time.time() while not progress_page_status and (time.time() - start < timeout): try: - resp = requests.get("http://127.0.0.1:12000/index.html") - if resp.status_code == expected_status_code: + resp = subprocess.check_output( + [ + "docker", + "exec", + "progress-page", + "curl", + "-i", + "http://localhost/index.html", + ] + ) + if b"HTTP/1.0 200 OK" in resp: progress_page_status = True break except Exception as e: - print(e) time.sleep(2) continue