-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the curl utility by the python requests library to avoid another host-dependency.
- Loading branch information
Showing
2 changed files
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
"""This module contains the tests for the nginx container, the image with nginx pre-installed. | ||
""" | ||
from bci_tester.data import NGINX_CONTAINER | ||
import requests | ||
from tenacity import retry | ||
from tenacity import stop_after_attempt | ||
from tenacity import wait_exponential | ||
|
||
from bci_tester.data import NGINX_CONTAINER | ||
|
||
CONTAINER_IMAGES = (NGINX_CONTAINER,) | ||
|
||
|
||
def test_nginx_welcome_page(auto_container, host): | ||
def test_nginx_welcome_page(auto_container): | ||
"""test that the default welcome page is served by the container.""" | ||
host_port = auto_container.forwarded_ports[0].host_port | ||
|
||
assert "Welcome to nginx" in host.check_output( | ||
f"curl -sf --retry 5 --retry-connrefused http://localhost:{host_port}/" | ||
# Retry 5 times with exponential backoff delay | ||
@retry( | ||
wait=wait_exponential(multiplier=1, min=4, max=10), | ||
stop=stop_after_attempt(5), | ||
) | ||
def check_nginx_response(): | ||
resp = requests.get(f"http://localhost:{host_port}/", timeout=30) | ||
resp.raise_for_status() | ||
assert "Welcome to nginx" in resp.text | ||
|
||
check_nginx_response() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters