@@ -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
0 commit comments