Skip to content

Commit 3f03d48

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 3f03d48

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

.github/workflows/smoke-test.yaml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
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+
configSecret:
104+
name: credentials-secret
105+
namespace: default
106+
EOF
107+
108+
# Install providers chart
109+
helm install capi-providers ./hack/charts/cluster-api-operator-providers \
110+
-f /tmp/providers-values.yaml \
111+
--wait \
112+
--timeout 5m
113+
114+
- name: Wait for providers to be ready
115+
run: |
116+
echo "Waiting for Core Provider to be ready..."
117+
kubectl wait --for=condition=Ready --timeout=300s -n capi-system coreprovider/cluster-api || true
118+
119+
echo "Waiting for Infrastructure Provider to be ready..."
120+
kubectl wait --for=condition=Ready --timeout=300s -n capd-system infrastructureprovider/docker || true
121+
122+
# Additional wait for deployments
123+
kubectl wait --for=condition=Available --timeout=300s -n capi-system deployment/capi-controller-manager || true
124+
kubectl wait --for=condition=Available --timeout=300s -n capd-system deployment/capd-controller-manager || true
125+
126+
- name: Verify installation
127+
run: |
128+
echo "=== Cluster API Operator Status ==="
129+
kubectl get pods -n capi-operator-system
130+
131+
echo -e "\n=== Core Provider Status ==="
132+
kubectl get coreprovider -A -o wide
133+
kubectl describe coreprovider -n capi-system cluster-api || true
134+
135+
echo -e "\n=== Infrastructure Provider Status ==="
136+
kubectl get infrastructureprovider -A -o wide
137+
kubectl describe infrastructureprovider -n capd-system docker || true
138+
139+
echo -e "\n=== All Pods ==="
140+
kubectl get pods -A | grep -E "(capi-|capd-)"
141+
142+
echo -e "\n=== CRDs ==="
143+
kubectl get crds | grep -E "(cluster.x-k8s.io|operator.cluster.x-k8s.io)"
144+
145+
- name: Check provider health
146+
run: |
147+
# Check if core provider is ready
148+
CORE_READY=$(kubectl get coreprovider -n capi-system cluster-api -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
149+
if [ "$CORE_READY" != "True" ]; then
150+
echo "Core provider is not ready"
151+
kubectl get coreprovider -n capi-system cluster-api -o yaml
152+
exit 1
153+
fi
154+
155+
# Check if infrastructure provider is ready
156+
INFRA_READY=$(kubectl get infrastructureprovider -n capd-system docker -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
157+
if [ "$INFRA_READY" != "True" ]; then
158+
echo "Infrastructure provider is not ready"
159+
kubectl get infrastructureprovider -n capd-system docker -o yaml
160+
exit 1
161+
fi
162+
163+
echo "All providers are ready!"
164+
165+
- name: Collect debug information on failure
166+
if: failure()
167+
run: |
168+
echo "=== Events ==="
169+
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
170+
171+
echo -e "\n=== CAPI Operator Logs ==="
172+
kubectl logs -n capi-operator-system deployment/capi-operator-controller-manager --tail=100 || true
173+
174+
echo -e "\n=== Core Provider Logs ==="
175+
kubectl logs -n capi-system deployment/capi-controller-manager --tail=100 || true
176+
177+
echo -e "\n=== Infrastructure Provider Logs ==="
178+
kubectl logs -n capd-system deployment/capd-controller-manager --tail=100 || true
179+
180+
echo -e "\n=== Describe Failed Pods ==="
181+
kubectl get pods -A | grep -v Running | grep -v Completed | tail -n +2 | while read namespace name ready status restarts age; do
182+
echo "Describing pod $name in namespace $namespace"
183+
kubectl describe pod -n $namespace $name
184+
echo "---"
185+
done
186+
187+
- name: Clean up
188+
if: always()
189+
run: |
190+
kind delete cluster --name capi-operator-smoke-test || true

0 commit comments

Comments
 (0)