Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wonky timeouts in test_split_tunnel #6005

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions test/test-manager/src/tests/split_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ const CHECKER_FILENAME_WINDOWS: &str = "connection-checker.exe";
const CHECKER_FILENAME_UNIX: &str = "connection-checker";
const LEAK_DESTINATION: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 1337);

const AM_I_MULLVAD_TIMEOUT_MS: u64 = 10000;
const LEAK_TIMEOUT_MS: u64 = 500;

/// Timeout of [ConnCheckerHandle::check_connection].
const CONN_CHECKER_TIMEOUT: Duration = Duration::from_millis(
AM_I_MULLVAD_TIMEOUT_MS // https://am.i.mullvad.net timeout
+ LEAK_TIMEOUT_MS // leak-tcp timeout
+ LEAK_TIMEOUT_MS // leak-icmp timeout
+ 1000, // plus some extra grace time
);

/// Test that split tunneling works by asserting the following:
/// - Splitting a process shouldn't do anything if tunnel is not connected.
/// - A split process should never push traffic through the tunnel.
Expand Down Expand Up @@ -146,12 +157,12 @@ impl ConnChecker {
args: [
"--interactive",
"--timeout",
"10000",
&AM_I_MULLVAD_TIMEOUT_MS.to_string(),
// try to leak traffic to LEAK_DESTINATION
"--leak",
&LEAK_DESTINATION.to_string(),
"--leak-timeout",
"500",
&LEAK_TIMEOUT_MS.to_string(),
"--leak-tcp",
"--leak-udp",
"--leak-icmp",
Expand Down Expand Up @@ -300,7 +311,7 @@ impl ConnCheckerHandle<'_> {
/// Try to a single line of output from the spawned process
async fn read_stdout_line(&mut self) -> anyhow::Result<String> {
// Add a timeout to avoid waiting forever.
timeout(Duration::from_secs(8), async {
timeout(CONN_CHECKER_TIMEOUT, async {
let mut line = String::new();

// tarpc doesn't support streams, so we poll the checker process in a loop instead
Expand Down
Loading