handlers.sh 1.2 KB

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091
  3. . lib.sh
  4. setup_suite() {
  5. block_until_ready_by_name kube-system kilo-userspace
  6. }
  7. test_graph_handler() {
  8. assert "curl_pod 'http://10.4.0.1:1107/graph?format=svg&layout=circo' | grep -q '<svg'" "graph handler should produce SVG output"
  9. assert "curl_pod http://10.4.0.1:1107/graph?layout=circo | grep -q '<svg'" "graph handler should default to SVG output"
  10. assert "curl_pod http://10.4.0.1:1107/graph | grep -q '<svg'" "graph handler should default to SVG output"
  11. assert_fail "curl_pod http://10.4.0.1:1107/graph?layout=fake | grep -q '<svg'" "graph handler should reject invalid layout"
  12. assert_fail "curl_pod http://10.4.0.1:1107/graph?format=fake | grep -q '<svg'" "graph handler should reject invalid format"
  13. }
  14. test_health_handler() {
  15. assert "curl_pod http://10.4.0.1:1107/health" "health handler should return a status code of 200"
  16. }
  17. test_metrics_handler() {
  18. assert "curl_pod http://10.4.0.1:1107/metrics" "metrics handler should return a status code of 200"
  19. assert "(( $(curl_pod http://10.4.0.1:1107/metrics | grep -E ^kilo_nodes | cut -d " " -f 2) > 0 ))" "metrics handler should provide metric: kilo_nodes > 0"
  20. }