Skip to content

Commit 777d0b6

Browse files
committed
ci: Add smoke test workflow
Add a new GitHub Actions workflow for smoke testing. This workflow triggers on pull requests to the main and release branches as well as direct pushes to the main branch. It sets up a Kind cluster, installs necessary tools, and runs a series of installation and verification steps for the Cluster API Operator, cert-manager, and provider components. The workflow includes steps for error handling and cleanup after tests. Signed-off-by: kahirokunn <[email protected]>
1 parent c773386 commit 777d0b6

File tree

1 file changed

+189
-0
lines changed

1 file changed

+189
-0
lines changed

.github/workflows/smoke-test.yaml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Smoke Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- 'release-*'
8+
push:
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
smoke-test:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 15
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version-file: 'go.mod'
30+
31+
- name: Install kubectl
32+
run: |
33+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
34+
chmod +x kubectl
35+
sudo mv kubectl /usr/local/bin/
36+
37+
- name: Install Helm
38+
run: |
39+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
40+
41+
- name: Build charts
42+
run: |
43+
make release-chart
44+
45+
- name: Create kind cluster
46+
run: |
47+
chmod +x ./hack/ensure-kind.sh
48+
./hack/ensure-kind.sh
49+
kind create cluster --name capi-operator-smoke-test --wait 5m
50+
kubectl cluster-info --context kind-capi-operator-smoke-test
51+
52+
- name: Add Helm repositories
53+
run: |
54+
helm repo add capi-operator https://kubernetes-sigs.github.io/cluster-api-operator
55+
helm repo add jetstack https://charts.jetstack.io
56+
helm repo update
57+
58+
- name: Install cert-manager
59+
run: |
60+
helm install cert-manager jetstack/cert-manager \
61+
--namespace cert-manager \
62+
--create-namespace \
63+
--set installCRDs=true \
64+
--wait \
65+
--timeout 5m
66+
67+
- name: Install Cluster API Operator
68+
run: |
69+
# Find the packaged chart (exclude providers chart)
70+
CHART_PACKAGE=$(find out/package -name "cluster-api-operator-*.tgz" ! -name "*-providers-*.tgz" | head -n 1)
71+
echo "Using chart package: $CHART_PACKAGE"
72+
73+
helm install capi-operator "$CHART_PACKAGE" \
74+
--create-namespace \
75+
-n capi-operator-system \
76+
--set infrastructure.docker.enabled=true \
77+
--set cert-manager.enabled=true \
78+
--set configSecret.name=credentials-secret \
79+
--set configSecret.namespace=default \
80+
--wait \
81+
--timeout 90s
82+
83+
- name: Wait for CAPI Operator to be ready
84+
run: |
85+
kubectl wait --for=condition=Available --timeout=300s -n capi-operator-system deployment/capi-operator-controller-manager
86+
87+
- name: Deploy providers using cluster-api-operator-providers chart
88+
run: |
89+
# Create values file for providers
90+
cat <<EOF > /tmp/providers-values.yaml
91+
core:
92+
cluster-api:
93+
namespace: capi-system
94+
createNamespace: false
95+
infrastructure:
96+
docker:
97+
namespace: capd-system
98+
createNamespace: false
99+
configSecret:
100+
name: credentials-secret
101+
namespace: default
102+
EOF
103+
104+
# Install providers chart
105+
PROVIDERS_CHART_PACKAGE=$(find out/package -name "cluster-api-operator-providers-*.tgz" | head -n 1)
106+
echo "Using providers chart package: $PROVIDERS_CHART_PACKAGE"
107+
108+
helm install capi-providers "$PROVIDERS_CHART_PACKAGE" \
109+
-f /tmp/providers-values.yaml \
110+
--wait \
111+
--timeout 5m
112+
113+
- name: Wait for providers to be ready
114+
run: |
115+
echo "Waiting for Core Provider to be ready..."
116+
kubectl wait --for=condition=Ready --timeout=300s -n capi-system coreprovider/cluster-api || true
117+
118+
echo "Waiting for Infrastructure Provider to be ready..."
119+
kubectl wait --for=condition=Ready --timeout=300s -n capd-system infrastructureprovider/docker || true
120+
121+
# Additional wait for deployments
122+
kubectl wait --for=condition=Available --timeout=300s -n capi-system deployment/capi-controller-manager || true
123+
kubectl wait --for=condition=Available --timeout=300s -n capd-system deployment/capd-controller-manager || true
124+
125+
- name: Verify installation
126+
run: |
127+
echo "=== Cluster API Operator Status ==="
128+
kubectl get pods -n capi-operator-system
129+
130+
echo -e "\n=== Core Provider Status ==="
131+
kubectl get coreprovider -A -o wide
132+
kubectl describe coreprovider -n capi-system cluster-api || true
133+
134+
echo -e "\n=== Infrastructure Provider Status ==="
135+
kubectl get infrastructureprovider -A -o wide
136+
kubectl describe infrastructureprovider -n capd-system docker || true
137+
138+
echo -e "\n=== All Pods ==="
139+
kubectl get pods -A | grep -E "(capi-|capd-)"
140+
141+
echo -e "\n=== CRDs ==="
142+
kubectl get crds | grep -E "(cluster.x-k8s.io|operator.cluster.x-k8s.io)"
143+
144+
- name: Check provider health
145+
run: |
146+
# Check if core provider is ready
147+
CORE_READY=$(kubectl get coreprovider -n capi-system cluster-api -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
148+
if [ "$CORE_READY" != "True" ]; then
149+
echo "Core provider is not ready"
150+
kubectl get coreprovider -n capi-system cluster-api -o yaml
151+
exit 1
152+
fi
153+
154+
# Check if infrastructure provider is ready
155+
INFRA_READY=$(kubectl get infrastructureprovider -n capd-system docker -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
156+
if [ "$INFRA_READY" != "True" ]; then
157+
echo "Infrastructure provider is not ready"
158+
kubectl get infrastructureprovider -n capd-system docker -o yaml
159+
exit 1
160+
fi
161+
162+
echo "All providers are ready!"
163+
164+
- name: Collect debug information on failure
165+
if: failure()
166+
run: |
167+
echo "=== Events ==="
168+
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
169+
170+
echo -e "\n=== CAPI Operator Logs ==="
171+
kubectl logs -n capi-operator-system deployment/capi-operator-controller-manager --tail=100 || true
172+
173+
echo -e "\n=== Core Provider Logs ==="
174+
kubectl logs -n capi-system deployment/capi-controller-manager --tail=100 || true
175+
176+
echo -e "\n=== Infrastructure Provider Logs ==="
177+
kubectl logs -n capd-system deployment/capd-controller-manager --tail=100 || true
178+
179+
echo -e "\n=== Describe Failed Pods ==="
180+
kubectl get pods -A | grep -v Running | grep -v Completed | tail -n +2 | while read namespace name ready status restarts age; do
181+
echo "Describing pod $name in namespace $namespace"
182+
kubectl describe pod -n $namespace $name
183+
echo "---"
184+
done
185+
186+
- name: Clean up
187+
if: always()
188+
run: |
189+
kind delete cluster --name capi-operator-smoke-test || true

0 commit comments

Comments
 (0)