1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

fix awc tests

This commit is contained in:
Nikolay Kim 2019-12-20 17:27:32 +06:00
parent c877840c07
commit 74fa4060c2
3 changed files with 73 additions and 48 deletions

View File

@ -14,8 +14,8 @@ use rand::Rng;
use actix_http::HttpService;
use actix_http_test::test_server;
use actix_service::pipeline_factory;
use actix_web::dev::BodyEncoding;
use actix_service::{map_config, pipeline_factory, IntoServiceFactory};
use actix_web::dev::{AppConfig, BodyEncoding};
use actix_web::http::Cookie;
use actix_web::middleware::Compress;
use actix_web::{
@ -170,10 +170,12 @@ async fn test_connection_reuse() {
ok(io)
})
.and_then(
HttpService::new(
HttpService::new(map_config(
App::new()
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
)
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
.into_factory(),
|_| AppConfig::default(),
))
.tcp(),
)
});
@ -206,10 +208,12 @@ async fn test_connection_force_close() {
ok(io)
})
.and_then(
HttpService::new(
HttpService::new(map_config(
App::new()
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))),
)
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
.into_factory(),
|_| AppConfig::default(),
))
.tcp(),
)
});
@ -235,19 +239,22 @@ async fn test_connection_server_close() {
let num = Arc::new(AtomicUsize::new(0));
let num2 = num.clone();
let srv = test_server(move || {
let srv =
test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
.and_then(
HttpService::new(
App::new().service(
web::resource("/")
.route(web::to(|| HttpResponse::Ok().force_close().finish())),
),
)
HttpService::new(map_config(
App::new()
.service(web::resource("/").route(web::to(|| {
HttpResponse::Ok().force_close().finish()
})))
.into_factory(),
|_| AppConfig::default(),
))
.tcp(),
)
});
@ -280,8 +287,14 @@ async fn test_connection_wait_queue() {
ok(io)
})
.and_then(
HttpService::new(App::new().service(
web::resource("/").route(web::to(|| HttpResponse::Ok().body(STR))),
HttpService::new(map_config(
App::new()
.service(
web::resource("/")
.route(web::to(|| HttpResponse::Ok().body(STR))),
)
.into_factory(),
|_| AppConfig::default(),
))
.tcp(),
)
@ -317,19 +330,22 @@ async fn test_connection_wait_queue_force_close() {
let num = Arc::new(AtomicUsize::new(0));
let num2 = num.clone();
let srv = test_server(move || {
let srv =
test_server(move || {
let num2 = num2.clone();
pipeline_factory(move |io| {
num2.fetch_add(1, Ordering::Relaxed);
ok(io)
})
.and_then(
HttpService::new(
App::new().service(
web::resource("/")
.route(web::to(|| HttpResponse::Ok().force_close().body(STR))),
),
)
HttpService::new(map_config(
App::new()
.service(web::resource("/").route(web::to(|| {
HttpResponse::Ok().force_close().body(STR)
})))
.into_factory(),
|_| AppConfig::default(),
))
.tcp(),
)
});

View File

@ -4,9 +4,9 @@ use std::sync::Arc;
use actix_http::HttpService;
use actix_http_test::test_server;
use actix_service::{pipeline_factory, ServiceFactory};
use actix_service::{map_config, pipeline_factory, ServiceFactory, IntoServiceFactory};
use actix_web::http::Version;
use actix_web::{web, App, HttpResponse};
use actix_web::{web, App, HttpResponse, dev::AppConfig};
use futures::future::ok;
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod, SslVerifyMode};
use rust_tls::ClientConfig;
@ -62,8 +62,11 @@ async fn _test_connection_reuse_h2() {
})
.and_then(
HttpService::build()
.h2(App::new()
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))))
.h2(map_config(App::new()
.service(web::resource("/").route(web::to(|| HttpResponse::Ok())))
.into_factory(),
|_| AppConfig::default(),
))
.openssl(ssl_acceptor())
.map_err(|_| ()),
)

View File

@ -4,9 +4,9 @@ use std::sync::Arc;
use actix_http::HttpService;
use actix_http_test::test_server;
use actix_service::{pipeline_factory, ServiceFactory};
use actix_service::{map_config, pipeline_factory, IntoServiceFactory, ServiceFactory};
use actix_web::http::Version;
use actix_web::{web, App, HttpResponse};
use actix_web::{dev::AppConfig, web, App, HttpResponse};
use futures::future::ok;
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
@ -44,8 +44,14 @@ async fn test_connection_reuse_h2() {
})
.and_then(
HttpService::build()
.h2(App::new()
.service(web::resource("/").route(web::to(|| HttpResponse::Ok()))))
.h2(map_config(
App::new()
.service(
web::resource("/").route(web::to(|| HttpResponse::Ok())),
)
.into_factory(),
|_| AppConfig::default(),
))
.openssl(ssl_acceptor())
.map_err(|_| ()),
)