From ad3903223780788c15e55203b270dc3a4593aa0d Mon Sep 17 00:00:00 2001 From: Sohan Kshirsagar Date: Thu, 15 Jan 2026 17:02:02 -0800 Subject: [PATCH] use shared test utils in urllib3 and aiohttp e2e tests --- .../aiohttp/e2e-tests/src/test_requests.py | 22 ++----------------- .../urllib3/e2e-tests/src/test_requests.py | 22 ++----------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/drift/instrumentation/aiohttp/e2e-tests/src/test_requests.py b/drift/instrumentation/aiohttp/e2e-tests/src/test_requests.py index 0199aee..4695858 100644 --- a/drift/instrumentation/aiohttp/e2e-tests/src/test_requests.py +++ b/drift/instrumentation/aiohttp/e2e-tests/src/test_requests.py @@ -1,24 +1,6 @@ """Execute test requests against the Flask app to exercise the aiohttp instrumentation.""" -import time - -import requests - -BASE_URL = "http://localhost:8000" - - -def make_request(method, endpoint, **kwargs): - """Make HTTP request and log result.""" - url = f"{BASE_URL}{endpoint}" - print(f"-> {method} {endpoint}") - - # Set default timeout if not provided - kwargs.setdefault("timeout", 30) - response = requests.request(method, url, **kwargs) - print(f" Status: {response.status_code}") - time.sleep(0.5) # Small delay between requests - return response - +from drift.instrumentation.e2e_common.test_utils import make_request, print_request_summary if __name__ == "__main__": print("Starting test request sequence for aiohttp instrumentation...\n") @@ -106,4 +88,4 @@ def make_request(method, endpoint, **kwargs): # POST with bytes body make_request("POST", "/test/post-bytes") - print("\nAll requests completed successfully") + print_request_summary() diff --git a/drift/instrumentation/urllib3/e2e-tests/src/test_requests.py b/drift/instrumentation/urllib3/e2e-tests/src/test_requests.py index 4a6771f..dbb8f37 100644 --- a/drift/instrumentation/urllib3/e2e-tests/src/test_requests.py +++ b/drift/instrumentation/urllib3/e2e-tests/src/test_requests.py @@ -1,24 +1,6 @@ """Execute test requests against the Flask app to exercise the urllib3 instrumentation.""" -import time - -import requests - -BASE_URL = "http://localhost:8000" - - -def make_request(method, endpoint, **kwargs): - """Make HTTP request and log result.""" - url = f"{BASE_URL}{endpoint}" - print(f"-> {method} {endpoint}") - - # Set default timeout if not provided - kwargs.setdefault("timeout", 30) - response = requests.request(method, url, **kwargs) - print(f" Status: {response.status_code}") - time.sleep(0.5) # Small delay between requests - return response - +from drift.instrumentation.e2e_common.test_utils import make_request, print_request_summary if __name__ == "__main__": print("Starting test request sequence for urllib3 instrumentation...\n") @@ -127,4 +109,4 @@ def make_request(method, endpoint, **kwargs): # curl http://localhost:8000/test/bug/streaming-response # ========================================================================== - print("\nAll requests completed successfully") + print_request_summary()