Skip to content

Commit 59f59c0

Browse files
committed
ref(smoketest): break out lengthy script; also remove containerdruntimeoptions if k3d
Signed-off-by: Vaughn Dice <vdice@akamai.com>
1 parent 08d2897 commit 59f59c0

3 files changed

Lines changed: 63 additions & 47 deletions

File tree

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

Lines changed: 19 additions & 46 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,58 +158,28 @@ jobs:
156158
--set rcm.shimDownloaderConfig.content.sleepDuration=3 \
157159
deploy/helm
158160
159-
- name: verify configMap for shim-downloader is added
160-
run: |
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-
163161
- name: apply shims
162+
working-directory: config/samples
164163
run: |
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
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
169169
# update file to remove the 'containerdRuntimeOptions' field
170170
# as there is a known bug that MicroK8s containerd does not pass the options
171+
# and k3d uses cgroupfs, not systemd
171172
yq -i 'del(.spec.containerdRuntimeOptions)' $shim_file
172173
fi
173174
kubectl apply -f $shim_file
174175
done
175176
176-
- name: label nodes and wait for shim to be ready
177-
run: |
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
177+
- name: label nodes and wait for shims to be ready
178+
run: ./scripts/sample-shims-label-nodes.sh
181179

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
180+
- name: verify configMap for shim-downloader is added
181+
run: |
182+
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'
211183
212184
# TODO: unify testdata/apps to all model the same behavor, eg simple web server, etc
213185
- name: run and verify spin app
@@ -228,11 +200,12 @@ jobs:
228200
if: failure()
229201
run: |
230202
kubectl get pods -A
231-
kubectl describe shims
232-
kubectl describe runtimeclasses
203+
kubectl describe shims || true
204+
kubectl describe runtimeclasses || true
233205
234206
# Get install pod logs
235-
for shim_file in $(ls config/samples/sample_shim*); do
207+
IFS=',' read -ra shims <<< "${{ env.SAMPLE_SHIMS }}"
208+
for shim_file in "${shims[@]}"; do
236209
shim_name="$(cat $shim_file | yq '.metadata.name')"
237210
install_pod="$(kubectl get pods -n rcm --no-headers -o name | grep $shim_name-install)"
238211
kubectl describe -n rcm $install_pod || true
@@ -245,7 +218,7 @@ jobs:
245218
kubectl describe -n rcm pod -l app.kubernetes.io/name=runtime-class-manager || true
246219
247220
# App logs
248-
for app_file in $(ls testdata/apps/*); do
221+
for app_file in testdata/apps/spin-v2-app.yaml testdata/apps/wasmtime-v1-app.yaml; do
249222
app=$(cat $app_file | yq 'select(.kind == "Deployment") | .metadata.name')
250223
kubectl logs -l app=$app || true
251224
kubectl describe pod -l app=$app || true
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

testdata/apps/wasmtime-v1-app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ spec:
1515
runtimeClassName: wasmtime-v1
1616
containers:
1717
- name: wasmtime-v1-app
18-
image: ghcr.io/containerd/runwasi/wasi-demo-app:latest
18+
image: ghcr.io/containerd/runwasi/wasi-demo-app:0.2.0

0 commit comments

Comments
 (0)