diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-12-05 09:36:55 +0100 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-12-06 14:37:24 +0100 |
| commit | 07dedbcf0247a9a1c0d91aebd765ae6a0c77155f (patch) | |
| tree | 3283ea38e40db031b9f6fcb6e6f144e8d9c91e5b /test/test-runner/src | |
| parent | 44a478e71ff0ed02a18c824fe0b0243398310d6b (diff) | |
| download | mullvadvpn-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-runner/src')
| -rw-r--r-- | test/test-runner/src/main.rs | 14 | ||||
| -rw-r--r-- | test/test-runner/src/sys.rs | 70 |
2 files changed, 24 insertions, 60 deletions
diff --git a/test/test-runner/src/main.rs b/test/test-runner/src/main.rs index 259ccdbab6..fe85e6f89f 100644 --- a/test/test-runner/src/main.rs +++ b/test/test-runner/src/main.rs @@ -226,17 +226,17 @@ impl Service for TestServer { logging::get_mullvad_app_logs().await } - async fn restart_app(self, _: context::Context) -> Result<(), test_rpc::Error> { + async fn restart_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> { sys::restart_app().await } /// Stop the Mullvad VPN application. - async fn stop_app(self, _: context::Context) -> Result<(), test_rpc::Error> { + async fn stop_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> { sys::stop_app().await } /// Start the Mullvad VPN application. - async fn start_app(self, _: context::Context) -> Result<(), test_rpc::Error> { + async fn start_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> { sys::start_app().await } @@ -292,14 +292,6 @@ impl Service for TestServer { sys::reboot() } - async fn set_mullvad_daemon_service_state( - self, - _: context::Context, - on: bool, - ) -> Result<(), test_rpc::Error> { - sys::set_mullvad_daemon_service_state(on).await - } - async fn make_device_json_old(self, _: context::Context) -> Result<(), test_rpc::Error> { app::make_device_json_old().await } diff --git a/test/test-runner/src/sys.rs b/test/test-runner/src/sys.rs index cc89205425..562c608120 100644 --- a/test/test-runner/src/sys.rs +++ b/test/test-runner/src/sys.rs @@ -216,7 +216,14 @@ pub async fn restart_app() -> Result<(), test_rpc::Error> { /// This function waits for the app to successfully shut down. #[cfg(target_os = "linux")] pub async fn stop_app() -> Result<(), test_rpc::Error> { - set_mullvad_daemon_service_state(false).await + tokio::process::Command::new("systemctl") + .args(["stop", "mullvad-daemon"]) + .status() + .await + .map_err(|e| test_rpc::Error::Service(e.to_string()))?; + wait_for_service_state(ServiceState::Inactive).await?; + + Ok(()) } /// Start the Mullvad VPN application. @@ -224,7 +231,13 @@ pub async fn stop_app() -> Result<(), test_rpc::Error> { /// This function waits for the app to successfully start again. #[cfg(target_os = "linux")] pub async fn start_app() -> Result<(), test_rpc::Error> { - set_mullvad_daemon_service_state(true).await + tokio::process::Command::new("systemctl") + .args(["start", "mullvad-daemon"]) + .status() + .await + .map_err(|e| test_rpc::Error::Service(e.to_string()))?; + wait_for_service_state(ServiceState::Running).await?; + Ok(()) } /// Restart the Mullvad VPN application. @@ -278,7 +291,9 @@ pub async fn restart_app() -> Result<(), test_rpc::Error> { /// This function waits for the app to successfully shut down. #[cfg(target_os = "macos")] pub async fn stop_app() -> Result<(), test_rpc::Error> { - set_mullvad_daemon_service_state(false).await + set_launch_daemon_state(false).await?; + tokio::time::sleep(std::time::Duration::from_millis(1000)).await; + Ok(()) } /// Start the Mullvad VPN application. @@ -286,7 +301,9 @@ pub async fn stop_app() -> Result<(), test_rpc::Error> { /// This function waits for the app to successfully start again. #[cfg(target_os = "macos")] pub async fn start_app() -> Result<(), test_rpc::Error> { - set_mullvad_daemon_service_state(true).await + set_launch_daemon_state(false).await?; + tokio::time::sleep(std::time::Duration::from_millis(1000)).await; + Ok(()) } #[cfg(target_os = "windows")] @@ -506,51 +523,6 @@ pub async fn set_daemon_environment(env: HashMap<String, String>) -> Result<(), Ok(()) } -#[cfg(target_os = "linux")] -pub async fn set_mullvad_daemon_service_state(on: bool) -> Result<(), test_rpc::Error> { - if on { - tokio::process::Command::new("systemctl") - .args(["start", "mullvad-daemon"]) - .status() - .await - .map_err(|e| test_rpc::Error::Service(e.to_string()))?; - wait_for_service_state(ServiceState::Running).await?; - } else { - tokio::process::Command::new("systemctl") - .args(["stop", "mullvad-daemon"]) - .status() - .await - .map_err(|e| test_rpc::Error::Service(e.to_string()))?; - wait_for_service_state(ServiceState::Inactive).await?; - } - Ok(()) -} - -#[cfg(target_os = "windows")] -pub async fn set_mullvad_daemon_service_state(on: bool) -> Result<(), test_rpc::Error> { - if on { - tokio::process::Command::new("net") - .args(["start", "mullvadvpn"]) - .status() - .await - .map_err(|e| test_rpc::Error::Service(e.to_string()))?; - } else { - tokio::process::Command::new("net") - .args(["stop", "mullvadvpn"]) - .status() - .await - .map_err(|e| test_rpc::Error::Service(e.to_string()))?; - } - Ok(()) -} - -#[cfg(target_os = "macos")] -pub async fn set_mullvad_daemon_service_state(on: bool) -> Result<(), test_rpc::Error> { - set_launch_daemon_state(on).await?; - tokio::time::sleep(std::time::Duration::from_millis(1000)).await; - Ok(()) -} - #[cfg(target_os = "macos")] async fn set_launch_daemon_state(on: bool) -> Result<(), test_rpc::Error> { tokio::process::Command::new("launchctl") |
