-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f9fd09
commit 5120062
Showing
2 changed files
with
29 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 |
---|---|---|
|
@@ -17,3 +17,4 @@ | |
import routes | ||
import test_secrets | ||
import test_stats | ||
import test_launch |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Test if PAPI launches correctly. | ||
Sometimes can fail, especially with the @repeat_every() task (fastapi_utils | ||
package error). | ||
""" | ||
|
||
import subprocess | ||
import requests | ||
import time | ||
|
||
|
||
server_process = subprocess.Popen( | ||
['uvicorn', 'ai4papi.main:app', '--host', '0.0.0.0', '--port', '8080'], | ||
stdout=subprocess.DEVNULL, | ||
stderr = subprocess.DEVNULL, | ||
) | ||
time.sleep(15) # wait for PAPI to start | ||
|
||
try: | ||
response = requests.get("http://0.0.0.0:8080") | ||
assert response.status_code == 200, "PAPI status code is not 200" | ||
except requests.exceptions.ConnectionError: | ||
raise Exception("Failed to connect to the server") | ||
finally: | ||
server_process.kill() | ||
|
||
print("PAPI launch tests successful!") |