Skip to content

Commit 7e6b1b8

Browse files
authored
Merge pull request #605 from vdice/ci/update-smoketest-add-wasmtime-coverage
ci(*): update helm-chart-smoketest.yml, add wasmtime-v1 coverage
2 parents d08aca9 + 59f59c0 commit 7e6b1b8

5 files changed

Lines changed: 113 additions & 43 deletions

File tree

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

Lines changed: 46 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ env:
1111
MICROK8S_CHANNEL: 1.32/stable
1212
SHIM_SPIN_VERSION: v0.23.0
1313
DOCKER_BUILD_SUMMARY: false
14+
# A comma-delimited list of shim files in config/samples to test
15+
SAMPLE_SHIMS: sample_shim_spin.yaml,sample_shim_wasmtime.yaml
1416

1517
jobs:
1618
build-images:
@@ -156,61 +158,68 @@ jobs:
156158
--set rcm.shimDownloaderConfig.content.sleepDuration=3 \
157159
deploy/helm
158160
159-
- name: apply Spin shim
161+
- name: apply shims
162+
working-directory: config/samples
160163
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
175-
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'
164+
IFS=',' read -ra shims <<< "${{ env.SAMPLE_SHIMS }}"
165+
for shim_file in "${shims[@]}"; do
166+
if [[ "${{ matrix.config.type }}" == "microk8s" || "${{ matrix.config.type }}" == "k3d" ]]; then
167+
cp $shim_file $shim_file.amended
168+
shim_file=$shim_file.amended
169+
# update file to remove the 'containerdRuntimeOptions' field
170+
# as there is a known bug that MicroK8s containerd does not pass the options
171+
# and k3d uses cgroupfs, not systemd
172+
yq -i 'del(.spec.containerdRuntimeOptions)' $shim_file
173+
fi
174+
kubectl apply -f $shim_file
175+
done
176+
177+
- name: label nodes and wait for shims to be ready
178+
run: ./scripts/sample-shims-label-nodes.sh
177179

178180
- name: verify configMap for shim-downloader is added
179181
run: |
180182
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'
181183
182-
- name: run Spin App
184+
# TODO: unify testdata/apps to all model the same behavor, eg simple web server, etc
185+
- name: run and verify spin app
183186
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'
187+
kubectl apply -f testdata/apps/spin-v2-app.yaml
188+
kubectl rollout status deployment spin-v2-app --timeout 180s
189+
kubectl port-forward svc/spin-v2-app 8083:80 &
190+
timeout 60s bash -c 'until curl -f -vvv http://localhost:8083/hello; do sleep 2; done'
189191
190-
- name: restart system containerd
191-
if: matrix.config.type == 'microk8s'
192-
run: sudo systemctl start containerd
192+
- name: run and verify wasmtime app
193+
run: |
194+
kubectl apply -f testdata/apps/wasmtime-v1-app.yaml
195+
kubectl rollout status deployment wasmtime-v1-app --timeout 180s
196+
pod=$(kubectl get pod -l app=wasmtime-v1-app -o name)
197+
timeout 60s bash -c 'until kubectl logs $1 | grep -q "This is a song that never ends."; do sleep 2; done' -- $pod
193198
194199
- name: debug
195200
if: failure()
196201
run: |
197202
kubectl get pods -A
198-
kubectl describe shim spin-v2
199-
kubectl describe runtimeclass wasmtime-spin-v2
203+
kubectl describe shims || true
204+
kubectl describe runtimeclasses || true
200205
201206
# 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
207+
IFS=',' read -ra shims <<< "${{ env.SAMPLE_SHIMS }}"
208+
for shim_file in "${shims[@]}"; do
209+
shim_name="$(cat $shim_file | yq '.metadata.name')"
210+
install_pod="$(kubectl get pods -n rcm --no-headers -o name | grep $shim_name-install)"
211+
kubectl describe -n rcm $install_pod || true
212+
kubectl logs -n rcm -c downloader $install_pod || true
213+
kubectl logs -n rcm -c provisioner $install_pod || true
214+
done
206215
207216
# RCM pod logs
208217
kubectl logs -n rcm -l app.kubernetes.io/name=runtime-class-manager || true
209218
kubectl describe -n rcm pod -l app.kubernetes.io/name=runtime-class-manager || true
210219
211220
# 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
221+
for app_file in testdata/apps/spin-v2-app.yaml testdata/apps/wasmtime-v1-app.yaml; do
222+
app=$(cat $app_file | yq 'select(.kind == "Deployment") | .metadata.name')
223+
kubectl logs -l app=$app || true
224+
kubectl describe pod -l app=$app || true
225+
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: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
SCRIPT_DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
5+
6+
# Currently used in .github/workflows/helm-chart-smoketest.yml
7+
# Iterates through all sample shims and applies their labels to all nodes
8+
# using the current kubernetes context.
9+
# Waits for all corresponding Shim resources to be ready, else fails.
10+
11+
IFS=',' read -ra shims <<< "${SAMPLE_SHIMS}"
12+
for shim_file in "${shims[@]}"; do
13+
cd "${SCRIPT_DIR}/../config/samples"
14+
label="$(cat $shim_file | yq '.spec.nodeSelector' | tr -d '"' | tr -d '[:space:]' | sed s/:/=/g)"
15+
kubectl label node --all $label
16+
17+
shim_name="$(cat $shim_file | yq '.metadata.name')"
18+
timeout=300
19+
SECONDS=0 # Reset the internal bash timer to 0
20+
success=false
21+
22+
echo "Waiting for the $shim_name shim to be ready/installed..."
23+
24+
while [[ $SECONDS -lt $timeout ]]; do
25+
# Fetch both nodes and nodesReady
26+
read -r nodes nodesReady <<< $(kubectl get shim "$shim_name" \
27+
-o jsonpath='{.status.nodes} {.status.nodesReady}' 2>/dev/null)
28+
29+
# Check to see if all nodes are ready
30+
if [[ -n "$nodes" ]] && [[ -n "$nodesReady" ]] && [[ "$nodes" -eq "$nodesReady" ]]; then
31+
echo "Success: all nodes have the $shim_name shim installed."
32+
success=true
33+
break
34+
fi
35+
36+
sleep 2
37+
done
38+
39+
if [[ "${success}" != "true" ]]; then
40+
echo "Error: Timed out after ${timeout}s waiting for the $shim_name shim to be ready."
41+
exit 1
42+
fi
43+
done
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:0.2.0

0 commit comments

Comments
 (0)