This commit is contained in:
larssand
2026-06-30 12:46:09 +02:00
parent e781f66003
commit 86065eca59
8 changed files with 58 additions and 8 deletions

View File

@@ -20,6 +20,11 @@ class _AggregateClient:
return self.responses.pop(0)
class _ProbeErrorClient:
def probe(self):
raise RuntimeError("connection refused")
class GraylogAggregateTests(unittest.TestCase):
def test_reads_count_from_graylog_schema_rows(self):
client = _AggregateClient([
@@ -33,6 +38,11 @@ class GraylogAggregateTests(unittest.TestCase):
self.assertEqual(client.arguments[0]["streams"], ["firewall"])
self.assertEqual(client.arguments[0]["metrics"], ["count()"])
def test_returns_error_status_instead_of_raising_on_probe_error(self):
status = GraylogAggregateSource(_ProbeErrorClient(), "firewall").fetch_count()
self.assertEqual(status["aggregate_status"], "error")
self.assertIn("probe_error", status["aggregate_error"])
def test_tries_fallback_argument_shape_after_tool_error(self):
client = _AggregateClient([
{"result": {"isError": True, "content": [{"type": "text", "text": "bad metrics"}]}},