summaryrefslogtreecommitdiffhomepage
path: root/test/test-manager/src
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2023-12-05 09:36:55 +0100
committerMarkus Pettersson <markus.pettersson@mullvad.net>2023-12-06 14:37:24 +0100
commit07dedbcf0247a9a1c0d91aebd765ae6a0c77155f (patch)
tree3283ea38e40db031b9f6fcb6e6f144e8d9c91e5b /test/test-manager/src
parent44a478e71ff0ed02a18c824fe0b0243398310d6b (diff)
downloadmullvadvpn-07dedbcf0247a9a1c0d91aebd765ae6a0c77155f.tar.xz
mullvadvpn-07dedbcf0247a9a1c0d91aebd765ae6a0c77155f.zip
Remove superseded RPC for restarting the Mullvad system service
The function `set_mullvad_daemon_service_state(on: bool) -> Result<(), test_rpc::Error>`, which would conditionally start or stop the Mullvad daemon in the test runner, has been superseded by two separate functions which accomplish the same thing: `start_mullvad_daemon` & `stop_mullvad_daemon`.
Diffstat (limited to 'test/test-manager/src')
-rw-r--r--test/test-manager/src/tests/account.rs4
-rw-r--r--test/test-manager/src/tests/tunnel_state.rs55
2 files changed, 22 insertions, 37 deletions
diff --git a/test/test-manager/src/tests/account.rs b/test/test-manager/src/tests/account.rs
index 92c95346b2..78eb42adc4 100644
--- a/test/test-manager/src/tests/account.rs
+++ b/test/test-manager/src/tests/account.rs
@@ -324,7 +324,7 @@ pub async fn test_automatic_wireguard_rotation(
.pubkey;
// Stop daemon
- rpc.set_mullvad_daemon_service_state(false)
+ rpc.stop_mullvad_daemon()
.await
.expect("Could not stop system service");
@@ -334,7 +334,7 @@ pub async fn test_automatic_wireguard_rotation(
.expect("Could not change device.json to have an old created timestamp");
// Start daemon
- rpc.set_mullvad_daemon_service_state(true)
+ rpc.start_mullvad_daemon()
.await
.expect("Could not start system service");
diff --git a/test/test-manager/src/tests/tunnel_state.rs b/test/test-manager/src/tests/tunnel_state.rs
index 90a5086863..9ae817c7ee 100644
--- a/test/test-manager/src/tests/tunnel_state.rs
+++ b/test/test-manager/src/tests/tunnel_state.rs
@@ -1,6 +1,6 @@
use super::helpers::{
- self, connect_and_wait, disconnect_and_wait, get_tunnel_state, send_guest_probes,
- set_relay_settings, unreachable_wireguard_tunnel, wait_for_tunnel_state,
+ self, connect_and_wait, get_tunnel_state, send_guest_probes, set_relay_settings,
+ unreachable_wireguard_tunnel, wait_for_tunnel_state,
};
use super::{ui, Error, TestContext};
use crate::assert_tunnel_state;
@@ -342,18 +342,18 @@ pub async fn test_connected_state(
pub async fn test_connecting_state_when_corrupted_state_cache(
_: TestContext,
rpc: ServiceClient,
- mut mullvad_client: ManagementServiceClient,
+ mullvad_client: ManagementServiceClient,
) -> Result<(), Error> {
- // Enter the disconnected state. Normally this would be preserved when
- // restarting the app, i.e. the user would still be disconnected after a
- // successfull restart. However, as we will intentionally corrupt the state
- // target cache the user should end up in the connecting/connected state,
- // *not in the disconnected state, upon restart.
- disconnect_and_wait(&mut mullvad_client).await?;
+ // The test should start in a disconnected state. Normally this would be
+ // preserved when restarting the app, i.e. the user would still be
+ // disconnected after a successfull restart. However, as we will
+ // intentionally corrupt the state target cache the user should end up in
+ // the connecting/connected state, *not in the disconnected state*, upon
+ // restart.
// Stopping the app should write to the state target cache.
log::info!("Stopping the app");
- rpc.stop_app().await?;
+ rpc.stop_mullvad_daemon().await?;
// Intentionally corrupt the state cache. Note that we can not simply remove
// the cache, as this will put the app in the default target state which is
@@ -373,31 +373,16 @@ pub async fn test_connecting_state_when_corrupted_state_cache(
// Start the app & make sure that we start in the 'connecting state'. The
// side-effect of this is that no network traffic is allowed to leak.
log::info!("Starting the app back up again");
- rpc.start_app().await?;
-
- let new_state = wait_for_tunnel_state(mullvad_client.clone(), |state| {
- matches!(
- state,
- TunnelState::Connecting { .. } | TunnelState::Connected { .. } | TunnelState::Error(..)
- )
- })
- .await
- .map_err(|err| {
- log::error!("App did not start in an expected state.");
- err
- })?;
-
- assert!(
- matches!(
- new_state,
- TunnelState::Connecting { .. } | TunnelState::Connected { .. }
- ),
- "App is not in either `Connecting` or `Connected` state after starting with corrupt state cache! There is a possibility of leaks during app startup"
- );
-
- log::info!(
- "App started successfully! It successfully recovered from a corrupt tunnel state cache."
- );
+ rpc.start_mullvad_daemon().await?;
+ wait_for_tunnel_state(mullvad_client.clone(), |state| !state.is_disconnected())
+ .await
+ .map_err(|err| {
+ log::error!("App did not start in an expected state. \
+ App is not in either `Connecting` or `Connected` state after starting with corrupt state cache! \
+ There is a possibility of leaks during app startup ");
+ err
+ })?;
+ log::info!("App successfully recovered from a corrupt tunnel state cache.");
Ok(())
}