-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_queries.py
51 lines (42 loc) · 1.69 KB
/
test_queries.py
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
import requests
import time
import json
# List of test queries from your logs
test_queries = [
"Which namespace is the harbor service deployed to?",
"What is the name of the database in postgresql is harbor using?",
"How many pods are in the cluster?",
"What is the container port for harbor-core?",
"What is the status of harbor registry?",
"Which port will the harbor redis svc route traffic to?",
"What is the rediness probe path for the harbor core?",
"Which pod(s) associate with the harbor database secret",
"What is the mount path of the persistent volume for the harbor database?",
"What is the value of the environment variable CHART_CACHE_DRIVER in the harbor core pod?"
]
def test_query(query: str) -> None:
"""Send a single query to the API and print the response"""
url = "http://localhost:8000/query"
headers = {"Content-Type": "application/json"}
data = {"query": query}
try:
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
result = response.json()
print(f"\nQuery: {result['query']}")
print(f"Answer: {result['answer']}")
print("-" * 50)
except requests.exceptions.RequestException as e:
print(f"Error making request: {e}")
except json.JSONDecodeError:
print("Error decoding response")
def run_all_tests() -> None:
"""Run through all test queries with a small delay between each"""
print("Starting query tests...")
print("=" * 50)
for query in test_queries:
test_query(query)
time.sleep(1)
print("\nAll tests completed!")
if __name__ == "__main__":
run_all_tests()