Skip to content

Commit 2335076

Browse files
authored
outbound: more TCP tests, test cleanup (#711)
This branch adds two new TCP tests: one asserting that resolutions are cached across multiple connections with the same original destination IP, and one asserting that outbound TCP load balancing actually distributes load over multiple endpoints. In addition, I've done some more cleanup and refactoring of the new tests to reduce boilerplate, etc. This should make adding new tests in subsequent PRs easier. Signed-off-by: Eliza Weisman <[email protected]>
1 parent 7a03fc7 commit 2335076

File tree

10 files changed

+611
-207
lines changed

10 files changed

+611
-207
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ dependencies = [
931931
"tokio",
932932
"tower",
933933
"tracing",
934+
"tracing-futures",
934935
]
935936

936937
[[package]]

linkerd/app/outbound/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ features = [
3333
ipnet = "1.0"
3434
linkerd2-app-test = { path = "../test" }
3535
tokio = { version = "0.2", features = ["full", "macros"]}
36+
tracing-futures = "0.2"

linkerd/app/outbound/src/tests.rs

Lines changed: 0 additions & 189 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
use crate::{
2+
endpoint::{TcpConcrete, TcpLogical},
3+
Config,
4+
};
5+
use futures::prelude::*;
6+
use ipnet::IpNet;
7+
use linkerd2_app_core::{
8+
config, exp_backoff, profiles,
9+
proxy::http::h2,
10+
svc::NewService,
11+
transport::{listen, tls},
12+
Error, IpMatch,
13+
};
14+
use linkerd2_app_test as test_support;
15+
use std::{net::SocketAddr, str::FromStr, time::Duration};
16+
use tower::ServiceExt;
17+
18+
mod tcp;
19+
20+
const LOCALHOST: [u8; 4] = [127, 0, 0, 1];
21+
22+
fn profile() -> profiles::Receiver {
23+
let (mut tx, rx) = tokio::sync::watch::channel(profiles::Profile::default());
24+
tokio::spawn(async move { tx.closed().await });
25+
rx
26+
}
27+
28+
fn default_config(orig_dst: SocketAddr) -> Config {
29+
Config {
30+
allow_discovery: IpMatch::new(Some(IpNet::from_str("0.0.0.0/0").unwrap())),
31+
proxy: config::ProxyConfig {
32+
server: config::ServerConfig {
33+
bind: listen::Bind::new(SocketAddr::new(LOCALHOST.into(), 0), None)
34+
.with_orig_dst_addr(orig_dst.into()),
35+
h2_settings: h2::Settings::default(),
36+
},
37+
connect: config::ConnectConfig {
38+
keepalive: None,
39+
timeout: Duration::from_secs(1),
40+
backoff: exp_backoff::ExponentialBackoff::new(
41+
Duration::from_millis(100),
42+
Duration::from_millis(500),
43+
0.1,
44+
)
45+
.unwrap(),
46+
h2_settings: h2::Settings::default(),
47+
},
48+
buffer_capacity: 10_000,
49+
cache_max_idle_age: Duration::from_secs(60),
50+
dispatch_timeout: Duration::from_secs(3),
51+
max_in_flight_requests: 10_000,
52+
detect_protocol_timeout: Duration::from_secs(3),
53+
},
54+
}
55+
}

0 commit comments

Comments
 (0)