Skip to content

Commit

Permalink
Merge branch 'mtu-detection-tests-nft' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Mar 8, 2024
2 parents cd5f335 + 301a123 commit 9c035ee
Show file tree
Hide file tree
Showing 12 changed files with 367 additions and 143 deletions.
77 changes: 72 additions & 5 deletions test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ rust-version = "1.75.0"

[workspace]
resolver = "2"
members = [
"test-manager",
"test-runner",
"test-rpc",
"socks-server",
]
members = ["test-manager", "test-runner", "test-rpc", "socks-server"]

[workspace.lints.rust]
rust_2018_idioms = "deny"
Expand All @@ -22,7 +17,15 @@ unused_async = "deny"

[workspace.dependencies]
futures = "0.3"
tokio = { version = "1.8", features = ["macros", "rt", "process", "time", "fs", "io-util", "rt-multi-thread"] }
tokio = { version = "1.8", features = [
"macros",
"rt",
"process",
"time",
"fs",
"io-util",
"rt-multi-thread",
] }
tokio-serial = "5.4.1"
# Serde and related crates
serde = "1.0"
Expand All @@ -46,8 +49,9 @@ shadowsocks-service = { version = "1.16" }

windows-sys = "0.48.0"

chrono = { version = "0.4.26", default-features = false}
chrono = { version = "0.4.26", default-features = false }
clap = { version = "4.2.7", features = ["cargo", "derive"] }
once_cell = "1.16.0"
bytes = "1.3.0"
async-trait = "0.1.58"
surge-ping = "0.8"
1 change: 1 addition & 0 deletions test/test-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async-tempfile = "0.2"
async-trait = { workspace = true }
uuid = "1.3"
dirs = "5.0.1"
scopeguard = "1.2"

serde = { workspace = true }
serde_json = { workspace = true }
Expand Down
24 changes: 18 additions & 6 deletions test/test-manager/src/tests/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{config::TEST_CONFIG, Error, PING_TIMEOUT, WAIT_FOR_TUNNEL_STATE_TIMEOUT};
use super::{config::TEST_CONFIG, Error, WAIT_FOR_TUNNEL_STATE_TIMEOUT};
use crate::network_monitor::{
self, start_packet_monitor, MonitorOptions, MonitorUnexpectedlyStopped, PacketMonitor,
};
Expand All @@ -21,7 +21,6 @@ use std::{
};
use talpid_types::net::wireguard::{PeerConfig, PrivateKey, TunnelConfig};
use test_rpc::{package::Package, AmIMullvad, ServiceClient};
use tokio::time::timeout;

#[macro_export]
macro_rules! assert_tunnel_state {
Expand Down Expand Up @@ -182,9 +181,21 @@ pub async fn ping_with_timeout(
dest: IpAddr,
interface: Option<String>,
) -> Result<(), Error> {
timeout(PING_TIMEOUT, rpc.send_ping(interface, dest))
const DEFAULT_PING_SIZE: usize = 64;

rpc.send_ping(dest, interface, DEFAULT_PING_SIZE)
.await
.map_err(Error::Rpc)
}

pub async fn ping_sized_with_timeout(
rpc: &ServiceClient,
dest: IpAddr,
interface: Option<String>,
size: usize,
) -> Result<(), Error> {
rpc.send_ping(dest, interface, size)
.await
.map_err(|_| Error::PingTimeout)?
.map_err(Error::Rpc)
}

Expand Down Expand Up @@ -506,8 +517,9 @@ impl Pinger {
log::debug!("Monitoring outgoing traffic");
let monitor = start_packet_monitor(
move |packet| {
// NOTE: Many packets will likely be observed for API traffic. Rather than filtering all
// of those specifically, simply fail if our probes are observed.
// NOTE: Many packets will likely be observed for API traffic. Rather than filtering
// all of those specifically, simply fail if our probes are
// observed.
packet.source.ip() == guest_ip
&& packet.destination.ip() == builder.destination.ip()
},
Expand Down
4 changes: 0 additions & 4 deletions test/test-manager/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use futures::future::BoxFuture;
use mullvad_management_interface::MullvadProxyClient;
use std::time::Duration;

const PING_TIMEOUT: Duration = Duration::from_secs(3);
const WAIT_FOR_TUNNEL_STATE_TIMEOUT: Duration = Duration::from_secs(40);

#[derive(Clone)]
Expand All @@ -42,9 +41,6 @@ pub enum Error {
#[error("RPC call failed")]
Rpc(#[from] test_rpc::Error),

#[error("Timeout waiting for ping")]
PingTimeout,

#[error("geoip lookup failed")]
GeoipLookup(test_rpc::Error),

Expand Down
Loading

0 comments on commit 9c035ee

Please sign in to comment.