-
-
Notifications
You must be signed in to change notification settings - Fork 73
Draft: Feature 587 turmoil http.1 client-server test #642
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
base: main
Are you sure you want to change the base?
Draft: Feature 587 turmoil http.1 client-server test #642
Conversation
- Adds `test-turmoil/test-client-server` package - Adds simple client server test using tokio-turmoil
@GlenDC or @soundofspace I was wondering if I could get some early feedback here. Am interested to know if this is what you guys had in mind? What do you think of the package structure? Any changes you would like to see? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. Left some feedback already.
Besides that, two questions:
- Why does this need to be a separate package? Can this not be just another main application in
/tests
? - What is the output when you run this? Is it just binary it works or fails? are there warnings. Asking as I haven't played with turmoil myself yet.
Cargo.toml
Outdated
@@ -48,7 +48,7 @@ members = [ | |||
"rama-udp", | |||
"rama-unix", | |||
"rama-utils", | |||
"rama-ws", | |||
"rama-ws", "tests-turmoil/test-client-server", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
give entries their own line please
|
||
[dependencies] | ||
rama = { path = "../..", features = ["full"] } | ||
turmoil = "0.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add as a workspace dep first and than use { workspace = true }
tokio = { workspace = true } | ||
serde = { workspace = true } | ||
serde_json = { workspace = true } | ||
tracing = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use from rama-core
}; | ||
use turmoil::Builder; | ||
|
||
const ADDRESS: SocketAddress = SocketAddress::default_ipv4(62004); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you made sure this port is not used by any other test?
HttpServer::http1() | ||
.listen( | ||
address.into(), | ||
(TraceLayer::new_for_http()).into_layer(WebService::default().get("/", "Hello, World")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useless round brackets
(TraceLayer::new_for_http()).into_layer(WebService::default().get("/", "Hello, World")), | ||
) | ||
.await | ||
.map_err(|e| e as Box<dyn std::error::Error>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map_err(|e| e as Box<dyn std::error::Error>) | |
.map_err(Into::into) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wont work, but also here we are trying to coerce the type so that w ecan drop the Send + Sync
trait bounds.
Co-authored-by: Glen De Cauwsemaecker <[email protected]>
Co-authored-by: Glen De Cauwsemaecker <[email protected]>
Co-authored-by: Glen De Cauwsemaecker <[email protected]>
Co-authored-by: Glen De Cauwsemaecker <[email protected]>
Now I have re-read this I think what you actually wanted was integration tests in a
There are no outputs unless logging is enabled. If the assertion fails, the binary panics as expected. If a For example if we do: let mut sim = Builder::new().enable_tokio_io().build();
sim.host(ADDRESS.ip_addr(), || async {
Err("error returned from server".into())
});
sim.client(...);
sim.run().expect("Error during simulation");
$ cargo run
...
2025-07-25T19:30:18.246122Z INFO turmoil: New nodename="0.0.0.0" addr=0.0.0.0
2025-07-25T19:30:18.247514Z INFO turmoil: New nodename="client" addr=192.168.0.1
thread 'main' panicked at tests-turmoil/test-client-server/src/main.rs:73:23:
Error during simulation: "error returned from server"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
Is there no bookkeeping that can be checked to see what inputs and parameters it used during the tests? And how to know it ran at all? |
There are some functions for inspecting the simulation state:
The simulation (struct Sim) provide some functions for manipulating the environment. However after some more investigation I dont believe this test is using the turmoil net types.
The output should show network traffice as it sent and delivered. I think I need to adjust the client and server so that they are using Something more like:
We could use something like tracing_test to scrape logs and assert specific network events. Although its not great. I think a better solution might be to add counters to the turmoil::Sim type |
Cool I think what you have of tracing and output is probably good enough for now, unless you think differently. |
153e3e8
to
049503f
Compare
Adds a simple http.1 client - server test using tokio-turmoil
Addresses #587