ci(awooop): add dedicated source link canary
All checks were successful
Code Review / ai-code-review (push) Successful in 11s
CD Pipeline / tests (push) Successful in 4m8s
CD Pipeline / build-and-deploy (push) Successful in 4m29s
CD Pipeline / post-deploy-checks (push) Successful in 1m58s

This commit is contained in:
Your Name
2026-05-21 12:34:51 +08:00
parent 89a5a2ea85
commit 867e0e73df
3 changed files with 178 additions and 3 deletions

View File

@@ -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()