-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_requests.py
More file actions
112 lines (82 loc) · 3.84 KB
/
test_requests.py
File metadata and controls
112 lines (82 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
"""Execute test requests against the Flask app to exercise the urllib3 instrumentation."""
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")
# Health check
make_request("GET", "/health")
# ==========================================================================
# PoolManager Tests (high-level API)
# ==========================================================================
print("\n--- PoolManager Tests ---\n")
# Basic GET request - JSON response
make_request("GET", "/api/poolmanager/get-json")
# GET with query parameters
make_request("GET", "/api/poolmanager/get-with-params")
# GET with custom headers
make_request("GET", "/api/poolmanager/get-with-headers")
# POST with JSON body
make_request(
"POST",
"/api/poolmanager/post-json",
json={"title": "Test Post", "body": "This is a test post body", "userId": 1},
)
# POST with form data
make_request("POST", "/api/poolmanager/post-form")
# PUT request
make_request(
"PUT",
"/api/poolmanager/put-json",
json={"title": "Updated Post", "body": "This is an updated post body", "userId": 1},
)
# PATCH request
make_request("PATCH", "/api/poolmanager/patch-json", json={"title": "Patched Title"})
# DELETE request
make_request("DELETE", "/api/poolmanager/delete")
# Sequential chained requests
make_request("GET", "/api/poolmanager/chain")
# ==========================================================================
# HTTPConnectionPool Tests (low-level API)
# ==========================================================================
print("\n--- HTTPConnectionPool Tests ---\n")
# GET using connection pool directly
make_request("GET", "/api/connectionpool/get-json")
# POST using connection pool directly
make_request(
"POST",
"/api/connectionpool/post-json",
json={"title": "Pool Test", "body": "Connection pool test", "userId": 2},
)
# ==========================================================================
# Additional Tests
# ==========================================================================
print("\n--- Additional Tests ---\n")
# Request with timeout
make_request("GET", "/test/timeout")
# Request with retries
make_request("GET", "/test/retries")
# Redirect handling
make_request("GET", "/test/redirect")
# New PoolManager per request
make_request("GET", "/test/new-poolmanager")
# Basic authentication
make_request("GET", "/test/basic-auth")
# Multiple requests in sequence
make_request("GET", "/test/multiple-requests")
# ==========================================================================
# Avoid Double-span Test (requests library)
# ==========================================================================
print("\n--- Double-span Test (requests library) ---\n")
# Test that uses requests library (which internally uses urllib3)
# This should NOT create double spans
make_request("GET", "/test/requests-lib")
# ==========================================================================
# preload_content=False Tests (botocore/boto3 pattern)
# ==========================================================================
print("\n--- preload_content=False Tests ---\n")
# read() after preload_content=False (core botocore pattern)
make_request("GET", "/test/preload-content-false-read")
# read() + CRC32 checksum validation (DynamoDB pattern)
make_request("GET", "/test/preload-content-false-crc32")
# stream() after preload_content=False
make_request("GET", "/test/preload-content-false-stream")
print_request_summary()