From ef0569e43c64886778826109537b3ca5cf78e5d4 Mon Sep 17 00:00:00 2001 From: Mikhail Tavarez Date: Sun, 12 Jan 2025 11:49:53 -0600 Subject: [PATCH] use diff ports for tests since ubuntu cant use reuseaddr --- scripts/integration_test.sh | 4 ++-- tests/integration/integration_client.py | 6 +++--- tests/integration/integration_test_server.mojo | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/integration_test.sh b/scripts/integration_test.sh index 81c10c5d..62cd6abc 100644 --- a/scripts/integration_test.sh +++ b/scripts/integration_test.sh @@ -27,12 +27,12 @@ test_client() { (magic run mojo build -D LB_LOG_LEVEL=DEBUG -I . --debug-level full tests/integration/integration_test_client.mojo) || exit 1 echo "[INFO] Starting Python server..." - magic run fastapi dev tests/integration/integration_server.py & + magic run fastapi run tests/integration/integration_server.py & sleep 5 ./integration_test_client rm ./integration_test_client - kill_server "fastapi dev" + kill_server "fastapi run" } test_server diff --git a/tests/integration/integration_client.py b/tests/integration/integration_client.py index b22fe07e..c98c8ebb 100644 --- a/tests/integration/integration_client.py +++ b/tests/integration/integration_client.py @@ -4,15 +4,15 @@ # TODO: Pair with the Mojo integration server to test the client and server independently. print("\n~~~ Testing redirect ~~~") session = requests.Session() -response = session.get('http://127.0.0.1:8000/redirect', allow_redirects=True) +response = session.get('http://127.0.0.1:8080/redirect', allow_redirects=True) assert response.status_code == 200 assert response.text == "yay you made it" print("\n~~~ Testing close connection ~~~") -response = session.get('http://127.0.0.1:8000/close-connection', headers={'connection': 'close'}) +response = session.get('http://127.0.0.1:8080/close-connection', headers={'connection': 'close'}) assert response.status_code == 200 assert response.text == "connection closed" print("\n~~~ Testing internal server error ~~~") -response = session.get('http://127.0.0.1:8000/error', headers={'connection': 'keep-alive'}) +response = session.get('http://127.0.0.1:8080/error', headers={'connection': 'keep-alive'}) assert response.status_code == 500 diff --git a/tests/integration/integration_test_server.mojo b/tests/integration/integration_test_server.mojo index bd636b8a..ee538fb7 100644 --- a/tests/integration/integration_test_server.mojo +++ b/tests/integration/integration_test_server.mojo @@ -24,4 +24,4 @@ struct IntegrationTestService(HTTPService): fn main() raises: var server = Server(tcp_keep_alive=True) var service = IntegrationTestService() - server.listen_and_serve("127.0.0.1:8000", service) + server.listen_and_serve("127.0.0.1:8080", service)