Skip to content

Commit 71ebea3

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 <okinakahiro@gmail.com>
1 parent fe95287 commit 71ebea3

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

.github/workflows/smoke-test.yaml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
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: Create kind cluster
42+
run: |
43+
chmod +x ./hack/ensure-kind.sh
44+
./hack/ensure-kind.sh
45+
kind create cluster --name capi-operator-smoke-test --wait 5m
46+
kubectl cluster-info --context kind-capi-operator-smoke-test
47+
48+
- name: Set up credentials secret
49+
run: |
50+
# Docker provider doesn't need real AWS credentials, but the secret is required
51+
export CREDENTIALS_SECRET_NAME="credentials-secret"
52+
export CREDENTIALS_SECRET_NAMESPACE="default"
53+
export AWS_B64ENCODED_CREDENTIALS=$(echo -n "dummy-credentials" | base64)
54+
55+
kubectl create secret generic "${CREDENTIALS_SECRET_NAME}" \
56+
--from-literal=AWS_B64ENCODED_CREDENTIALS="${AWS_B64ENCODED_CREDENTIALS}" \
57+
--namespace "${CREDENTIALS_SECRET_NAMESPACE}"
58+
59+
- name: Add Helm repositories
60+
run: |
61+
helm repo add capi-operator https://kubernetes-sigs.github.io/cluster-api-operator
62+
helm repo add jetstack https://charts.jetstack.io --force-update
63+
helm repo update
64+
65+
- name: Install cert-manager
66+
run: |
67+
helm install cert-manager jetstack/cert-manager \
68+
--namespace cert-manager \
69+
--create-namespace \
70+
--set installCRDs=true \
71+
--wait \
72+
--timeout 5m
73+
74+
- name: Wait for cert-manager to be ready
75+
run: |
76+
kubectl wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager
77+
kubectl wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-webhook
78+
kubectl wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-cainjector
79+
80+
- name: Install Cluster API Operator
81+
run: |
82+
helm install capi-operator capi-operator/cluster-api-operator \
83+
--create-namespace \
84+
-n capi-operator-system \
85+
--set infrastructure.docker.enabled=true \
86+
--set cert-manager.enabled=true \
87+
--set configSecret.name=credentials-secret \
88+
--set configSecret.namespace=default \
89+
--wait \
90+
--timeout 90s
91+
92+
- name: Deploy providers using cluster-api-operator-providers chart
93+
run: |
94+
# Create values file for providers
95+
cat <<EOF > /tmp/providers-values.yaml
96+
core:
97+
cluster-api:
98+
namespace: capi-system
99+
createNamespace: false
100+
infrastructure:
101+
docker:
102+
namespace: capd-system
103+
createNamespace: false
104+
configSecret:
105+
name: credentials-secret
106+
namespace: default
107+
EOF
108+
109+
# Install providers chart
110+
helm install capi-providers ./hack/charts/cluster-api-operator-providers \
111+
-f /tmp/providers-values.yaml \
112+
--wait \
113+
--timeout 5m
114+
115+
- name: Wait for providers to be ready
116+
run: |
117+
echo "Waiting for Core Provider to be ready..."
118+
kubectl wait --for=condition=Ready --timeout=300s -n capi-system coreprovider/cluster-api || true
119+
120+
echo "Waiting for Infrastructure Provider to be ready..."
121+
kubectl wait --for=condition=Ready --timeout=300s -n capd-system infrastructureprovider/docker || true
122+
123+
# Additional wait for deployments
124+
kubectl wait --for=condition=Available --timeout=300s -n capi-system deployment/capi-controller-manager || true
125+
kubectl wait --for=condition=Available --timeout=300s -n capd-system deployment/capd-controller-manager || true
126+
127+
- name: Verify installation
128+
run: |
129+
echo "=== Cluster API Operator Status ==="
130+
kubectl get pods -n capi-operator-system
131+
132+
echo -e "\n=== Core Provider Status ==="
133+
kubectl get coreprovider -A -o wide
134+
kubectl describe coreprovider -n capi-system cluster-api || true
135+
136+
echo -e "\n=== Infrastructure Provider Status ==="
137+
kubectl get infrastructureprovider -A -o wide
138+
kubectl describe infrastructureprovider -n capd-system docker || true
139+
140+
echo -e "\n=== All Pods ==="
141+
kubectl get pods -A | grep -E "(capi-|capd-)"
142+
143+
echo -e "\n=== CRDs ==="
144+
kubectl get crds | grep -E "(cluster.x-k8s.io|operator.cluster.x-k8s.io)"
145+
146+
- name: Check provider health
147+
run: |
148+
# Check if core provider is ready
149+
CORE_READY=$(kubectl get coreprovider -n capi-system cluster-api -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
150+
if [ "$CORE_READY" != "True" ]; then
151+
echo "Core provider is not ready"
152+
kubectl get coreprovider -n capi-system cluster-api -o yaml
153+
exit 1
154+
fi
155+
156+
# Check if infrastructure provider is ready
157+
INFRA_READY=$(kubectl get infrastructureprovider -n capd-system docker -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
158+
if [ "$INFRA_READY" != "True" ]; then
159+
echo "Infrastructure provider is not ready"
160+
kubectl get infrastructureprovider -n capd-system docker -o yaml
161+
exit 1
162+
fi
163+
164+
echo "All providers are ready!"
165+
166+
- name: Collect debug information on failure
167+
if: failure()
168+
run: |
169+
echo "=== Events ==="
170+
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
171+
172+
echo -e "\n=== CAPI Operator Logs ==="
173+
kubectl logs -n capi-operator-system deployment/capi-operator-controller-manager --tail=100 || true
174+
175+
echo -e "\n=== Core Provider Logs ==="
176+
kubectl logs -n capi-system deployment/capi-controller-manager --tail=100 || true
177+
178+
echo -e "\n=== Infrastructure Provider Logs ==="
179+
kubectl logs -n capd-system deployment/capd-controller-manager --tail=100 || true
180+
181+
echo -e "\n=== Describe Failed Pods ==="
182+
kubectl get pods -A | grep -v Running | grep -v Completed | tail -n +2 | while read namespace name ready status restarts age; do
183+
echo "Describing pod $name in namespace $namespace"
184+
kubectl describe pod -n $namespace $name
185+
echo "---"
186+
done
187+
188+
- name: Clean up
189+
if: always()
190+
run: |
191+
kind delete cluster --name capi-operator-smoke-test || true

0 commit comments

Comments
 (0)