diff --git a/README.md b/README.md index 27bf268aa..cfd4ebb7e 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,6 @@ cmake --build aws-c-http/build --target install To run some of the integration tests (start with localhost_integ_*), you need to set up a localhost that echo the request headers from `/echo` back first. -To do that, check [localhost](./tests/py_localhost/) script we have. +To do that, check [localhost](./tests/mock_server/) script we have. After that, configure and build your cmake project with `-DENABLE_LOCALHOST_INTEGRATION_TESTS=true` to build the tests with localhost and run them from `ctest --output-on-failure -R localhost_integ_*`. diff --git a/bin/h2benchmark/README.md b/bin/h2benchmark/README.md index 9fd1c93e0..798b0b7f6 100644 --- a/bin/h2benchmark/README.md +++ b/bin/h2benchmark/README.md @@ -4,7 +4,7 @@ this is a C program mimic the API call benchmark from aws-java-sdk-v2. https://g It collects how many API calls finish per second. Basically how many request can made per second. -The program connects to the local host that can be found [here](../../tests/py_localhost). +The program connects to the local host that can be found [here](../../tests/mock_server). To run the benchmark, build the h2benchmark with aws-c-http as dependency. TODO: Currently the configs are all hardcoded. diff --git a/tests/mock_server/README.md b/tests/mock_server/README.md index c93f6af19..f6ffaff8d 100644 --- a/tests/mock_server/README.md +++ b/tests/mock_server/README.md @@ -100,20 +100,18 @@ pip3 install trio h11 ### Basic Usage (HTTP + HTTPS) -Run both HTTP (port 80) and HTTPS (port 443) servers: +Run both HTTP (port 8081) and HTTPS (port 8082) servers: ```bash -sudo python3 mock_server.py +python3 mock_server.py ``` -Note: `sudo` is required for ports 80 and 443 on most systems. - -### Test Mode (Custom Port) +### Custom Ports Run on a custom port without sudo: ```bash -TEST_PORT=8080 python3 mock_server.py +HTTP_PORT=8080 HTTPS_PORT=8443 python3 mock_server.py ``` **Important**: Since this uses a self-signed certificate, clients must disable peer verification. diff --git a/tests/mock_server/h11mock_server.py b/tests/mock_server/h11mock_server.py index 8ef8a860f..e6ca074b2 100644 --- a/tests/mock_server/h11mock_server.py +++ b/tests/mock_server/h11mock_server.py @@ -247,15 +247,12 @@ async def serve_ssl(port, cert_file=os.path.join(os.path.dirname(__file__), async def main(): - test_port = os.environ.get('TEST_PORT') + http_port = os.environ.get('HTTP_PORT') + https_port = os.environ.get('HTTPS_PORT') - if test_port: - print(f"Running in test mode on port {test_port}") - await serve(int(test_port)) - else: - async with trio.open_nursery() as nursery: - nursery.start_soon(serve, 80) - nursery.start_soon(serve_ssl, 443) + async with trio.open_nursery() as nursery: + nursery.start_soon(serve, 8081 if not http_port else int(http_port)) + nursery.start_soon(serve_ssl, 8082 if not https_port else int(https_port)) if __name__ == "__main__":