Skip to content

Commit b4b4565

Browse files
refactor: use shared test utils in urllib3 and aiohttp e2e tests (#37)
1 parent fd368a5 commit b4b4565

File tree

2 files changed

+4
-40
lines changed

2 files changed

+4
-40
lines changed

drift/instrumentation/aiohttp/e2e-tests/src/test_requests.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
"""Execute test requests against the Flask app to exercise the aiohttp instrumentation."""
22

3-
import time
4-
5-
import requests
6-
7-
BASE_URL = "http://localhost:8000"
8-
9-
10-
def make_request(method, endpoint, **kwargs):
11-
"""Make HTTP request and log result."""
12-
url = f"{BASE_URL}{endpoint}"
13-
print(f"-> {method} {endpoint}")
14-
15-
# Set default timeout if not provided
16-
kwargs.setdefault("timeout", 30)
17-
response = requests.request(method, url, **kwargs)
18-
print(f" Status: {response.status_code}")
19-
time.sleep(0.5) # Small delay between requests
20-
return response
21-
3+
from drift.instrumentation.e2e_common.test_utils import make_request, print_request_summary
224

235
if __name__ == "__main__":
246
print("Starting test request sequence for aiohttp instrumentation...\n")
@@ -106,4 +88,4 @@ def make_request(method, endpoint, **kwargs):
10688
# POST with bytes body
10789
make_request("POST", "/test/post-bytes")
10890

109-
print("\nAll requests completed successfully")
91+
print_request_summary()

drift/instrumentation/urllib3/e2e-tests/src/test_requests.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
"""Execute test requests against the Flask app to exercise the urllib3 instrumentation."""
22

3-
import time
4-
5-
import requests
6-
7-
BASE_URL = "http://localhost:8000"
8-
9-
10-
def make_request(method, endpoint, **kwargs):
11-
"""Make HTTP request and log result."""
12-
url = f"{BASE_URL}{endpoint}"
13-
print(f"-> {method} {endpoint}")
14-
15-
# Set default timeout if not provided
16-
kwargs.setdefault("timeout", 30)
17-
response = requests.request(method, url, **kwargs)
18-
print(f" Status: {response.status_code}")
19-
time.sleep(0.5) # Small delay between requests
20-
return response
21-
3+
from drift.instrumentation.e2e_common.test_utils import make_request, print_request_summary
224

235
if __name__ == "__main__":
246
print("Starting test request sequence for urllib3 instrumentation...\n")
@@ -127,4 +109,4 @@ def make_request(method, endpoint, **kwargs):
127109
# curl http://localhost:8000/test/bug/streaming-response
128110
# ==========================================================================
129111

130-
print("\nAll requests completed successfully")
112+
print_request_summary()

0 commit comments

Comments
 (0)