hanicz commented on code in PR #1202:
URL: https://github.com/apache/knox/pull/1202#discussion_r3116867883
##########
.github/workflows/tests/test_health.py:
##########
@@ -92,6 +99,112 @@ def test_health_ping_content_type_is_plain_text(self):
content_type = response.headers.get("Content-Type", "")
self.assertIn("text/plain", content_type)
-if __name__ == '__main__':
- unittest.main()
+class TestHealthGatewayExtended(unittest.TestCase):
+ """Anonymous HEALTH topology: gateway-status, ping variants, metrics keys,
routing."""
+
+ def setUp(self):
+ self.base_url = gateway_base_url()
+
+ def test_health_gateway_status_returns_ok_or_pending_plain_text(self):
+ """gateway-status is 200 text/plain with body OK or PENDING."""
+ url = self.base_url + "gateway/health/v1/gateway-status"
+ r = knox_get(url)
+ self.assertEqual(r.status_code, 200)
+ self.assertIn("text/plain", r.headers.get("Content-Type", ""))
+ self.assertIn(r.text.strip(), ("OK", "PENDING"))
+
+ def test_health_ping_post_returns_ok(self):
+ """POST /v1/ping matches GET semantics for the health service."""
+ url = self.base_url + "gateway/health/v1/ping"
+ r = knox_post(url)
+ self.assertEqual(r.status_code, 200)
+ self.assertEqual(r.text.strip(), "OK")
+
+ def test_health_ping_sets_cache_control_no_store(self):
+ """Ping uses must-revalidate,no-cache,no-store (see PingResource)."""
+ url = self.base_url + "gateway/health/v1/ping"
+ r = knox_get(url)
+ self.assertEqual(r.status_code, 200)
+ cc = r.headers.get("Cache-Control", "")
+ self.assertIn("no-store", cc)
+ self.assertIn("no-cache", cc)
+
+ def test_health_metrics_pretty_includes_all_core_top_level_keys(self):
+ """Pretty metrics JSON includes
timers/histograms/counters/gauges/version/meters."""
+ payload = health_metrics_pretty_dict(self.base_url)
+ self.assertTrue(
+ METRICS_TOP_LEVEL_KEYS.issubset(payload.keys()),
+ msg=f"Missing keys: {METRICS_TOP_LEVEL_KEYS -
set(payload.keys())}",
+ )
+
+ def test_health_metrics_without_pretty_includes_same_top_level_keys(self):
Review Comment:
I think there are test duplications with this new PR. For example we already
have `test_health_metrics_without_pretty_returns_json` which does the same.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]