Skip to content

Conversation

@brendandburns
Copy link
Contributor

@brendandburns brendandburns requested a review from a team as a code owner April 5, 2023 22:39
@brendandburns brendandburns requested review from pchickey and removed request for a team April 5, 2023 22:39
@brendandburns
Copy link
Contributor Author

fwiw, the test failed b/c there was a 502 error from postman-echo.com. We may want to turn up a localhost server instead to reduce flakiness.

@cfallin
Copy link
Member

cfallin commented Apr 6, 2023

fwiw, the test failed b/c there was a 502 error from postman-echo.com. We may want to turn up a localhost server instead to reduce flakiness.

I'd strongly +1 this: I was confused just now watching CI logs and seeing queries to an external website. We definitely should not have dependencies on a third-party service like this in our core CI flows, especially given that we will sometimes have time-sensitive CI builds (e.g. for security issues) that cannot tolerate third-party downtime.

@pchickey
Copy link
Contributor

pchickey commented Apr 6, 2023

Agreed, this is one of the things i thought was OK for an initial prototype but we should remedy pretty quickly.

In addition to having integration tests that run against local webservers, we can also pursue writing tests by abstracting over how hyper forms connections, and connect to hyper services in the same process, skipping syscalls entirely. We would still want some tests to connect on a "real" local network to make sure that code gets exercised as well.

@brendandburns
Copy link
Contributor Author

I will update the tests in this PR to run against localhost

@brendandburns brendandburns requested a review from a team as a code owner April 7, 2023 21:17
Copy link
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the test is failing at the moment for some reason, but once that is fixed this is good to go.

) -> anyhow::Result<()> {
let _thread = std::thread::spawn(|| {
run_server().unwrap();
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to break as soon as we run more than one test in a process, which I hope we will do soon. I'll work on the structural changes to the test suite to work that out soon, but its ok for now

Copy link
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

println!("localhost:3000 /get: {r1:?}");
assert_eq!(r1.status, 200);
let method = findHeader(&r1, "x-wasmtime-test-method".to_string()).unwrap_or("MISSING".to_string());
let method = r1.header("x-wasmtime-test-method").unwrap_or(&missing);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are the one place in Rust I prefer to write code that panics on failure - after all, that is what assert_eq! is doing. So in this case I would write this as let method = r1.header("x-wasmtime-test-method").unwrap(); rather than mess around with having the alternative value around with the correct type, which is clunky.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm still learning idiomatic rust. I will correct this in a follow-on PR.

@pchickey pchickey added this pull request to the merge queue Apr 11, 2023
Merged via the queue into bytecodealliance:main with commit 3ff6e0f Apr 11, 2023
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

Successfully merging this pull request may close these issues.

3 participants