ci(awooop): add dedicated source link canary
This commit is contained in:
@@ -244,6 +244,62 @@ class AlertChainSmokeMetricTest(unittest.TestCase):
|
||||
self.assertEqual(calls[0]["headers"]["X-AwoooP-Operator-Id"], "gitea-e2e-health")
|
||||
self.assertEqual(calls[1]["headers"]["X-AwoooP-Operator-Key"], "secret")
|
||||
|
||||
def test_source_link_canary_requires_operator_key(self):
|
||||
result = alert_chain_smoke_test.send_source_link_canary(
|
||||
"https://awoooi.example",
|
||||
target_incident_id="INC-20260505-25E744",
|
||||
operator_key=None,
|
||||
operator_id="gitea-e2e-health",
|
||||
run_ref="run-123",
|
||||
)
|
||||
|
||||
self.assertFalse(result.passed)
|
||||
self.assertTrue(result.critical)
|
||||
self.assertIn("AWOOOP_OPERATOR_API_KEY", result.message)
|
||||
|
||||
def test_source_link_canary_posts_dedicated_sentry_payload(self):
|
||||
calls = []
|
||||
|
||||
def fake_post(url, payload, *, headers=None, timeout=None):
|
||||
calls.append(
|
||||
{
|
||||
"url": url,
|
||||
"payload": payload,
|
||||
"headers": headers,
|
||||
"timeout": timeout,
|
||||
}
|
||||
)
|
||||
return alert_chain_smoke_test.HttpGetResult(
|
||||
200,
|
||||
'{"status":"canary_recorded","provider":"sentry"}',
|
||||
)
|
||||
|
||||
original_post = alert_chain_smoke_test.http_post_json
|
||||
try:
|
||||
alert_chain_smoke_test.http_post_json = fake_post
|
||||
result = alert_chain_smoke_test.send_source_link_canary(
|
||||
"https://awoooi.example",
|
||||
target_incident_id="INC-20260505-25E744",
|
||||
operator_key="secret",
|
||||
operator_id="gitea-e2e-health",
|
||||
run_ref="run/123",
|
||||
)
|
||||
finally:
|
||||
alert_chain_smoke_test.http_post_json = original_post
|
||||
|
||||
self.assertTrue(result.passed)
|
||||
self.assertEqual(
|
||||
calls[0]["url"],
|
||||
"https://awoooi.example/api/v1/webhooks/sentry/error",
|
||||
)
|
||||
issue = calls[0]["payload"]["data"]["issue"]
|
||||
tags = calls[0]["payload"]["data"]["event"]["tags"]
|
||||
self.assertEqual(issue["id"], "awoooi-source-link-canary-run-123")
|
||||
self.assertEqual(issue["title"], "AwoooPSourceLinkCanary")
|
||||
self.assertIn(["source_link_canary", "true"], tags)
|
||||
self.assertIn(["target_incident_id", "INC-20260505-25E744"], tags)
|
||||
self.assertEqual(calls[0]["headers"]["X-AwoooP-Operator-Key"], "secret")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user