mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Test progress page stopped
This commit is contained in:
@@ -23,6 +23,7 @@ def run_bootstrap(container_name, image, flags=None):
|
|||||||
subprocess.check_output([
|
subprocess.check_output([
|
||||||
'docker', 'exec', container_name, 'apt-get', 'update'
|
'docker', 'exec', container_name, 'apt-get', 'update'
|
||||||
])
|
])
|
||||||
|
|
||||||
if flags:
|
if flags:
|
||||||
pkgs = ['python3', 'systemd', 'git']
|
pkgs = ['python3', 'systemd', 'git']
|
||||||
else:
|
else:
|
||||||
@@ -63,27 +64,35 @@ def test_inside_no_systemd_docker():
|
|||||||
assert output.returncode == 1
|
assert output.returncode == 1
|
||||||
|
|
||||||
|
|
||||||
def verify_progress_page(expected_status_code):
|
def verify_progress_page(expected_status_code, timeout):
|
||||||
progress_page_status = False
|
progress_page_status = False
|
||||||
while True:
|
start = time.time()
|
||||||
|
print("in verify_progress_page")
|
||||||
|
while not progress_page_status and (time.time() - start < timeout):
|
||||||
try:
|
try:
|
||||||
r = requests.get('http://127.0.0.1:12000/index.html')
|
resp = requests.get('http://127.0.0.1:12000/index.html')
|
||||||
status = r.status_code
|
if resp.status_code == expected_status_code:
|
||||||
if status == expected_status_code:
|
|
||||||
progress_page_status = True
|
progress_page_status = True
|
||||||
break;
|
break;
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
time.sleep(5)
|
time.sleep(2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return progress_page_status
|
return progress_page_status
|
||||||
|
|
||||||
def test_progress_page():
|
def test_progress_page():
|
||||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||||
future = executor.submit(run_bootstrap, 'progress-page', 'ubuntu:18.04', ['--show-progress-page'])
|
installer = executor.submit(run_bootstrap, 'progress-page', 'ubuntu:18.04', ['--show-progress-page'])
|
||||||
|
print("started installer")
|
||||||
|
|
||||||
# Check if progress page started
|
# Check if progress page started
|
||||||
started = verify_progress_page(200)
|
started = verify_progress_page(expected_status_code=200, timeout=120)
|
||||||
|
print("started")
|
||||||
assert started
|
assert started
|
||||||
|
|
||||||
return_value = future.result()
|
return_value = installer.result()
|
||||||
|
print("return value")
|
||||||
|
|
||||||
|
# Check if progress page stopped
|
||||||
|
stopped = verify_progress_page(expected_status_code=404, timeout=120)
|
||||||
|
assert stopped
|
||||||
|
|||||||
Reference in New Issue
Block a user