diff --git a/test_files/compare_container_performance.py b/test_files/compare_container_performance.py index 23b3113..bc4929d 100644 --- a/test_files/compare_container_performance.py +++ b/test_files/compare_container_performance.py @@ -20,6 +20,7 @@ class TestFields: failed_requests: str = "failed_requests" rps: str = "rps" time_mean: str = "time_mean" + non_2xx: str = "non-2xx-responses" def get_field_from_container_name(name, pos:int = 1): @@ -169,6 +170,12 @@ def run(self): self.ab_raw_results = _ab_runner.ab_results def get_results(self): + non_2xx = self.ab_raw_results.get(TestFields.non_2xx) or 0 + assert not non_2xx, ( + f"{non_2xx} non-2xx responses from {self.uri} on port {self.port}. " + f"The measurement is not hitting the endpoint: FastAPI answers 307 " + f"when the trailing slash of the route is missing from the URL." + ) _return = {} for key in [TestFields.time_mean, TestFields.rps, TestFields.failed_requests]: _return[key] = self.ab_raw_results.get(key) diff --git a/test_files/test_combo_best_worst.py b/test_files/test_combo_best_worst.py index 62d1e0c..aaa918a 100644 --- a/test_files/test_combo_best_worst.py +++ b/test_files/test_combo_best_worst.py @@ -17,11 +17,11 @@ class TestComboBestWorst(TestBase): def test_combo_sync_big_json_best_vs_worst(self): test_config = [] for container in worst_config.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 500 test_config.append(container) for container in best_config.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 500 test_config.append(container) p = CompareContainers(test_config) @@ -32,11 +32,11 @@ def test_combo_sync_big_json_best_vs_worst(self): def test_combo_async_big_json_best_vs_worst(self): test_config = [] for container in worst_config.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 500 test_config.append(container) for container in best_config.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 500 test_config.append(container) p = CompareContainers(test_config) diff --git a/test_files/test_gunicorn_vs_uvicorn.py b/test_files/test_gunicorn_vs_uvicorn.py index 40de81d..b6c5782 100644 --- a/test_files/test_gunicorn_vs_uvicorn.py +++ b/test_files/test_gunicorn_vs_uvicorn.py @@ -26,7 +26,7 @@ def test_gunicorn_vs_uvicorn_sync_w1(self): def test_gunicorn_vs_uvicorn_async_w1(self): async_test_config = [] for container in test_config_w1.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -43,7 +43,7 @@ def test_gunicorn_vs_uvicorn_sync_w2(self): def test_gunicorn_vs_uvicorn_async_w2(self): async_test_config = [] for container in test_config_w2.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) diff --git a/test_files/test_keepalive.py b/test_files/test_keepalive.py index 8b303cb..1e72ff0 100644 --- a/test_files/test_keepalive.py +++ b/test_files/test_keepalive.py @@ -20,7 +20,7 @@ def testnginx_socker_keepalive_sync(self): def test_nginx_socker_keepalive_async(self): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -31,7 +31,7 @@ def test_nginx_socker_keepalive_async(self): def test_nginx_socker_keepalive_sync_big_json_response(self): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -43,7 +43,7 @@ def test_nginx_socker_keepalive_sync_big_json_response(self): def test_nginx_socker_keepalive_async_big_json_response(self): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) diff --git a/test_files/test_nginx_port_vs_socket.py b/test_files/test_nginx_port_vs_socket.py index 9873f4e..d1e520a 100644 --- a/test_files/test_nginx_port_vs_socket.py +++ b/test_files/test_nginx_port_vs_socket.py @@ -52,7 +52,7 @@ def testnginx_port_vs_socket_sync(self): def test_nginx_port_vs_socket_async(self): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -63,7 +63,7 @@ def test_nginx_port_vs_socket_async(self): def test_nginx_port_vs_socket_sync_big_json_response(self): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -75,7 +75,7 @@ def test_nginx_port_vs_socket_sync_big_json_response(self): def test_nginx_port_vs_socket_async_big_json_response(self): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -94,7 +94,7 @@ def test_nginx_port_vs_socket_sync_gunicorn_w1t0(self): def test_nginx_port_vs_socket_async_gunicorn_w1t0(self): async_test_config = [] for container in test_config_gunicorn_w1t0.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -105,7 +105,7 @@ def test_nginx_port_vs_socket_async_gunicorn_w1t0(self): def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w1t0(self): async_test_config = [] for container in test_config_gunicorn_w1t0.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -117,7 +117,7 @@ def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w1t0(self): def test_nginx_port_vs_socket_async_big_json_response_gunicorn_w1t0(self): async_test_config = [] for container in test_config_gunicorn_w1t0.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -136,7 +136,7 @@ def test_nginx_port_vs_socket_sync_gunicorn_w2t0(self): def test_nginx_port_vs_socket_async_gunicorn_w2t0(self): async_test_config = [] for container in test_config_gunicorn_w2t0.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -147,7 +147,7 @@ def test_nginx_port_vs_socket_async_gunicorn_w2t0(self): def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w2t0(self): async_test_config = [] for container in test_config_gunicorn_w2t0.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -159,7 +159,7 @@ def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w2t0(self): def test_nginx_port_vs_socket_async_big_json_response_gunicorn_w2t0(self): async_test_config = [] for container in test_config_gunicorn_w2t0.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -178,7 +178,7 @@ def test_nginx_port_vs_socket_sync_gunicorn_w1t1(self): def test_nginx_port_vs_socket_async_gunicorn_w1t1(self): async_test_config = [] for container in test_config_gunicorn_w1t1.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -189,7 +189,7 @@ def test_nginx_port_vs_socket_async_gunicorn_w1t1(self): def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w1t1(self): async_test_config = [] for container in test_config_gunicorn_w1t1.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -201,7 +201,7 @@ def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w1t1(self): def test_nginx_port_vs_socket_async_big_json_response_gunicorn_w1t1(self): async_test_config = [] for container in test_config_gunicorn_w1t1.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -220,7 +220,7 @@ def test_nginx_port_vs_socket_sync_gunicorn_w2t1(self): def test_nginx_port_vs_socket_async_gunicorn_w2t1(self): async_test_config = [] for container in test_config_gunicorn_w2t1.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -231,7 +231,7 @@ def test_nginx_port_vs_socket_async_gunicorn_w2t1(self): def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w2t1(self): async_test_config = [] for container in test_config_gunicorn_w2t1.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -243,7 +243,7 @@ def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w2t1(self): def test_nginx_port_vs_socket_async_big_json_response_gunicorn_w2t1(self): async_test_config = [] for container in test_config_gunicorn_w2t1.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -262,7 +262,7 @@ def test_nginx_port_vs_socket_sync_gunicorn_w1t2(self): def test_nginx_port_vs_socket_async_gunicorn_w1t2(self): async_test_config = [] for container in test_config_gunicorn_w1t2.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -273,7 +273,7 @@ def test_nginx_port_vs_socket_async_gunicorn_w1t2(self): def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w1t2(self): async_test_config = [] for container in test_config_gunicorn_w1t2.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -285,7 +285,7 @@ def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w1t2(self): def test_nginx_port_vs_socket_async_big_json_response_gunicorn_w1t2(self): async_test_config = [] for container in test_config_gunicorn_w1t2.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -304,7 +304,7 @@ def test_nginx_port_vs_socket_sync_gunicorn_w2t2(self): def test_nginx_port_vs_socket_async_gunicorn_w2t2(self): async_test_config = [] for container in test_config_gunicorn_w2t2.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -315,7 +315,7 @@ def test_nginx_port_vs_socket_async_gunicorn_w2t2(self): def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w2t2(self): async_test_config = [] for container in test_config_gunicorn_w2t2.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) @@ -327,7 +327,7 @@ def test_nginx_port_vs_socket_sync_big_json_response_gunicorn_w2t2(self): def test_nginx_port_vs_socket_async_big_json_response_gunicorn_w2t2(self): async_test_config = [] for container in test_config_gunicorn_w2t2.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 1000 async_test_config.append(container) print(async_test_config) diff --git a/test_files/test_workers_and_threads.py b/test_files/test_workers_and_threads.py index b3908a9..ef0ebac 100644 --- a/test_files/test_workers_and_threads.py +++ b/test_files/test_workers_and_threads.py @@ -54,7 +54,7 @@ def test_workers_and_threads_sync(self, test_config): def test_workers_and_threads_async(self, test_config): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/async/items" + container["uri"] = "/async/items/" async_test_config.append(container) print(async_test_config) p = CompareContainers(async_test_config) @@ -68,7 +68,7 @@ def test_workers_and_threads_async(self, test_config): def test_workers_and_threads_sync_big_json_response(self, test_config): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/sync/big_json_response" + container["uri"] = "/sync/big_json_response/" container["request_count"] = 500 async_test_config.append(container) print(async_test_config) @@ -83,7 +83,7 @@ def test_workers_and_threads_sync_big_json_response(self, test_config): def test_workers_and_threads_async_big_json_response(self, test_config): async_test_config = [] for container in test_config.copy(): - container["uri"] = "/async/big_json_response" + container["uri"] = "/async/big_json_response/" container["request_count"] = 500 async_test_config.append(container) print(async_test_config)