Skip to content

Commit 08d2897

Browse files
committed
ci(*): update helm-chart-smoketest.yml, add wasmtime-v1 coverage
Signed-off-by: Vaughn Dice <vdice@akamai.com>
1 parent d08aca9 commit 08d2897

4 files changed

Lines changed: 98 additions & 44 deletions

File tree

.github/workflows/helm-chart-smoketest.yml

Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -156,61 +156,97 @@ jobs:
156156
--set rcm.shimDownloaderConfig.content.sleepDuration=3 \
157157
deploy/helm
158158
159-
- name: apply Spin shim
159+
- name: verify configMap for shim-downloader is added
160160
run: |
161-
shim_file=config/samples/test_shim_spin.yaml
162-
if [[ "${{ matrix.config.type }}" == "microk8s" ]]; then
163-
cp $shim_file config/samples/test_shim_spin_microk8s.yaml
164-
shim_file=config/samples/test_shim_spin_microk8s.yaml
165-
# update file to remove the 'containerdRuntimeOptions' field
166-
# as there is a known bug that MicroK8s containerd does not pass the options
167-
yq -i 'del(.spec.containerdRuntimeOptions)' $shim_file
168-
fi
169-
kubectl apply -f $shim_file
170-
171-
- name: label nodes
172-
run: kubectl label node --all spin=true
173-
174-
- name: verify only one installer pod with Succeeded status
161+
timeout 60s bash -c 'until [[ $(kubectl -n rcm get $(kubectl get pods -n rcm --no-headers -o name | grep install | head -n1) -o jsonpath="{.spec.initContainers[0].envFrom[0].configMapRef.name}" 2>/dev/null) == "configmap-test" ]]; do sleep 2; done'
162+
163+
- name: apply shims
175164
run: |
176-
timeout 60s bash -c 'until [[ "$(kubectl -n rcm get $(kubectl get pods -n rcm --no-headers -o name | grep install | head -n1) -o jsonpath="{.status.phase}" 2>/dev/null)" == "Succeeded" ]]; do sleep 2; done'
165+
for shim_file in $(ls config/samples/sample_shim*); do
166+
if [[ "${{ matrix.config.type }}" == "microk8s" ]]; then
167+
cp $shim_file $shim_file.microk8s
168+
shim_file=$shim_file.microk8s
169+
# update file to remove the 'containerdRuntimeOptions' field
170+
# as there is a known bug that MicroK8s containerd does not pass the options
171+
yq -i 'del(.spec.containerdRuntimeOptions)' $shim_file
172+
fi
173+
kubectl apply -f $shim_file
174+
done
177175
178-
- name: verify configMap for shim-downloader is added
176+
- name: label nodes and wait for shim to be ready
179177
run: |
180-
timeout 60s bash -c 'until [[ $(kubectl -n rcm get $(kubectl get pods -n rcm --no-headers -o name | grep install | head -n1) -o jsonpath="{.spec.initContainers[0].envFrom[0].configMapRef.name}" 2>/dev/null) == "configmap-test" ]]; do sleep 2; done'
178+
for shim_file in $(ls config/samples/sample_shim*); do
179+
label="$(cat $shim_file | yq '.spec.nodeSelector' | tr -d '"' | tr -d '[:space:]' | sed s/:/=/g)"
180+
kubectl label node --all $label
181+
182+
shim_name="$(cat $shim_file | yq '.metadata.name')"
183+
# TODO: k3d can take a long round of failed install pods (exit code 6 when curling the artifact?)
184+
# Once this behavior is diagnosed and resolved, we should be able to shorten this timeout substantially
185+
timeout=600
186+
SECONDS=0 # Reset the internal bash timer to 0
187+
success=false
188+
189+
echo "Waiting for the $shim_name shim to be ready/installed..."
190+
191+
while [[ $SECONDS -lt $timeout ]]; do
192+
# Fetch both nodes and nodesReady
193+
read -r nodes nodesReady <<< $(kubectl get shim "$shim_name" \
194+
-o jsonpath='{.status.nodes} {.status.nodesReady}' 2>/dev/null)
195+
196+
# Check to see if all nodes are ready
197+
if [[ -n "$nodes" ]] && [[ -n "$nodesReady" ]] && [[ "$nodes" -eq "$nodesReady" ]]; then
198+
echo "Success: all nodes have the $shim_name shim installed."
199+
success=true
200+
break
201+
fi
202+
203+
sleep 2
204+
done
205+
206+
if [[ "${success}" != "true" ]]; then
207+
echo "Error: Timed out after ${timeout}s waiting for the $shim_name shim to be ready."
208+
exit 1
209+
fi
210+
done
181211
182-
- name: run Spin App
212+
# TODO: unify testdata/apps to all model the same behavor, eg simple web server, etc
213+
- name: run and verify spin app
183214
run: |
184-
kubectl apply -f testdata/apps/spin-app.yaml
185-
kubectl rollout status deployment wasm-spin --timeout 180s
186-
kubectl get pods -A
187-
kubectl port-forward svc/wasm-spin 8083:80 &
188-
timeout 90s bash -c 'until curl -f -vvv http://localhost:8083/hello; do sleep 2; done'
215+
kubectl apply -f testdata/apps/spin-v2-app.yaml
216+
kubectl rollout status deployment spin-v2-app --timeout 180s
217+
kubectl port-forward svc/spin-v2-app 8083:80 &
218+
timeout 60s bash -c 'until curl -f -vvv http://localhost:8083/hello; do sleep 2; done'
189219
190-
- name: restart system containerd
191-
if: matrix.config.type == 'microk8s'
192-
run: sudo systemctl start containerd
220+
- name: run and verify wasmtime app
221+
run: |
222+
kubectl apply -f testdata/apps/wasmtime-v1-app.yaml
223+
kubectl rollout status deployment wasmtime-v1-app --timeout 180s
224+
pod=$(kubectl get pod -l app=wasmtime-v1-app -o name)
225+
timeout 60s bash -c 'until kubectl logs $1 | grep -q "This is a song that never ends."; do sleep 2; done' -- $pod
193226
194227
- name: debug
195228
if: failure()
196229
run: |
197230
kubectl get pods -A
198-
kubectl describe shim spin-v2
199-
kubectl describe runtimeclass wasmtime-spin-v2
231+
kubectl describe shims
232+
kubectl describe runtimeclasses
200233
201234
# Get install pod logs
202-
install_pod=$(kubectl get pods -n rcm --no-headers -o name | awk '{if ($1 ~ "-spin-v2-install") print $0}')
203-
kubectl describe -n rcm $install_pod || true
204-
kubectl logs -n rcm -c downloader $install_pod || true
205-
kubectl logs -n rcm -c provisioner $install_pod || true
235+
for shim_file in $(ls config/samples/sample_shim*); do
236+
shim_name="$(cat $shim_file | yq '.metadata.name')"
237+
install_pod="$(kubectl get pods -n rcm --no-headers -o name | grep $shim_name-install)"
238+
kubectl describe -n rcm $install_pod || true
239+
kubectl logs -n rcm -c downloader $install_pod || true
240+
kubectl logs -n rcm -c provisioner $install_pod || true
241+
done
206242
207243
# RCM pod logs
208244
kubectl logs -n rcm -l app.kubernetes.io/name=runtime-class-manager || true
209245
kubectl describe -n rcm pod -l app.kubernetes.io/name=runtime-class-manager || true
210246
211247
# App logs
212-
kubectl logs -l app=wasm-spin || true
213-
kubectl describe pod -l app=wasm-spin || true
214-
215-
- name: Verify curl
216-
run: curl localhost:8083/hello
248+
for app_file in $(ls testdata/apps/*); do
249+
app=$(cat $app_file | yq 'select(.kind == "Deployment") | .metadata.name')
250+
kubectl logs -l app=$app || true
251+
kubectl describe pod -l app=$app || true
252+
done

config/samples/sample_shim_wasmtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323

2424
runtimeClass:
2525
name: wasmtime-v1
26-
handler: wasmtime
26+
handler: wasmtime-v1
2727

2828
rolloutStrategy:
2929
type: recreate
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
apiVersion: apps/v1
33
kind: Deployment
44
metadata:
5-
name: wasm-spin
5+
name: spin-v2-app
66
spec:
77
replicas: 1
88
selector:
99
matchLabels:
10-
app: wasm-spin
10+
app: spin-v2-app
1111
template:
1212
metadata:
1313
labels:
14-
app: wasm-spin
14+
app: spin-v2-app
1515
spec:
1616
runtimeClassName: wasmtime-spin-v2
1717
containers:
@@ -22,11 +22,11 @@ spec:
2222
apiVersion: v1
2323
kind: Service
2424
metadata:
25-
name: wasm-spin
25+
name: spin-v2-app
2626
spec:
2727
ports:
2828
- protocol: TCP
2929
port: 80
3030
targetPort: 80
3131
selector:
32-
app: wasm-spin
32+
app: spin-v2-app

testdata/apps/wasmtime-v1-app.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: wasmtime-v1-app
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: wasmtime-v1-app
10+
template:
11+
metadata:
12+
labels:
13+
app: wasmtime-v1-app
14+
spec:
15+
runtimeClassName: wasmtime-v1
16+
containers:
17+
- name: wasmtime-v1-app
18+
image: ghcr.io/containerd/runwasi/wasi-demo-app:latest

0 commit comments

Comments
 (0)