-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_utils.py
More file actions
37 lines (26 loc) · 907 Bytes
/
test_utils.py
File metadata and controls
37 lines (26 loc) · 907 Bytes
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
"""
Shared test utilities for e2e tests.
This module provides common functions used across all instrumentation e2e tests,
including request counting for validation.
"""
import time
import requests
BASE_URL = "http://localhost:8000"
_request_count = 0
def make_request(method, endpoint, **kwargs):
"""Make HTTP request, log result, and track count."""
global _request_count
_request_count += 1
url = f"{BASE_URL}{endpoint}"
print(f"→ {method} {endpoint}")
kwargs.setdefault("timeout", 30)
response = requests.request(method, url, **kwargs)
print(f" Status: {response.status_code}")
time.sleep(0.5)
return response
def get_request_count():
"""Return the current request count."""
return _request_count
def print_request_summary():
"""Print the total request count in a parseable format."""
print(f"\nTOTAL_REQUESTS_SENT:{_request_count}")