Skip to content

Commit

Permalink
Merge branch 'testing-fix-idempotency-test'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Jan 17, 2024
2 parents 45da7d0 + 303c8d2 commit b3898cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
9 changes: 5 additions & 4 deletions test/test-manager/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ pub async fn ping_with_timeout(

/// Try to connect to a Mullvad Tunnel.
///
/// If that fails for whatever reason, the Mullvad daemon ends up in the
/// [`TunnelState::Error`] state & [`Error::DaemonError`] is returned.
/// If that fails to begin to connect, [`Error::DaemonError`] is returned. If it fails to connect
/// after that, the daemon ends up in the [`TunnelState::Error`] state, and
/// [`Error::UnexpectedErrorState`] is returned.
pub async fn connect_and_wait(mullvad_client: &mut MullvadProxyClient) -> Result<(), Error> {
log::info!("Connecting");

Expand All @@ -209,8 +210,8 @@ pub async fn connect_and_wait(mullvad_client: &mut MullvadProxyClient) -> Result
})
.await?;

if matches!(new_state, TunnelState::Error(..)) {
return Err(Error::Daemon("daemon entered error state".to_string()));
if let TunnelState::Error(error_state) = new_state {
return Err(Error::UnexpectedErrorState(error_state));
}

log::info!("Connected");
Expand Down
15 changes: 10 additions & 5 deletions test/test-manager/src/tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,20 @@ pub async fn test_install_new_app(_: TestContext, rpc: ServiceClient) -> Result<
///
/// This test is supposed to guard against regressions to this fix included in
/// the 2021.3-beta1 release:
/// https://github.com/mullvad/mullvadvpn-app/blob/main/CHANGELOG.md#security-10
/// https://github.com/mullvad/mullvadvpn-app/blob/2021.3-beta1/CHANGELOG.md#security
#[test_function(priority = -150)]
pub async fn test_installation_idempotency(
_: TestContext,
rpc: ServiceClient,
mut mullvad_client: MullvadProxyClient,
) -> Result<(), Error> {
// Connect to any relay
connect_and_wait(&mut mullvad_client).await?;
// Connect to any relay. This forces the daemon to enter a secured target state
connect_and_wait(&mut mullvad_client)
.await
.or_else(|error| match error {
Error::UnexpectedErrorState(_) => Ok(()),
err => Err(err),
})?;
// Disable auto-connect
mullvad_client
.set_auto_connect(false)
Expand All @@ -302,8 +307,8 @@ pub async fn test_installation_idempotency(
log::debug!("Installing new app");
rpc.install_app(get_package_desc(&TEST_CONFIG.current_app_filename)?)
.await?;
// verify that daemon is running
wait_for_tunnel_state(mullvad_client.clone(), |state| state.is_connected())
// verify that the daemon starts in a non-disconnected state
wait_for_tunnel_state(mullvad_client.clone(), |state| !state.is_disconnected())
.await
.map_err(|err| {
log::error!(
Expand Down
3 changes: 3 additions & 0 deletions test/test-manager/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub enum Error {
#[error(display = "The daemon returned an error: {}", _0)]
Daemon(String),

#[error(display = "The daemon ended up in the error state")]
UnexpectedErrorState(talpid_types::tunnel::ErrorState),

#[error(display = "The gRPC client ran into an error: {}", _0)]
ManagementInterface(#[source] mullvad_management_interface::Error),

Expand Down

0 comments on commit b3898cf

Please sign in to comment.