Skip to content

Commit

Permalink
use diff ports for tests since ubuntu cant use reuseaddr
Browse files Browse the repository at this point in the history
  • Loading branch information
thatstoasty committed Jan 12, 2025
1 parent b3bad11 commit ef0569e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions scripts/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/integration_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/integration/integration_test_server.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ef0569e

Please sign in to comment.