-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoke_ingress.sh
More file actions
executable file
·79 lines (74 loc) · 2.78 KB
/
Copy pathsmoke_ingress.sh
File metadata and controls
executable file
·79 lines (74 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -euo pipefail
BASE="${INGRESS_BASE_URL:-http://localhost:8090}"
BASE="${BASE%/}"
expect_url() {
local name="$1"
local url="$2"
local out
out=$(curl --connect-timeout 5 --max-time 30 -fsS -o /dev/null -w "%{http_code}" "$url") || true
if [[ "${out:-}" =~ ^(200|301|302|303|307|308)$ ]]; then
echo "OK:${out} ${name} ${url}"
else
echo "FAIL:http_status=${out:-} ${name} ${url}" >&2
return 1
fi
}
expect_url_status() {
local name="$1"
local url="$2"
local allowed_regex="$3"
local out
out=$(curl --connect-timeout 5 --max-time 30 -fsS -o /dev/null -w "%{http_code}" "$url") || true
if [[ "${out:-}" =~ ${allowed_regex} ]]; then
echo "OK:${out} ${name} ${url}"
else
echo "FAIL:http_status=${out:-} ${name} ${url}" >&2
return 1
fi
}
expect_response_contains() {
local name="$1"
local url="$2"
local needle="$3"
local body body_lc needle_lc
body="$(curl --connect-timeout 5 --max-time 30 -fsSL "$url" || true)"
body_lc=$(printf '%s' "$body" | tr '[:upper:]' '[:lower:]')
needle_lc=$(printf '%s' "$needle" | tr '[:upper:]' '[:lower:]')
if [[ "${body_lc}" == *"${needle_lc}"* ]]; then
echo "OK:${name} body_contains=${needle}"
else
echo "FAIL:no_substring '${needle}' ${name} ${url}" >&2
return 1
fi
}
echo "Smoke ingress BASE=${BASE}"
expect_url root "${BASE}/"
expect_url dbt-docs "${BASE}/dbt/"
expect_url airflow-health "${BASE}/airflow/health"
expect_url_status airflow-api-version "${BASE}/airflow/api/v1/version" "^(200|401|403)$"
expect_url airflow "${BASE}/airflow/"
expect_url mlflow "${BASE}/mlflow/"
expect_url grafana "${BASE}/grafana/"
expect_url superset "${BASE}/superset/"
superset_double_code="$(curl -sS -o /dev/null -w "%{http_code}" "${BASE}/superset/superset/welcome/")"
if [[ "${superset_double_code}" != "301" ]]; then
echo "FAIL:superset_double_prefix expected 301 got ${superset_double_code} ${BASE}/superset/superset/welcome/" >&2
exit 1
fi
echo "OK:301 superset_double_prefix_redirect ${BASE}/superset/superset/welcome/"
expect_url jupyter "${BASE}/jupyter/"
expect_response_contains prometheus_markup "${BASE}/prometheus/graph" "Prometheus"
expect_url pushgateway "${BASE}/pushgateway/"
expect_url spark-master "${BASE}/spark-master/"
expect_url spark-worker "${BASE}/spark-worker/"
expect_url minio-console "${BASE}/minio-console/"
expect_url_status atlas "${BASE}/atlas/" "^(200|301|302|303|307|308|401)$"
expect_url_status node-red "${BASE}/node-red/" "^(200|301|302|303|307|308|401)$"
ALT_BASE="${INGRESS_ALT_BASE_URL:-}"
if [[ -n "${ALT_BASE}" ]]; then
ALT_BASE="${ALT_BASE%/}"
expect_url_status atlas_port80 "${ALT_BASE}/atlas/" "^(200|301|302|303|307|308|401)$"
expect_url_status node_red_port80 "${ALT_BASE}/node-red/" "^(200|301|302|303|307|308|401)$"
fi
echo "All ingress checks passed."