Skip to content

Commit 9307bbc

Browse files
committed
Place test_uninstall_app after test_install_new_app
This removes the requirement that `test_install_previous_app` and `test_upgrade_app` are run before so that the app is installed. Also make `test_uninstall_app` reinstall the app again to reset the state.
1 parent a92473a commit 9307bbc

File tree

1 file changed

+43
-32
lines changed

1 file changed

+43
-32
lines changed

test/test-manager/src/tests/install.rs

+43-32
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,37 @@ pub async fn test_upgrade_app(ctx: TestContext, rpc: ServiceClient) -> anyhow::R
178178
Ok(())
179179
}
180180

181+
/// Install the app cleanly, failing if the installer doesn't succeed
182+
/// or if the VPN service is not running afterwards.
183+
#[test_function(always_run = true, must_succeed = true, priority = -170)]
184+
pub async fn test_install_new_app(_: TestContext, rpc: ServiceClient) -> anyhow::Result<()> {
185+
// verify that daemon is not already running
186+
if rpc.mullvad_daemon_get_status().await? != ServiceStatus::NotRunning {
187+
rpc.stop_mullvad_daemon().await.unwrap();
188+
}
189+
190+
// install package
191+
log::debug!("Installing new app");
192+
rpc.install_app(get_package_desc(&TEST_CONFIG.app_package_filename)?)
193+
.await?;
194+
195+
// verify that daemon is running
196+
if rpc.mullvad_daemon_get_status().await? != ServiceStatus::Running {
197+
bail!(Error::DaemonNotRunning);
198+
}
199+
200+
// Set the log level to trace
201+
rpc.set_daemon_log_level(test_rpc::mullvad_daemon::Verbosity::Trace)
202+
.await?;
203+
204+
replace_openvpn_cert(&rpc).await?;
205+
206+
// Override env vars
207+
rpc.set_daemon_environment(get_app_env().await?).await?;
208+
209+
Ok(())
210+
}
211+
181212
/// Uninstall the app version being tested. This verifies
182213
/// that that the uninstaller works, and also that logs,
183214
/// application files, system services are removed.
@@ -189,16 +220,24 @@ pub async fn test_upgrade_app(ctx: TestContext, rpc: ServiceClient) -> anyhow::R
189220
/// Files due to Electron, temporary files, registry
190221
/// values/keys, and device drivers are not guaranteed
191222
/// to be deleted.
192-
#[test_function(priority = -170, cleanup = false)]
223+
#[test_function(priority = -160, cleanup = false)]
193224
pub async fn test_uninstall_app(
194-
_: TestContext,
225+
_ctx: TestContext,
195226
rpc: ServiceClient,
196227
mut mullvad_client: MullvadProxyClient,
197228
) -> anyhow::Result<()> {
198229
if rpc.mullvad_daemon_get_status().await? != ServiceStatus::Running {
199230
bail!(Error::DaemonNotRunning);
200231
}
201232

233+
// Clear devices before logging in
234+
let device_client = super::account::new_device_client()
235+
.await
236+
.context("Failed to create device client")?;
237+
super::account::clear_devices(&device_client)
238+
.await
239+
.context("failed to clear devices")?;
240+
202241
// Login to test preservation of device/account
203242
// TODO: Remove once we can login before upgrade above
204243
mullvad_client
@@ -247,36 +286,8 @@ pub async fn test_uninstall_app(
247286
uninstalled_device,
248287
);
249288

250-
Ok(())
251-
}
252-
253-
/// Install the app cleanly, failing if the installer doesn't succeed
254-
/// or if the VPN service is not running afterwards.
255-
#[test_function(always_run = true, must_succeed = true, priority = -160)]
256-
pub async fn test_install_new_app(_: TestContext, rpc: ServiceClient) -> anyhow::Result<()> {
257-
// verify that daemon is not already running
258-
if rpc.mullvad_daemon_get_status().await? != ServiceStatus::NotRunning {
259-
bail!(Error::DaemonRunning);
260-
}
261-
262-
// install package
263-
log::debug!("Installing new app");
264-
rpc.install_app(get_package_desc(&TEST_CONFIG.app_package_filename)?)
265-
.await?;
266-
267-
// verify that daemon is running
268-
if rpc.mullvad_daemon_get_status().await? != ServiceStatus::Running {
269-
bail!(Error::DaemonNotRunning);
270-
}
271-
272-
// Set the log level to trace
273-
rpc.set_daemon_log_level(test_rpc::mullvad_daemon::Verbosity::Trace)
274-
.await?;
275-
276-
replace_openvpn_cert(&rpc).await?;
277-
278-
// Override env vars
279-
rpc.set_daemon_environment(get_app_env().await?).await?;
289+
// Re-install the app to ensure that the next test can run
290+
test_install_new_app(_ctx, rpc).await?;
280291

281292
Ok(())
282293
}

0 commit comments

Comments
 (0)