Skip to content

Commit

Permalink
Merge pull request #46 from rajatjindal/e2e-test
Browse files Browse the repository at this point in the history
add workload delete test and refactor signal handling in run_wasi function
  • Loading branch information
jsturtevant authored Mar 27, 2024
2 parents 34e35ed + f1d7e6f commit f28792b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ pod-status-check:
workloads:
./scripts/workloads.sh

./PHONY: test-workloads-delete
test-workloads-delete:
./scripts/workloads-delete.sh

.PHONY: integration-tests
integration-tests: check-bins move-bins up pod-status-check workloads
integration-tests: check-bins move-bins up pod-status-check workloads test-workloads-delete
cargo test -p containerd-shim-spin-tests -- --nocapture

.PHONY: tests/clean
Expand Down
37 changes: 19 additions & 18 deletions containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,7 @@ impl SpinEngine {
}
};
info!(" >>> notifying main thread we are about to start");
let (abortable, abort_handle) = futures::future::abortable(f);
ctrlc::set_handler(move || abort_handle.abort())?;
match abortable.await {
Ok(Ok(())) => {
info!("Trigger executor shut down: exiting");
Ok(())
}
Ok(Err(err)) => {
log::error!("ERROR >>> Trigger executor failed: {:?}", err);
Err(err)
}
Err(aborted) => {
info!("Received signal to abort: {:?}", aborted);
Ok(())
}
}
f.await
}

async fn load_resolved_app_source(
Expand Down Expand Up @@ -339,8 +324,24 @@ impl Engine for SpinEngine {
stdio.redirect()?;
info!("setting up wasi");
let rt = Runtime::new().context("failed to create runtime")?;
rt.block_on(self.wasm_exec_async(ctx))?;
Ok(0)

let (abortable, abort_handle) = futures::future::abortable(self.wasm_exec_async(ctx));
ctrlc::set_handler(move || abort_handle.abort())?;

match rt.block_on(abortable) {
Ok(Ok(())) => {
info!("run_wasi shut down: exiting");
Ok(0)
}
Ok(Err(err)) => {
log::error!("run_wasi ERROR >>> failed: {:?}", err);
Err(err)
}
Err(aborted) => {
info!("Received signal to abort: {:?}", aborted);
Ok(0)
}
}
}

fn can_handle(&self, _ctx: &impl RuntimeContext) -> Result<()> {
Expand Down
9 changes: 9 additions & 0 deletions scripts/workloads-delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -euo pipefail

## test that the workload pods can be terminated
kubectl delete pod -l app=wasm-spin --timeout 10s
kubectl delete pod -l app=spin-keyvalue --timeout 10s
kubectl delete pod -l app=spin-outbound-redis --timeout 10s

0 comments on commit f28792b

Please sign in to comment.