diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-10-23 15:59:04 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-10-24 11:35:07 +0200 |
| commit | cec5f59720e6c29468ddaeb9b61b4f166fbdd6f2 (patch) | |
| tree | 9c3f80b202339c396fbf8d5b87660f05c1cc962c | |
| parent | 71fff416c4151dde2476a72f94fc59cb3f1af6f6 (diff) | |
| download | mullvadvpn-cec5f59720e6c29468ddaeb9b61b4f166fbdd6f2.tar.xz mullvadvpn-cec5f59720e6c29468ddaeb9b61b4f166fbdd6f2.zip | |
Refactor move `reboot` to `helpers.rs`
| -rw-r--r-- | test/test-manager/src/tests/helpers.rs | 16 | ||||
| -rw-r--r-- | test/test-manager/src/tests/tunnel.rs | 17 |
2 files changed, 18 insertions, 15 deletions
diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs index f73e6f6e79..e5f8c6034e 100644 --- a/test/test-manager/src/tests/helpers.rs +++ b/test/test-manager/src/tests/helpers.rs @@ -33,6 +33,22 @@ pub fn get_package_desc(name: &str) -> Result<Package, Error> { }) } +/// Reboot the guest virtual machine. +/// +/// # macOS +/// The tunnel must be reconfigured after the virtual machine is up, +/// or macOS refuses to assign an IP. The reasons for this are poorly understood. +pub async fn reboot(rpc: &mut ServiceClient) -> Result<(), Error> { + rpc.reboot().await?; + + #[cfg(target_os = "macos")] + crate::vm::network::macos::configure_tunnel() + .await + .map_err(|error| Error::Other(format!("Failed to recreate custom wg tun: {error}")))?; + + Ok(()) +} + #[derive(Debug, Default)] pub struct ProbeResult { tcp: usize, diff --git a/test/test-manager/src/tests/tunnel.rs b/test/test-manager/src/tests/tunnel.rs index 9edc2414a8..20fc1e076b 100644 --- a/test/test-manager/src/tests/tunnel.rs +++ b/test/test-manager/src/tests/tunnel.rs @@ -397,7 +397,7 @@ pub async fn test_wireguard_autoconnect( .await .expect("failed to enable auto-connect"); - reboot(&mut rpc).await?; + helpers::reboot(&mut rpc).await?; rpc.mullvad_daemon_wait_for_state(|state| state == ServiceStatus::Running) .await?; @@ -439,7 +439,7 @@ pub async fn test_openvpn_autoconnect( .await .expect("failed to enable auto-connect"); - reboot(&mut rpc).await?; + helpers::reboot(&mut rpc).await?; rpc.mullvad_daemon_wait_for_state(|state| state == ServiceStatus::Running) .await?; @@ -453,19 +453,6 @@ pub async fn test_openvpn_autoconnect( Ok(()) } -async fn reboot(rpc: &mut ServiceClient) -> Result<(), Error> { - rpc.reboot().await?; - - // The tunnel must be reconfigured after the virtual machine is up, - // or macOS refuses to assign an IP. The reasons for this are poorly understood. - #[cfg(target_os = "macos")] - crate::vm::network::macos::configure_tunnel() - .await - .map_err(|error| Error::Other(format!("Failed to recreate custom wg tun: {error}")))?; - - Ok(()) -} - /// Test whether quantum-resistant tunnels can be set up. /// /// # Limitations |
