-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2201 from fermyon/wasi-http-runtime-test
- Loading branch information
Showing
22 changed files
with
1,320 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from http.server import SimpleHTTPRequestHandler, HTTPServer | ||
import sys | ||
|
||
|
||
class EchoHandler(SimpleHTTPRequestHandler): | ||
def log_message(self, format, *args): | ||
# Write logs to stdout instead of stderr | ||
log_entry = "[%s] %s\n" % (self.log_date_time_string(), format % args) | ||
sys.stdout.write(log_entry) | ||
|
||
def _set_headers(self): | ||
self.send_response(200) | ||
self.send_header('Content-type', 'text/plain') | ||
self.end_headers() | ||
|
||
def do_POST(self): | ||
content_length = int(self.headers['Content-Length']) | ||
body = self.rfile.read(content_length) | ||
self._set_headers() | ||
self.wfile.write(body) | ||
|
||
|
||
def run(port=8080): | ||
server_address = ('', port) | ||
httpd = HTTPServer(server_address, EchoHandler) | ||
print(f'Starting server on port {port}...') | ||
httpd.serve_forever() | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
http-echo.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
spin_manifest_version = 2 | ||
|
||
[application] | ||
name = "wasi-http" | ||
authors = ["Fermyon Engineering <engineering@fermyon.com>"] | ||
version = "0.1.0" | ||
|
||
[[trigger.http]] | ||
route = "/" | ||
component = "test" | ||
|
||
[component.test] | ||
source = "{{wasi-http-v0.2.0-rc-2023-11-10}}" | ||
allowed_outbound_hosts = ["http://localhost:8080"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ edition = "2021" | |
|
||
[build-dependencies] | ||
cargo_toml = "0.17.1" | ||
wit-component = "0.19.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
tests/test-components/components/wasi-http-v0.2.0-rc-2023-11-10/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "wasi-http-rc-2023-11-10" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
url = "2.4.0" | ||
wit-bindgen = "0.16.0" | ||
helper = { path = "../../helper" } |
10 changes: 10 additions & 0 deletions
10
tests/test-components/components/wasi-http-v0.2.0-rc-2023-11-10/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Wasi HTTP (v0.2.0-rc-2023-11-10) | ||
|
||
Tests the Wasi HTTP outgoing request handler specifically the 0.2.0-rc-2023-11-10 version. | ||
|
||
The `wit` directory was copied from https://github.com/bytecodealliance/wasmtime/tree/v15.0.1/crates/wasi/wit and then modified to only include the parts actually used by this component. | ||
|
||
## Expectations | ||
|
||
This test component expects the following to be true: | ||
* It has access to an HTTP server on localhost:8080 that accepts POST requests and returns the same bytes in the response body as in the request body. |
Oops, something went wrong.