diff --git a/test/test-manager/src/main.rs b/test/test-manager/src/main.rs index 973a1aec06f2..b72ae6a495cc 100644 --- a/test/test-manager/src/main.rs +++ b/test/test-manager/src/main.rs @@ -295,6 +295,7 @@ async fn main() -> Result<()> { .await .context("Failed to run provisioning for VM")?; + let bridge_ip = instance.get_ip().to_owned(); TEST_CONFIG.init(tests::config::TestConfig::new( account, artifacts_dir, @@ -311,7 +312,11 @@ async fn main() -> Result<()> { .gui_package_path .map(|path| path.file_name().unwrap().to_string_lossy().into_owned()), mullvad_host, - vm::network::bridge()?, + vm::network::bridge( + #[cfg(target_os = "macos")] + &bridge_ip, + )?, + bridge_ip, test_rpc::meta::Os::from(vm_config.os_type), openvpn_certificate, )); diff --git a/test/test-manager/src/tests/config.rs b/test/test-manager/src/tests/config.rs index 04b2e01e71b1..e25e60db33b2 100644 --- a/test/test-manager/src/tests/config.rs +++ b/test/test-manager/src/tests/config.rs @@ -1,3 +1,4 @@ +use std::net::IpAddr; use std::sync::OnceLock; use std::{ops::Deref, path::Path}; use test_rpc::meta::Os; @@ -35,7 +36,7 @@ pub struct TestConfig { pub mullvad_host: String, pub host_bridge_name: String, - + pub host_bridge_ip: IpAddr, pub os: Os, /// The OpenVPN CA certificate to use with the the installed Mullvad App. pub openvpn_certificate: OpenVPNCertificate, @@ -52,6 +53,7 @@ impl TestConfig { ui_e2e_tests_filename: Option, mullvad_host: String, host_bridge_name: String, + host_bridge_ip: IpAddr, os: Os, openvpn_certificate: OpenVPNCertificate, ) -> Self { @@ -63,6 +65,7 @@ impl TestConfig { ui_e2e_tests_filename, mullvad_host, host_bridge_name, + host_bridge_ip, os, openvpn_certificate, } diff --git a/test/test-manager/src/vm/network/macos.rs b/test/test-manager/src/vm/network/macos.rs index 35467144ec1c..0e52a33caa5d 100644 --- a/test/test-manager/src/vm/network/macos.rs +++ b/test/test-manager/src/vm/network/macos.rs @@ -53,14 +53,14 @@ pub async fn setup_test_network() -> Result<()> { /// A hack to find the Tart bridge interface using `NON_TUN_GATEWAY`. /// It should be possible to retrieve this using the virtualization framework instead, /// but that requires an entitlement. -pub(crate) fn find_vm_bridge() -> Result { +pub(crate) fn find_vm_bridge(bridge_ip: &IpAddr) -> Result { for addr in nix::ifaddrs::getifaddrs().unwrap() { if !addr.interface_name.starts_with("bridge") { continue; } if let Some(address) = addr.address.as_ref().and_then(|addr| addr.as_sockaddr_in()) { - let interface_ip = *SocketAddrV4::from(*address).ip(); - if interface_ip == NON_TUN_GATEWAY { + let interface_ip = SocketAddrV4::from(*address).ip(); + if interface_ip == bridge_ip { return Ok(addr.interface_name.to_owned()); } } diff --git a/test/test-manager/src/vm/network/mod.rs b/test/test-manager/src/vm/network/mod.rs index a06227027b9d..5a72264b4567 100644 --- a/test/test-manager/src/vm/network/mod.rs +++ b/test/test-manager/src/vm/network/mod.rs @@ -1,5 +1,8 @@ // #[cfg(target_os = "linux")] pub mod linux; +#[cfg(target_os = "macos")] +use std::net::IpAddr; + #[cfg(target_os = "linux")] pub use linux as platform; @@ -19,10 +22,10 @@ pub use platform::{ pub const SOCKS5_PORT: u16 = 54321; /// Get the name of the bridge interface between the test-manager and the test-runner. -pub fn bridge() -> anyhow::Result { +pub fn bridge(#[cfg(target_os = "macos")] bridge_ip: &IpAddr) -> anyhow::Result { #[cfg(target_os = "macos")] { - crate::vm::network::macos::find_vm_bridge() + crate::vm::network::macos::find_vm_bridge(bridge_ip) } #[cfg(not(target_os = "macos"))] Ok(platform::BRIDGE_NAME.to_owned())