handlers.sh 1.3 KB

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091
  3. . lib.sh
  4. setup_suite() {
  5. # shellcheck disable=SC2016
  6. block_until_ready_by_name kube-system kilo-userspace
  7. _kubectl wait pod -l app.kubernetes.io/name=adjacency --for=condition=Ready --timeout 3m
  8. }
  9. test_graph_handler() {
  10. assert "curl_pod 'http://10.4.0.1:1107/graph?format=svg&layout=circo' | grep -q '<svg'" "graph handler should produce SVG output"
  11. assert "curl_pod http://10.4.0.1:1107/graph?layout=circo | grep -q '<svg'" "graph handler should default to SVG output"
  12. assert "curl_pod http://10.4.0.1:1107/graph | grep -q '<svg'" "graph handler should default to SVG output"
  13. assert_fail "curl_pod http://10.4.0.1:1107/graph?layout=fake | grep -q '<svg'" "graph handler should reject invalid layout"
  14. assert_fail "curl_pod http://10.4.0.1:1107/graph?format=fake | grep -q '<svg'" "graph handler should reject invalid format"
  15. }
  16. test_health_handler() {
  17. assert "curl_pod http://10.4.0.1:1107/health" "health handler should return a status code of 200"
  18. }
  19. test_metrics_handler() {
  20. assert "curl_pod http://10.4.0.1:1107/metrics" "metrics handler should return a status code of 200"
  21. 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"
  22. }