-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add endpoint check to integration test
- Loading branch information
1 parent
07ec947
commit 4d5fcfc
Showing
1 changed file
with
24 additions
and
0 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,10 +1,34 @@ | ||
import os | ||
import time | ||
import requests | ||
from constellation import docker_util | ||
from src.grout_deploy.cli import main | ||
|
||
base_url = "http://localhost:5000" | ||
|
||
def wait_for_web_app(poll_interval=0.2, max=5): | ||
for i in range(0, round(max/poll_interval)): | ||
status_code = None | ||
try: | ||
status_code = requests.get(base_url).status_code | ||
except requests.exceptions.ConnectionError: | ||
pass | ||
if status_code == 200: | ||
return | ||
time.sleep(poll_interval) | ||
raise Exception(f"Web app not available within max timeout of {max}s") | ||
|
||
def test_start_and_stop_grout(): | ||
assert os.getenv("GITHUB_ACCESS_TOKEN") is not None, "GITHUB_ACCESS_TOKEN env var must be set to run integration test" | ||
main(["start", "grout", "--pull"]) | ||
assert docker_util.container_exists("grout") | ||
|
||
# check can access metadata endpoint | ||
wait_for_web_app() | ||
response = requests.get(f"{base_url}/metadata") | ||
assert response.status_code == 200 | ||
json = response.json() | ||
assert json["data"]["datasets"]["tile"]["gadm41"]["levels"] == ["admin0", "admin1", "admin2"] | ||
|
||
main(["stop"]) | ||
assert not docker_util.container_exists("grout") |