Skip to content

Commit 936fe3b

Browse files
committed
Add Helm smoke test workflow
- Introduce a GitHub Actions workflow for DevLake Helm chart smoke testing. - Set up a temporary Kubernetes cluster with kind, install the Helm chart, and verify core services. - Incorporate health checks for Grafana and connected MySQL datasource. - Provide detailed diagnostics on failure to assist troubleshooting. Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent d81a0ae commit 936fe3b

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

.github/workflows/smoke-test.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: DevLake Helm Smoke Test
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "**" ]
8+
9+
jobs:
10+
smoke-test:
11+
name: Smoke Test
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 45
14+
env:
15+
RELEASE_NAME: devlake
16+
NAMESPACE: devlake
17+
GRAFANA_ADMIN_PASSWORD: admin
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v5
21+
22+
- name: Set up Helm
23+
uses: azure/setup-helm@v4
24+
25+
- name: Create kind cluster
26+
uses: helm/kind-action@v1.12.0
27+
with:
28+
cluster_name: devlake-e2e
29+
30+
- name: Set up kubectl
31+
uses: azure/setup-kubectl@v4
32+
33+
- name: Build chart dependencies (local)
34+
run: |
35+
helm dependency build charts/devlake
36+
37+
- name: Install DevLake chart (with Grafana)
38+
run: |
39+
ENCRYPTION_SECRET=$(openssl rand -base64 2000 | tr -dc 'A-Z' | fold -w 128 | head -n 1)
40+
set -euo pipefail
41+
helm install "$RELEASE_NAME" ./charts/devlake \
42+
--namespace "$NAMESPACE" \
43+
--create-namespace \
44+
--wait \
45+
--timeout 15m \
46+
--set lake.encryptionSecret.secret="${ENCRYPTION_SECRET}" \
47+
--set grafana.adminPassword="${GRAFANA_ADMIN_PASSWORD}"
48+
49+
- name: Wait for core workloads to be Ready
50+
run: |
51+
set -euo pipefail
52+
# MySQL (StatefulSet) may take longest on cold start
53+
kubectl rollout status statefulset/${RELEASE_NAME}-mysql -n "$NAMESPACE" --timeout=10m || true
54+
kubectl rollout status deployment/${RELEASE_NAME}-lake -n "$NAMESPACE" --timeout=10m
55+
kubectl rollout status deployment/${RELEASE_NAME}-ui -n "$NAMESPACE" --timeout=10m
56+
kubectl rollout status deployment/${RELEASE_NAME}-grafana -n "$NAMESPACE" --timeout=10m
57+
kubectl get pods -n "$NAMESPACE" -o wide
58+
59+
- name: Verify Grafana health and MySQL datasource connectivity
60+
run: |
61+
set -euo pipefail
62+
# Port-forward Grafana service locally
63+
kubectl port-forward -n "$NAMESPACE" svc/${RELEASE_NAME}-grafana 3000:80 >/tmp/pf.log 2>&1 &
64+
# Wait for port-forward to come up
65+
for i in {1..60}; do
66+
if curl -sSf -o /dev/null http://127.0.0.1:3000/api/health; then
67+
break
68+
fi
69+
sleep 2
70+
done
71+
# Basic health
72+
curl -sSf http://127.0.0.1:3000/api/health | tee /tmp/grafana_health.json
73+
# List datasources and find a MySQL datasource id
74+
# Requires admin credentials set via helm values
75+
DS_ID=$(curl -sSf -u admin:"${GRAFANA_ADMIN_PASSWORD}" http://127.0.0.1:3000/api/datasources \
76+
| jq -r '[.[] | select(.type=="mysql")][0].id // empty')
77+
if [ -z "${DS_ID}" ]; then
78+
echo "ERROR: No MySQL datasource found in Grafana" >&2
79+
exit 2
80+
fi
81+
echo "Found MySQL datasource id=${DS_ID}"
82+
# Check datasource health
83+
HEALTH_JSON=$(curl -sSf -u admin:"${GRAFANA_ADMIN_PASSWORD}" http://127.0.0.1:3000/api/datasources/${DS_ID}/health)
84+
echo "$HEALTH_JSON" | tee /tmp/grafana_ds_health.json
85+
echo "$HEALTH_JSON" | grep -q '"status":"OK"'
86+
87+
- name: Dump diagnostics on failure
88+
if: failure()
89+
run: |
90+
echo "===== Helm list ====="
91+
helm list -n "$NAMESPACE" || true
92+
echo "===== Helm status ====="
93+
helm status "$RELEASE_NAME" -n "$NAMESPACE" || true
94+
echo "===== Kubernetes objects ====="
95+
kubectl get all -n "$NAMESPACE" || true
96+
echo "===== Describe MySQL ====="
97+
kubectl describe statefulset/${RELEASE_NAME}-mysql -n "$NAMESPACE" || true
98+
kubectl logs statefulset/${RELEASE_NAME}-mysql -n "$NAMESPACE" --all-containers --tail=200 || true
99+
echo "===== Describe Lake ====="
100+
kubectl describe deploy/${RELEASE_NAME}-lake -n "$NAMESPACE" || true
101+
kubectl logs deploy/${RELEASE_NAME}-lake -n "$NAMESPACE" --all-containers --tail=200 || true
102+
echo "===== Describe UI ====="
103+
kubectl describe deploy/${RELEASE_NAME}-ui -n "$NAMESPACE" || true
104+
kubectl logs deploy/${RELEASE_NAME}-ui -n "$NAMESPACE" --all-containers --tail=200 || true
105+
echo "===== Describe Grafana ====="
106+
kubectl describe deploy/${RELEASE_NAME}-grafana -n "$NAMESPACE" || true
107+
kubectl logs deploy/${RELEASE_NAME}-grafana -n "$NAMESPACE" --all-containers --tail=200 || true

0 commit comments

Comments
 (0)