Skip to content

Commit f28792b

Browse files
authored
Merge pull request #46 from rajatjindal/e2e-test
add workload delete test and refactor signal handling in run_wasi function
2 parents 34e35ed + f1d7e6f commit f28792b

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ pod-status-check:
4343
workloads:
4444
./scripts/workloads.sh
4545

46+
./PHONY: test-workloads-delete
47+
test-workloads-delete:
48+
./scripts/workloads-delete.sh
49+
4650
.PHONY: integration-tests
47-
integration-tests: check-bins move-bins up pod-status-check workloads
51+
integration-tests: check-bins move-bins up pod-status-check workloads test-workloads-delete
4852
cargo test -p containerd-shim-spin-tests -- --nocapture
4953

5054
.PHONY: tests/clean

containerd-shim-spin/src/engine.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -232,22 +232,7 @@ impl SpinEngine {
232232
}
233233
};
234234
info!(" >>> notifying main thread we are about to start");
235-
let (abortable, abort_handle) = futures::future::abortable(f);
236-
ctrlc::set_handler(move || abort_handle.abort())?;
237-
match abortable.await {
238-
Ok(Ok(())) => {
239-
info!("Trigger executor shut down: exiting");
240-
Ok(())
241-
}
242-
Ok(Err(err)) => {
243-
log::error!("ERROR >>> Trigger executor failed: {:?}", err);
244-
Err(err)
245-
}
246-
Err(aborted) => {
247-
info!("Received signal to abort: {:?}", aborted);
248-
Ok(())
249-
}
250-
}
235+
f.await
251236
}
252237

253238
async fn load_resolved_app_source(
@@ -339,8 +324,24 @@ impl Engine for SpinEngine {
339324
stdio.redirect()?;
340325
info!("setting up wasi");
341326
let rt = Runtime::new().context("failed to create runtime")?;
342-
rt.block_on(self.wasm_exec_async(ctx))?;
343-
Ok(0)
327+
328+
let (abortable, abort_handle) = futures::future::abortable(self.wasm_exec_async(ctx));
329+
ctrlc::set_handler(move || abort_handle.abort())?;
330+
331+
match rt.block_on(abortable) {
332+
Ok(Ok(())) => {
333+
info!("run_wasi shut down: exiting");
334+
Ok(0)
335+
}
336+
Ok(Err(err)) => {
337+
log::error!("run_wasi ERROR >>> failed: {:?}", err);
338+
Err(err)
339+
}
340+
Err(aborted) => {
341+
info!("Received signal to abort: {:?}", aborted);
342+
Ok(0)
343+
}
344+
}
344345
}
345346

346347
fn can_handle(&self, _ctx: &impl RuntimeContext) -> Result<()> {

scripts/workloads-delete.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
## test that the workload pods can be terminated
6+
kubectl delete pod -l app=wasm-spin --timeout 10s
7+
kubectl delete pod -l app=spin-keyvalue --timeout 10s
8+
kubectl delete pod -l app=spin-outbound-redis --timeout 10s
9+

0 commit comments

Comments
 (0)