Rocket/contrib/sync_db_pools/lib/tests/shutdown.rs

34 lines
1.0 KiB
Rust
Raw Normal View History

#[cfg(test)]
#[cfg(all(feature = "diesel_sqlite_pool"))]
mod sqlite_shutdown_test {
use rocket::{async_test, Build, Rocket};
use rocket_sync_db_pools::database;
#[database("test")]
struct Pool(diesel::SqliteConnection);
async fn rocket() -> Rocket<Build> {
use rocket::figment::{util::map, Figment};
let options = map!["url" => ":memory:"];
let config = Figment::from(rocket::Config::debug_default())
Support QUIC and HTTP/3. This commit adds support for HTTP/3 and QUIC under a disabled-by-default feature `http3-preview`. The current implementation depends on modified versions of h3 and s2n-quic-h3 which will need to be upstreamed and published before a release is possible. During the course of development various facets of Rocket's internal connection handling and recent listener APIs were improved. The complete list of changes included in this PR is: * A `shutdown` module was introduced. * `config::Shutdown` was renamed to `ShutdownConfig` and moved to `shutdown` while being re-exported from `config`. * `ListenerAddr` is now called `Endpoint`. Various methods which previously referred to "addresses" now refer to "endpoints". * `Rocket::endpoint()` was renamed to `Rocket::endpoints()` and now returns an iterator over the endpoints Rocket is listening on. * `Endpoint` acquired various query utility methods. * The `{set_}remote()` methods now take/produce `Endpoint`s. * `TlsBindable` only accepts single-phase internal interfaces. * Bind error messages include candidate endpoint info when possible. * The warning message when a secret key is not configured now includes information about its effect on private cookies. Internal changes include: * Config module tests were moved to `config/tests.rs`. * The cancellable I/O implementation was significantly simplified. * The `TripWire` implementation was simplified. * Individual shutdown stages can now be awaited on via `Stages`. * The `Shield` implementation was simplified. Resolves #2723.
2024-03-19 03:19:00 +00:00
.merge(("port", 0))
.merge(("databases", map!["test" => &options]));
rocket::custom(config).attach(Pool::fairing())
}
#[test]
fn test_shutdown() {
let _rocket = async_test(
async {
let rocket = rocket().await.ignite().await.expect("unable to ignite");
// request shutdown
rocket.shutdown().notify();
rocket.launch().await.expect("unable to launch")
}
);
// _rocket is dropped here after the runtime is dropped
}
}