Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mode to execute a Wasm program without an incoming request #55

Closed
acfoltzer opened this issue Jul 27, 2021 · 3 comments
Closed

Add a mode to execute a Wasm program without an incoming request #55

acfoltzer opened this issue Jul 27, 2021 · 3 comments

Comments

@acfoltzer
Copy link
Contributor

Viceroy should be able to execute a C@E Wasm program from the command line as just a one-shot without requiring an external process to send it a request. This would enable the use of Viceroy to run test suites that are compiled to a wasm32-wasi target with the C@E Wasm imports, such as those produced by cargo test --target wasm32-wasi.

The wasmtime CLI could be a useful model here. In a Rust project, I am able to run my test suite in both native code and Wasm simply by adding a .cargo/config:

[target.wasm32-wasi]
runner = "wasmtime"

In addition to providing the one-shot execution model, wasmtime also hooks up stdio and such to make it look like the Wasm program is executing within the host environment. That's pretty different from the headless daemon approach that Viceroy currently supports.

Finally, we'll need to figure out what to do about hostcalls. For the purposes of running a test suite, we'd get a lot of value even if the C@E hostcalls didn't do all that much. There are many useful tests to write that don't even use the C@E APIs, and many more that only would need, e.g., the ability to read and write to a body. Eventually I could imagine wanting some more sophisticated behavior even in a unit test, but since the daemonized version is already there I don't think the needs are as pressing.

@peterbourgon
Copy link

peterbourgon commented Aug 3, 2021

Ha! I wrote a script to approximate exactly this (poorly)

#!/usr/bin/env fish

set host 127.0.0.1
set port 7878

trap "lsof -i :$port -t | xargs kill | wait" EXIT

fastly compute serve --file main.wasm --skip-build --addr=$host:$port 2>&1 | sed -l -e "s/^/[Server       ] /" &

while not nc -z $host $port
	sleep 0.25
end

curl --silent --show-error --verbose --no-buffer -XGET $host:$port 2>&1 | sed -l -e "s/^/[       Client] /"

...which is to say: +1!

@tedmielczarek-fastly
Copy link

I think #211 fixed this.

@acfoltzer
Copy link
Contributor Author

Yep!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants