oedb-backend/test_stats_endpoint.py

51 lines
1.5 KiB
Python
Raw Permalink Normal View History

2025-09-18 22:30:25 +02:00
#!/usr/bin/env python3
"""
Test script to check the stats endpoint response.
"""
import requests
import json
import sys
# URL of the stats endpoint (adjust if needed)
STATS_URL = "http://localhost:8080/stats"
def test_stats_endpoint():
"""
Make a request to the stats endpoint and print the response.
"""
try:
print(f"Making request to {STATS_URL}...")
response = requests.get(STATS_URL)
# Check if the request was successful
if response.status_code == 200:
print("Request successful!")
data = response.json()
# Print the events_count value
print(f"events_count: {data.get('events_count')}")
# Print other relevant information
print(f"last_updated: {data.get('last_updated')}")
print(f"uptime: {data.get('uptime')}")
print(f"db_uptime: {data.get('db_uptime')}")
# Check if events_count is -1
if data.get('events_count') == -1:
print("ISSUE CONFIRMED: events_count is -1")
else:
print(f"events_count is {data.get('events_count')}")
return data
else:
print(f"Request failed with status code: {response.status_code}")
print(f"Response: {response.text}")
return None
except Exception as e:
print(f"Error making request: {e}")
return None
if __name__ == "__main__":
test_stats_endpoint()