chore(tests): fix tokio runtime deprecations
This commit is contained in:
@@ -31,7 +31,7 @@ iovec = "0.1"
|
|||||||
log = "0.4"
|
log = "0.4"
|
||||||
net2 = "0.2.32"
|
net2 = "0.2.32"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
tokio = "0.1.3"
|
tokio = "0.1.5"
|
||||||
tokio-executor = "0.1.0"
|
tokio-executor = "0.1.0"
|
||||||
tokio-service = "0.1"
|
tokio-service = "0.1"
|
||||||
tokio-io = "0.1"
|
tokio-io = "0.1"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ fn get_one_at_a_time(b: &mut test::Bencher) {
|
|||||||
let addr = spawn_hello(&mut rt);
|
let addr = spawn_hello(&mut rt);
|
||||||
|
|
||||||
let client = hyper::Client::configure()
|
let client = hyper::Client::configure()
|
||||||
.build_with_executor(&rt.handle(), rt.executor());
|
.build_with_executor(&rt.reactor(), rt.executor());
|
||||||
|
|
||||||
let url: hyper::Uri = format!("http://{}/get", addr).parse().unwrap();
|
let url: hyper::Uri = format!("http://{}/get", addr).parse().unwrap();
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ fn post_one_at_a_time(b: &mut test::Bencher) {
|
|||||||
let addr = spawn_hello(&mut rt);
|
let addr = spawn_hello(&mut rt);
|
||||||
|
|
||||||
let client = hyper::Client::configure()
|
let client = hyper::Client::configure()
|
||||||
.build_with_executor(&rt.handle(), rt.executor());
|
.build_with_executor(&rt.reactor(), rt.executor());
|
||||||
|
|
||||||
let url: hyper::Uri = format!("http://{}/post", addr).parse().unwrap();
|
let url: hyper::Uri = format!("http://{}/post", addr).parse().unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ macro_rules! test {
|
|||||||
if !$set_host {
|
if !$set_host {
|
||||||
config = config.set_host(false);
|
config = config.set_host(false);
|
||||||
}
|
}
|
||||||
let client = config.build_with_executor(&runtime.handle(), runtime.executor());
|
let client = config.build_with_executor(&runtime.reactor(), runtime.executor());
|
||||||
|
|
||||||
let body = if let Some(body) = $request_body {
|
let body = if let Some(body) = $request_body {
|
||||||
let body: &'static str = body;
|
let body: &'static str = body;
|
||||||
@@ -665,7 +665,7 @@ mod dispatch_impl {
|
|||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
let client = Client::configure()
|
let client = Client::configure()
|
||||||
.connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &runtime.handle()), closes_tx))
|
.connector(DebugConnector::with_http_and_closes(HttpConnector::new(1, &runtime.reactor()), closes_tx))
|
||||||
.executor(runtime.executor());
|
.executor(runtime.executor());
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -705,7 +705,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -754,7 +754,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, mut closes) = mpsc::channel(10);
|
let (closes_tx, mut closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -818,7 +818,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -871,7 +871,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -925,7 +925,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -976,7 +976,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -1017,73 +1017,12 @@ mod dispatch_impl {
|
|||||||
let _ = t.select(close).wait();
|
let _ = t.select(close).wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn conn_drop_prevents_pool_checkout() {
|
|
||||||
// a drop might happen for any sort of reason, and we can protect
|
|
||||||
// against a lot of them, but if the `runtime` is dropped, we can't
|
|
||||||
// really catch that. So, this is case to always check.
|
|
||||||
//
|
|
||||||
// See https://github.com/hyperium/hyper/issues/1429
|
|
||||||
|
|
||||||
use std::error::Error;
|
|
||||||
let _ = pretty_env_logger::try_init();
|
|
||||||
|
|
||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
|
||||||
let addr = server.local_addr().unwrap();
|
|
||||||
let runtime = Runtime::new().unwrap();
|
|
||||||
let handle = runtime.handle().clone();
|
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
|
||||||
|
|
||||||
thread::spawn(move || {
|
|
||||||
let mut sock = server.accept().unwrap().0;
|
|
||||||
sock.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
|
|
||||||
sock.set_write_timeout(Some(Duration::from_secs(5))).unwrap();
|
|
||||||
let mut buf = [0; 4096];
|
|
||||||
sock.read(&mut buf).expect("read 1");
|
|
||||||
sock.write_all(b"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n").unwrap();
|
|
||||||
sock.read(&mut buf).expect("read 2");
|
|
||||||
let _ = tx1.send(());
|
|
||||||
});
|
|
||||||
|
|
||||||
let uri = format!("http://{}/a", addr).parse::<hyper::Uri>().unwrap();
|
|
||||||
|
|
||||||
let client = Client::configure().build_with_executor(&handle, runtime.executor());
|
|
||||||
|
|
||||||
let req = Request::builder()
|
|
||||||
.uri(uri.clone())
|
|
||||||
.body(Body::empty())
|
|
||||||
.unwrap();
|
|
||||||
let res = client.request(req).and_then(move |res| {
|
|
||||||
assert_eq!(res.status(), hyper::StatusCode::OK);
|
|
||||||
res.into_body().into_stream().concat2()
|
|
||||||
});
|
|
||||||
|
|
||||||
res.wait().unwrap();
|
|
||||||
|
|
||||||
// drop previous runtime
|
|
||||||
drop(runtime);
|
|
||||||
let timeout = Delay::new(Duration::from_millis(200));
|
|
||||||
let rx = rx1.map_err(|_| hyper::Error::Io(io::Error::new(io::ErrorKind::Other, "thread panicked")));
|
|
||||||
let rx = rx.and_then(move |_| timeout.map_err(|e| e.into()));
|
|
||||||
|
|
||||||
let req = Request::builder()
|
|
||||||
.uri(uri)
|
|
||||||
.body(Body::empty())
|
|
||||||
.unwrap();
|
|
||||||
let res = client.request(req);
|
|
||||||
// this does trigger an 'event loop gone' error, but before, it would
|
|
||||||
// panic internally on a `SendError`, which is what we're testing against.
|
|
||||||
let err = res.join(rx).map(|r| r.0).wait().unwrap_err();
|
|
||||||
assert_eq!(err.description(), "event loop gone");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn client_custom_executor() {
|
fn client_custom_executor() {
|
||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let (closes_tx, closes) = mpsc::channel(10);
|
let (closes_tx, closes) = mpsc::channel(10);
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -1134,7 +1073,7 @@ mod dispatch_impl {
|
|||||||
let _ = pretty_env_logger::try_init();
|
let _ = pretty_env_logger::try_init();
|
||||||
|
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let connector = DebugConnector::new(&handle);
|
let connector = DebugConnector::new(&handle);
|
||||||
let connects = connector.connects.clone();
|
let connects = connector.connects.clone();
|
||||||
|
|
||||||
@@ -1159,7 +1098,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let connector = DebugConnector::new(&handle);
|
let connector = DebugConnector::new(&handle);
|
||||||
let connects = connector.connects.clone();
|
let connects = connector.connects.clone();
|
||||||
|
|
||||||
@@ -1221,7 +1160,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
|
|
||||||
let connector = DebugConnector::new(&handle);
|
let connector = DebugConnector::new(&handle);
|
||||||
let connects = connector.connects.clone();
|
let connects = connector.connects.clone();
|
||||||
@@ -1283,7 +1222,7 @@ mod dispatch_impl {
|
|||||||
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
let server = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let addr = server.local_addr().unwrap();
|
let addr = server.local_addr().unwrap();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let handle = runtime.handle();
|
let handle = runtime.reactor();
|
||||||
let connector = DebugConnector::new(&handle)
|
let connector = DebugConnector::new(&handle)
|
||||||
.proxy();
|
.proxy();
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ fn get_with_body() {
|
|||||||
fn get_implicitly_empty() {
|
fn get_implicitly_empty() {
|
||||||
// See https://github.com/hyperium/hyper/issues/1373
|
// See https://github.com/hyperium/hyper/issues/1373
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -755,7 +755,7 @@ fn http_10_request_receives_http_10_response() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn disable_keep_alive_mid_request() {
|
fn disable_keep_alive_mid_request() {
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -800,7 +800,7 @@ fn disable_keep_alive_mid_request() {
|
|||||||
fn disable_keep_alive_post_request() {
|
fn disable_keep_alive_post_request() {
|
||||||
let _ = pretty_env_logger::try_init();
|
let _ = pretty_env_logger::try_init();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
let (tx1, rx1) = oneshot::channel();
|
let (tx1, rx1) = oneshot::channel();
|
||||||
@@ -871,7 +871,7 @@ fn disable_keep_alive_post_request() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn empty_parse_eof_does_not_return_error() {
|
fn empty_parse_eof_does_not_return_error() {
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -892,7 +892,7 @@ fn empty_parse_eof_does_not_return_error() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn nonempty_parse_eof_returns_error() {
|
fn nonempty_parse_eof_returns_error() {
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -915,7 +915,7 @@ fn nonempty_parse_eof_returns_error() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn returning_1xx_response_is_error() {
|
fn returning_1xx_response_is_error() {
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -951,7 +951,7 @@ fn upgrades() {
|
|||||||
use tokio_io::io::{read_to_end, write_all};
|
use tokio_io::io::{read_to_end, write_all};
|
||||||
let _ = pretty_env_logger::try_init();
|
let _ = pretty_env_logger::try_init();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
|
|
||||||
@@ -1016,7 +1016,7 @@ fn upgrades() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn parse_errors_send_4xx_response() {
|
fn parse_errors_send_4xx_response() {
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -1045,7 +1045,7 @@ fn parse_errors_send_4xx_response() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn illegal_request_length_returns_400_response() {
|
fn illegal_request_length_returns_400_response() {
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -1075,7 +1075,7 @@ fn illegal_request_length_returns_400_response() {
|
|||||||
fn max_buf_size() {
|
fn max_buf_size() {
|
||||||
let _ = pretty_env_logger::try_init();
|
let _ = pretty_env_logger::try_init();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
const MAX: usize = 16_000;
|
const MAX: usize = 16_000;
|
||||||
@@ -1109,7 +1109,7 @@ fn max_buf_size() {
|
|||||||
fn streaming_body() {
|
fn streaming_body() {
|
||||||
let _ = pretty_env_logger::try_init();
|
let _ = pretty_env_logger::try_init();
|
||||||
let runtime = Runtime::new().unwrap();
|
let runtime = Runtime::new().unwrap();
|
||||||
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.handle()).unwrap();
|
let listener = tcp_bind(&"127.0.0.1:0".parse().unwrap(), &runtime.reactor()).unwrap();
|
||||||
let addr = listener.local_addr().unwrap();
|
let addr = listener.local_addr().unwrap();
|
||||||
|
|
||||||
let (tx, rx) = oneshot::channel();
|
let (tx, rx) = oneshot::channel();
|
||||||
|
|||||||
Reference in New Issue
Block a user