hanicz commented on code in PR #1426:
URL: https://github.com/apache/knox/pull/1426#discussion_r4093603924
##########
.github/workflows/tests/test_health.py:
##########
@@ -95,6 +95,56 @@ def test_health_ping_content_type_is_plain_text(self):
content_type = response.headers.get("Content-Type", "")
self.assertIn("text/plain", content_type)
+ def test_health_ping_accepts_post(self):
+ """Ping supports POST for health probes that cannot use GET."""
+ url = self.base_url + "gateway/health/v1/ping"
+ response = knox_post(url)
+
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.text.strip(), "OK")
+ self.assertIn("text/plain", response.headers.get("Content-Type", ""))
+ self.assertEqual(
+ response.headers.get("Cache-Control"),
+ "must-revalidate,no-cache,no-store",
+ )
+
+ def test_health_metrics_pretty_query_changes_serialization(self):
+ """The pretty query parameter produces human-readable JSON output."""
+ url = self.base_url + "gateway/health/v1/metrics"
+ compact = knox_get(url)
+ pretty = knox_get(url + "?pretty=true")
+
+ self.assertEqual(compact.status_code, 200)
+ self.assertEqual(pretty.status_code, 200)
+ self.assertTrue(
+ len(pretty.text) > len(compact.text),
+ msg="pretty metrics should include formatting whitespace",
+ )
+ self.assertIn("\n", pretty.text)
+ self.assertEqual(json.loads(compact.text), json.loads(pretty.text))
Review Comment:
I don't like this, this can easily fail in the future due to shakiness. You
compare two different live metric snapshots.
--
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]