Check test server availability before using it

This commit is contained in:
Nikolay Kim 2025-03-14 12:39:39 +05:00
parent 493713bbf4
commit 0ae70f01fe
12 changed files with 39 additions and 106 deletions

View file

@ -52,17 +52,17 @@ jobs:
- name: Run tests (compio) - name: Run tests (compio)
timeout-minutes: 40 timeout-minutes: 40
run: | run: |
RUST_LOG=trace cargo test --all --no-default-features --features="ntex/compio,ntex/cookie,ntex/url,ntex/compress,ntex/openssl,ntex/rustls,ntex/ws,ntex/brotli" cargo test --all --no-default-features --features="ntex/compio,ntex/cookie,ntex/url,ntex/compress,ntex/openssl,ntex/rustls,ntex/ws,ntex/brotli"
- name: Run tests (neon) - name: Run tests (neon)
timeout-minutes: 40 timeout-minutes: 40
run: | run: |
RUST_LOG=trace cargo test --all --no-default-features --features="ntex/neon,ntex/cookie,ntex/url,ntex/compress,ntex/openssl,ntex/rustls,ntex/ws,ntex/brotli" cargo test --all --no-default-features --features="ntex/neon,ntex/cookie,ntex/url,ntex/compress,ntex/openssl,ntex/rustls,ntex/ws,ntex/brotli"
- name: Run tests (neon-uring) - name: Run tests (neon-uring)
timeout-minutes: 40 timeout-minutes: 40
run: | run: |
RUST_LOG=trace cargo test --all --no-default-features --features="ntex/neon-uring,ntex/cookie,ntex/url,ntex/compress,ntex/openssl,ntex/rustls,ntex/ws,ntex/brotli" cargo test --all --no-default-features --features="ntex/neon-uring,ntex/cookie,ntex/url,ntex/compress,ntex/openssl,ntex/rustls,ntex/ws,ntex/brotli"
- name: Install cargo-cache - name: Install cargo-cache
continue-on-error: true continue-on-error: true

View file

@ -1,5 +1,9 @@
# Changes # Changes
## [0.1.4] - 2025-03-14
* Enable env_logger for test macro
## [0.1.2] - 2021-02-25 ## [0.1.2] - 2021-02-25
* Export runtime from ntex crate * Export runtime from ntex crate

View file

@ -1,6 +1,6 @@
[package] [package]
name = "ntex-macros" name = "ntex-macros"
version = "0.1.3" version = "0.1.4"
description = "ntex proc macros" description = "ntex proc macros"
readme = "README.md" readme = "README.md"
authors = ["ntex contributors <team@ntex.rs>"] authors = ["ntex contributors <team@ntex.rs>"]

View file

@ -262,6 +262,7 @@ pub fn rt_test(_: TokenStream, item: TokenStream) -> TokenStream {
quote! { quote! {
#(#attrs)* #(#attrs)*
fn #name() #ret { fn #name() #ret {
ntex::util::enable_test_logging();
ntex::rt::System::new("test") ntex::rt::System::new("test")
.block_on(async { #body }) .block_on(async { #body })
} }
@ -271,6 +272,7 @@ pub fn rt_test(_: TokenStream, item: TokenStream) -> TokenStream {
#[test] #[test]
#(#attrs)* #(#attrs)*
fn #name() #ret { fn #name() #ret {
ntex::util::enable_test_logging();
ntex::rt::System::new("test") ntex::rt::System::new("test")
.block_on(async { #body }) .block_on(async { #body })
} }

View file

@ -67,6 +67,11 @@ where
let (system, addr, server) = rx.recv().unwrap(); let (system, addr, server) = rx.recv().unwrap();
// wait for server
while net::TcpStream::connect(addr).is_err() {
thread::sleep(std::time::Duration::from_millis(25));
}
TestServer { TestServer {
addr, addr,
server, server,

View file

@ -4,6 +4,8 @@
* Add neon runtime support * Add neon runtime support
* Check test server availability before using it
* Drop glommio support * Drop glommio support
* Drop async-std support * Drop async-std support

View file

@ -83,6 +83,7 @@ pin-project-lite = "0.2"
regex = { version = "1.11", default-features = false, features = ["std"] } regex = { version = "1.11", default-features = false, features = ["std"] }
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
sha-1 = { version = "0.10", optional = true } sha-1 = { version = "0.10", optional = true }
env_logger = { version = "0.11", default-features = false }
thiserror = "1" thiserror = "1"
nanorand = { version = "0.7", default-features = false, features = [ nanorand = { version = "0.7", default-features = false, features = [
"std", "std",
@ -112,7 +113,6 @@ brotli2 = { version = "0.3.2", optional = true }
flate2 = { version = "1.0", optional = true } flate2 = { version = "1.0", optional = true }
[dev-dependencies] [dev-dependencies]
env_logger = "0.11"
rand = "0.8" rand = "0.8"
time = "0.3" time = "0.3"
futures-util = "0.3" futures-util = "0.3"

View file

@ -251,6 +251,11 @@ where
let (system, server, addr) = rx.recv().unwrap(); let (system, server, addr) = rx.recv().unwrap();
// wait for server
while net::TcpStream::connect(addr).is_err() {
thread::sleep(std::time::Duration::from_millis(25));
}
TestServer { TestServer {
addr, addr,
system, system,

View file

@ -123,4 +123,14 @@ pub mod util {
#[doc(hidden)] #[doc(hidden)]
#[deprecated] #[deprecated]
pub use std::task::ready; pub use std::task::ready;
#[doc(hidden)]
pub fn enable_test_logging() {
if std::env::var("NTEX_NO_TEST_LOG").is_err() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "trace");
}
let _ = env_logger::builder().is_test(true).try_init();
}
}
} }

View file

@ -704,6 +704,11 @@ where
let (system, server, addr) = rx.recv().unwrap(); let (system, server, addr) = rx.recv().unwrap();
// wait for server
while net::TcpStream::connect(addr).is_err() {
thread::sleep(std::time::Duration::from_millis(25));
}
let client = { let client = {
let connector = { let connector = {
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]

View file

@ -1,5 +1,5 @@
#![cfg(feature = "openssl")] #![cfg(feature = "openssl")]
use std::{io, sync::atomic::AtomicUsize, sync::atomic::Ordering, sync::Arc}; use std::{env, io, sync::atomic::AtomicUsize, sync::atomic::Ordering, sync::Arc};
use futures_util::stream::{once, Stream, StreamExt}; use futures_util::stream::{once, Stream, StreamExt};
use tls_openssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod}; use tls_openssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
@ -58,8 +58,6 @@ fn ssl_acceptor() -> SslAcceptor {
#[ntex::test] #[ntex::test]
async fn test_h2() -> io::Result<()> { async fn test_h2() -> io::Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test_server(move || { let srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| Ready::Ok::<_, io::Error>(Response::Ok().finish())) .h2(|_| Ready::Ok::<_, io::Error>(Response::Ok().finish()))
@ -74,8 +72,6 @@ async fn test_h2() -> io::Result<()> {
#[ntex::test] #[ntex::test]
async fn test_h1() -> io::Result<()> { async fn test_h1() -> io::Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test_server(move || { let srv = test_server(move || {
let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
builder builder
@ -98,8 +94,6 @@ async fn test_h1() -> io::Result<()> {
#[ntex::test] #[ntex::test]
async fn test_h2_1() -> io::Result<()> { async fn test_h2_1() -> io::Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test_server(move || { let srv = test_server(move || {
HttpService::build() HttpService::build()
.finish(|req: Request| { .finish(|req: Request| {
@ -118,8 +112,6 @@ async fn test_h2_1() -> io::Result<()> {
#[ntex::test] #[ntex::test]
async fn test_h2_body() -> io::Result<()> { async fn test_h2_body() -> io::Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let data = "HELLOWORLD".to_owned().repeat(64 * 1024); let data = "HELLOWORLD".to_owned().repeat(64 * 1024);
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
@ -147,8 +139,6 @@ async fn test_h2_body() -> io::Result<()> {
#[ntex::test] #[ntex::test]
async fn test_h2_content_length() { async fn test_h2_content_length() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test_server(move || { let srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|req: Request| async move { .h2(|req: Request| async move {
@ -192,8 +182,6 @@ async fn test_h2_content_length() {
#[ntex::test] #[ntex::test]
async fn test_h2_headers() { async fn test_h2_headers() {
let _ = env_logger::builder().is_test(true).try_init();
let data = STR.repeat(10); let data = STR.repeat(10);
let data2 = data.clone(); let data2 = data.clone();
@ -257,8 +245,6 @@ const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
#[ntex::test] #[ntex::test]
async fn test_h2_body2() { async fn test_h2_body2() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| async { Ok::<_, io::Error>(Response::Ok().body(STR)) }) .h2(|_| async { Ok::<_, io::Error>(Response::Ok().body(STR)) })
@ -276,8 +262,6 @@ async fn test_h2_body2() {
#[ntex::test] #[ntex::test]
async fn test_h2_head_empty() { async fn test_h2_head_empty() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.finish(|_| async { Ok::<_, io::Error>(Response::Ok().body(STR)) }) .finish(|_| async { Ok::<_, io::Error>(Response::Ok().body(STR)) })
@ -301,8 +285,6 @@ async fn test_h2_head_empty() {
#[ntex::test] #[ntex::test]
async fn test_h2_head_binary() { async fn test_h2_head_binary() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| async { .h2(|_| async {
@ -330,8 +312,6 @@ async fn test_h2_head_binary() {
/// Server must send content-length, but no payload /// Server must send content-length, but no payload
#[ntex::test] #[ntex::test]
async fn test_h2_head_binary2() { async fn test_h2_head_binary2() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test_server(move || { let srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| async { Ok::<_, io::Error>(Response::Ok().body(STR)) }) .h2(|_| async { Ok::<_, io::Error>(Response::Ok().body(STR)) })
@ -350,8 +330,6 @@ async fn test_h2_head_binary2() {
#[ntex::test] #[ntex::test]
async fn test_h2_body_length() { async fn test_h2_body_length() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| async { .h2(|_| async {
@ -374,8 +352,6 @@ async fn test_h2_body_length() {
#[ntex::test] #[ntex::test]
async fn test_h2_body_chunked_explicit() { async fn test_h2_body_chunked_explicit() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| { .h2(|_| {
@ -404,8 +380,6 @@ async fn test_h2_body_chunked_explicit() {
#[ntex::test] #[ntex::test]
async fn test_h2_response_http_error_handling() { async fn test_h2_response_http_error_handling() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(fn_service(|_| { .h2(fn_service(|_| {
@ -430,8 +404,6 @@ async fn test_h2_response_http_error_handling() {
#[ntex::test] #[ntex::test]
async fn test_h2_service_error() { async fn test_h2_service_error() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(move || { let mut srv = test_server(move || {
HttpService::build() HttpService::build()
.h2(|_| { .h2(|_| {
@ -462,8 +434,6 @@ impl Drop for SetOnDrop {
#[ntex::test] #[ntex::test]
async fn test_h2_client_drop() -> io::Result<()> { async fn test_h2_client_drop() -> io::Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let count = Arc::new(AtomicUsize::new(0)); let count = Arc::new(AtomicUsize::new(0));
let count2 = count.clone(); let count2 = count.clone();
@ -493,8 +463,6 @@ async fn test_h2_client_drop() -> io::Result<()> {
#[ntex::test] #[ntex::test]
async fn test_ssl_handshake_timeout() { async fn test_ssl_handshake_timeout() {
let _ = env_logger::builder().is_test(true).try_init();
use std::io::Read; use std::io::Read;
let srv = test_server(move || { let srv = test_server(move || {
@ -513,8 +481,6 @@ async fn test_ssl_handshake_timeout() {
#[ntex::test] #[ntex::test]
async fn test_ws_transport() { async fn test_ws_transport() {
let _ = env_logger::builder().is_test(true).try_init();
let mut srv = test_server(|| { let mut srv = test_server(|| {
HttpService::build() HttpService::build()
.h1_control(|req: h1::Control<_, _>| async move { .h1_control(|req: h1::Control<_, _>| async move {
@ -571,8 +537,6 @@ async fn test_ws_transport() {
#[ntex::test] #[ntex::test]
async fn test_h2_graceful_shutdown() -> io::Result<()> { async fn test_h2_graceful_shutdown() -> io::Result<()> {
let _ = env_logger::builder().is_test(true).try_init();
let count = Arc::new(AtomicUsize::new(0)); let count = Arc::new(AtomicUsize::new(0));
let count2 = count.clone(); let count2 = count.clone();

View file

@ -81,8 +81,6 @@ impl Stream for TestBody {
#[ntex::test] #[ntex::test]
async fn test_body() { async fn test_body() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server(|| { let srv = test::server(|| {
App::new().service( App::new().service(
web::resource("/").route(web::to(|| async { HttpResponse::Ok().body(STR) })), web::resource("/").route(web::to(|| async { HttpResponse::Ok().body(STR) })),
@ -99,8 +97,6 @@ async fn test_body() {
#[ntex::test] #[ntex::test]
async fn test_body_gzip() { async fn test_body_gzip() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.wrap(Compress::new(ContentEncoding::Gzip)) .wrap(Compress::new(ContentEncoding::Gzip))
@ -131,8 +127,6 @@ async fn test_body_gzip() {
#[ntex::test] #[ntex::test]
async fn test_body_gzip2() { async fn test_body_gzip2() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.wrap(Compress::new(ContentEncoding::Gzip)) .wrap(Compress::new(ContentEncoding::Gzip))
@ -162,8 +156,6 @@ async fn test_body_gzip2() {
#[ntex::test] #[ntex::test]
async fn test_body_encoding_override() { async fn test_body_encoding_override() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.wrap(Compress::new(ContentEncoding::Gzip)) .wrap(Compress::new(ContentEncoding::Gzip))
@ -223,8 +215,6 @@ async fn test_body_encoding_override() {
#[ntex::test] #[ntex::test]
async fn test_body_gzip_large() { async fn test_body_gzip_large() {
let _ = env_logger::builder().is_test(true).try_init();
let data = STR.repeat(10); let data = STR.repeat(10);
let srv_data = data.clone(); let srv_data = data.clone();
@ -258,8 +248,6 @@ async fn test_body_gzip_large() {
#[ntex::test] #[ntex::test]
async fn test_body_gzip_large_random() { async fn test_body_gzip_large_random() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(70_000) .take(70_000)
@ -298,8 +286,6 @@ async fn test_body_gzip_large_random() {
#[ntex::test] #[ntex::test]
async fn test_body_chunked_implicit() { async fn test_body_chunked_implicit() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.wrap(Compress::new(ContentEncoding::Gzip)) .wrap(Compress::new(ContentEncoding::Gzip))
@ -334,8 +320,6 @@ async fn test_body_chunked_implicit() {
#[ntex::test] #[ntex::test]
async fn test_body_br_streaming() { async fn test_body_br_streaming() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().wrap(Compress::new(ContentEncoding::Br)).service( App::new().wrap(Compress::new(ContentEncoding::Br)).service(
web::resource("/").route(web::to(move || async { web::resource("/").route(web::to(move || async {
@ -366,8 +350,6 @@ async fn test_body_br_streaming() {
#[ntex::test] #[ntex::test]
async fn test_head_binary() { async fn test_head_binary() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service( App::new().service(
web::resource("/") web::resource("/")
@ -392,8 +374,6 @@ async fn test_head_binary() {
#[ntex::test] #[ntex::test]
async fn test_no_chunking() { async fn test_no_chunking() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service(web::resource("/").route(web::to(move || async { App::new().service(web::resource("/").route(web::to(move || async {
HttpResponse::Ok() HttpResponse::Ok()
@ -414,8 +394,6 @@ async fn test_no_chunking() {
#[ntex::test] #[ntex::test]
async fn test_body_deflate() { async fn test_body_deflate() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.wrap(Compress::new(ContentEncoding::Deflate)) .wrap(Compress::new(ContentEncoding::Deflate))
@ -446,8 +424,6 @@ async fn test_body_deflate() {
#[ntex::test] #[ntex::test]
async fn test_body_brotli() { async fn test_body_brotli() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().wrap(Compress::new(ContentEncoding::Br)).service( App::new().wrap(Compress::new(ContentEncoding::Br)).service(
web::resource("/") web::resource("/")
@ -477,8 +453,6 @@ async fn test_body_brotli() {
#[ntex::test] #[ntex::test]
async fn test_encoding() { async fn test_encoding() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.wrap(Compress::default()) .wrap(Compress::default())
@ -506,8 +480,6 @@ async fn test_encoding() {
#[ntex::test] #[ntex::test]
async fn test_gzip_encoding() { async fn test_gzip_encoding() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
HttpResponse::Ok().body(body) HttpResponse::Ok().body(body)
@ -533,8 +505,6 @@ async fn test_gzip_encoding() {
#[ntex::test] #[ntex::test]
async fn test_gzip_encoding_large() { async fn test_gzip_encoding_large() {
let _ = env_logger::builder().is_test(true).try_init();
let data = STR.repeat(10); let data = STR.repeat(10);
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
@ -561,8 +531,6 @@ async fn test_gzip_encoding_large() {
#[ntex::test] #[ntex::test]
async fn test_reading_gzip_encoding_large_random() { async fn test_reading_gzip_encoding_large_random() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(60_000) .take(60_000)
@ -595,8 +563,6 @@ async fn test_reading_gzip_encoding_large_random() {
#[ntex::test] #[ntex::test]
async fn test_reading_deflate_encoding() { async fn test_reading_deflate_encoding() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
HttpResponse::Ok().body(body) HttpResponse::Ok().body(body)
@ -622,8 +588,6 @@ async fn test_reading_deflate_encoding() {
#[ntex::test] #[ntex::test]
async fn test_reading_deflate_encoding_large() { async fn test_reading_deflate_encoding_large() {
let _ = env_logger::builder().is_test(true).try_init();
let data = STR.repeat(10); let data = STR.repeat(10);
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
@ -650,8 +614,6 @@ async fn test_reading_deflate_encoding_large() {
#[ntex::test] #[ntex::test]
async fn test_reading_deflate_encoding_large_random() { async fn test_reading_deflate_encoding_large_random() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(160_000) .take(160_000)
@ -684,8 +646,6 @@ async fn test_reading_deflate_encoding_large_random() {
#[ntex::test] #[ntex::test]
async fn test_brotli_encoding() { async fn test_brotli_encoding() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new().service(web::resource("/").route(web::to(move |body: Bytes| async { App::new().service(web::resource("/").route(web::to(move |body: Bytes| async {
HttpResponse::Ok().body(body) HttpResponse::Ok().body(body)
@ -711,8 +671,6 @@ async fn test_brotli_encoding() {
#[ntex::test] #[ntex::test]
async fn test_brotli_encoding_large() { async fn test_brotli_encoding_large() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(320_000) .take(320_000)
@ -749,8 +707,6 @@ async fn test_brotli_encoding_large() {
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
#[ntex::test] #[ntex::test]
async fn test_brotli_encoding_large_openssl() { async fn test_brotli_encoding_large_openssl() {
let _ = env_logger::builder().is_test(true).try_init();
// load ssl keys // load ssl keys
use tls_openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; use tls_openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
@ -793,8 +749,6 @@ async fn test_brotli_encoding_large_openssl() {
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
#[ntex::test] #[ntex::test]
async fn test_brotli_encoding_large_openssl_h1() { async fn test_brotli_encoding_large_openssl_h1() {
let _ = env_logger::builder().is_test(true).try_init();
// load ssl keys // load ssl keys
use tls_openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; use tls_openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
@ -837,8 +791,6 @@ async fn test_brotli_encoding_large_openssl_h1() {
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
#[ntex::test] #[ntex::test]
async fn test_brotli_encoding_large_openssl_h2() { async fn test_brotli_encoding_large_openssl_h2() {
let _ = env_logger::builder().is_test(true).try_init();
// load ssl keys // load ssl keys
use tls_openssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod}; use tls_openssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
@ -893,8 +845,6 @@ async fn test_brotli_encoding_large_openssl_h2() {
#[cfg(all(feature = "rustls", feature = "openssl"))] #[cfg(all(feature = "rustls", feature = "openssl"))]
#[ntex::test] #[ntex::test]
async fn test_reading_deflate_encoding_large_random_rustls() { async fn test_reading_deflate_encoding_large_random_rustls() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(160_000) .take(160_000)
@ -934,8 +884,6 @@ async fn test_reading_deflate_encoding_large_random_rustls() {
#[cfg(all(feature = "rustls", feature = "openssl"))] #[cfg(all(feature = "rustls", feature = "openssl"))]
#[ntex::test] #[ntex::test]
async fn test_reading_deflate_encoding_large_random_rustls_h1() { async fn test_reading_deflate_encoding_large_random_rustls_h1() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(160_000) .take(160_000)
@ -977,8 +925,6 @@ async fn test_reading_deflate_encoding_large_random_rustls_h1() {
#[cfg(all(feature = "rustls", feature = "openssl"))] #[cfg(all(feature = "rustls", feature = "openssl"))]
#[ntex::test] #[ntex::test]
async fn test_reading_deflate_encoding_large_random_rustls_h2() { async fn test_reading_deflate_encoding_large_random_rustls_h2() {
let _ = env_logger::builder().is_test(true).try_init();
let data = rand::thread_rng() let data = rand::thread_rng()
.sample_iter(&Alphanumeric) .sample_iter(&Alphanumeric)
.take(160_000) .take(160_000)
@ -1019,8 +965,6 @@ async fn test_reading_deflate_encoding_large_random_rustls_h2() {
#[ntex::test] #[ntex::test]
async fn test_server_cookies() { async fn test_server_cookies() {
let _ = env_logger::builder().is_test(true).try_init();
use ntex::http::header::SET_COOKIE; use ntex::http::header::SET_COOKIE;
use ntex::http::HttpMessage; use ntex::http::HttpMessage;
@ -1068,8 +1012,6 @@ async fn test_server_cookies() {
#[ntex::test] #[ntex::test]
async fn test_slow_request() { async fn test_slow_request() {
let _ = env_logger::builder().is_test(true).try_init();
use std::net; use std::net;
let srv = test::server_with(test::config().client_timeout(Seconds(1)), || { let srv = test::server_with(test::config().client_timeout(Seconds(1)), || {
@ -1091,8 +1033,6 @@ async fn test_slow_request() {
#[ntex::test] #[ntex::test]
async fn test_custom_error() { async fn test_custom_error() {
let _ = env_logger::builder().is_test(true).try_init();
#[derive(Error, Debug)] #[derive(Error, Debug)]
#[error("TestError")] #[error("TestError")]
struct TestError; struct TestError;
@ -1163,8 +1103,6 @@ async fn test_custom_error() {
#[ntex::test] #[ntex::test]
async fn test_web_server() { async fn test_web_server() {
let _ = env_logger::builder().is_test(true).try_init();
let (tx, rx) = std::sync::mpsc::channel(); let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || { std::thread::spawn(move || {
@ -1207,8 +1145,6 @@ async fn test_web_server() {
/// Websocket connection, no ws handler and response contains payload /// Websocket connection, no ws handler and response contains payload
#[ntex::test] #[ntex::test]
async fn web_no_ws_with_response_payload() { async fn web_no_ws_with_response_payload() {
let _ = env_logger::builder().is_test(true).try_init();
let srv = test::server_with(test::config().h1(), || { let srv = test::server_with(test::config().h1(), || {
App::new() App::new()
.service(web::resource("/").route(web::get().to(move || async { .service(web::resource("/").route(web::get().to(move || async {