-
Notifications
You must be signed in to change notification settings - Fork 324
Expand file tree
/
Copy pathcloudwatch_logs_test.py
More file actions
61 lines (53 loc) · 1.96 KB
/
cloudwatch_logs_test.py
File metadata and controls
61 lines (53 loc) · 1.96 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
import pytest
from mcp import ClientSession
from conftest import models
from utils import assert_mcp_eval, run_llm_tool_loop
pytestmark = pytest.mark.anyio
@pytest.mark.parametrize("model", models)
@pytest.mark.flaky(reruns=2)
async def test_cloudwatch_list_log_groups(
model: str,
mcp_client: ClientSession,
mcp_transport: str,
):
"""Test that the LLM can list CloudWatch log groups."""
prompt = "List all CloudWatch log groups available on the CloudWatch datasource in Grafana. Use the us-east-1 region."
final_content, tools_called, mcp_server = await run_llm_tool_loop(
model, mcp_client, mcp_transport, prompt
)
assert_mcp_eval(
prompt,
final_content,
tools_called,
mcp_server,
"Does the response contain CloudWatch log group names? "
"It should mention specific log groups like 'test-application-logs' "
"or similar log group patterns. ",
expected_tools="list_cloudwatch_log_groups",
)
@pytest.mark.parametrize("model", models)
@pytest.mark.flaky(reruns=2)
async def test_cloudwatch_query_logs(
model: str,
mcp_client: ClientSession,
mcp_transport: str,
):
"""Test that the LLM can query CloudWatch Logs Insights."""
prompt = (
"Query CloudWatch Logs Insights for ERROR messages in the 'test-application-logs' log group "
"over the last hour. Use the us-east-1 region."
)
final_content, tools_called, mcp_server = await run_llm_tool_loop(
model, mcp_client, mcp_transport, prompt
)
assert_mcp_eval(
prompt,
final_content,
tools_called,
mcp_server,
"Does the response provide information about CloudWatch log data? "
"It should either show log entries or messages, mention that logs were retrieved, "
"or explain that no log data was found in the specified time range. "
"Generic error messages don't count.",
expected_tools="query_cloudwatch_logs",
)