fix(ci): tolerate empty source link canary response
All checks were successful
CD Pipeline / tests (push) Successful in 1m27s
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / build-and-deploy (push) Successful in 4m2s
CD Pipeline / post-deploy-checks (push) Successful in 1m45s

This commit is contained in:
Your Name
2026-06-04 20:31:43 +08:00
parent 6a3348795f
commit 29a67ec775
2 changed files with 122 additions and 6 deletions

View File

@@ -430,6 +430,53 @@ class AlertChainSmokeMetricTest(unittest.TestCase):
self.assertIn(["target_incident_id", "INC-20260505-25E744"], tags)
self.assertEqual(calls[0]["headers"]["X-AwoooP-Operator-Key"], "secret")
def test_source_link_canary_accepts_empty_2xx_for_downstream_readback(self):
def fake_post(url, payload, *, headers=None, timeout=None):
self.assertTrue(url.endswith("/api/v1/webhooks/sentry/error"))
self.assertEqual(payload["data"]["issue"]["title"], "AwoooPSourceLinkCanary")
return alert_chain_smoke_test.HttpGetResult(204, "")
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.assertIn("source-correlation smoke must verify readback", result.message)
def test_source_link_canary_reports_http_error_before_json_parse(self):
def fake_post(url, payload, *, headers=None, timeout=None):
self.assertTrue(url.endswith("/api/v1/webhooks/sentry/error"))
return alert_chain_smoke_test.HttpGetResult(
502,
"<html><body>bad gateway</body></html>",
)
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.assertFalse(result.passed)
self.assertIn("sentry HTTP 502", result.message)
self.assertIn("bad gateway", result.message)
if __name__ == "__main__":
unittest.main()