summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2024-07-17 20:54:39 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2024-07-19 11:04:49 +0200
commit4df70d8951e92c1ecc9ebc7eb5347894d8ddc7d5 (patch)
tree80bbbca5c318d420d75a65840c44c187a5c94a7d
parent3a96d56cee566dd720a0f2ae5104ea57995868fc (diff)
downloadmullvadvpn-4df70d8951e92c1ecc9ebc7eb5347894d8ddc7d5.tar.xz
mullvadvpn-4df70d8951e92c1ecc9ebc7eb5347894d8ddc7d5.zip
Make previous app version and gui e2e binaries optional
-rw-r--r--test/test-manager/src/main.rs12
-rw-r--r--test/test-manager/src/package.rs23
-rw-r--r--test/test-manager/src/tests/config.rs4
-rw-r--r--test/test-manager/src/tests/install.rs9
-rw-r--r--test/test-manager/src/tests/mod.rs3
-rw-r--r--test/test-manager/src/tests/ui.rs16
-rw-r--r--test/test-manager/src/vm/provision.rs54
7 files changed, 73 insertions, 48 deletions
diff --git a/test/test-manager/src/main.rs b/test/test-manager/src/main.rs
index 37d7227967..078e91c7b3 100644
--- a/test/test-manager/src/main.rs
+++ b/test/test-manager/src/main.rs
@@ -94,7 +94,7 @@ enum Commands {
///
/// The CLI interface must be compatible with the upgrade test.
#[arg(long, short)]
- previous_app: String,
+ previous_app: Option<String>,
/// Only run tests matching substrings
test_filters: Vec<String>,
@@ -284,16 +284,10 @@ async fn main() -> Result<()> {
.into_owned(),
previous_app_filename: manifest
.previous_app_path
- .file_name()
- .unwrap()
- .to_string_lossy()
- .into_owned(),
+ .map(|path| path.file_name().unwrap().to_string_lossy().into_owned()),
ui_e2e_tests_filename: manifest
.ui_e2e_tests_path
- .file_name()
- .unwrap()
- .to_string_lossy()
- .into_owned(),
+ .map(|path| path.file_name().unwrap().to_string_lossy().into_owned()),
mullvad_host,
#[cfg(target_os = "macos")]
host_bridge_name: crate::vm::network::macos::find_vm_bridge()?,
diff --git a/test/test-manager/src/package.rs b/test/test-manager/src/package.rs
index 7e69ae867f..cbe6d34155 100644
--- a/test/test-manager/src/package.rs
+++ b/test/test-manager/src/package.rs
@@ -11,8 +11,8 @@ static VERSION_REGEX: Lazy<Regex> =
#[derive(Debug, Clone)]
pub struct Manifest {
pub current_app_path: PathBuf,
- pub previous_app_path: PathBuf,
- pub ui_e2e_tests_path: PathBuf,
+ pub previous_app_path: Option<PathBuf>,
+ pub ui_e2e_tests_path: Option<PathBuf>,
}
/// Obtain app packages and their filenames
@@ -22,15 +22,20 @@ pub struct Manifest {
pub async fn get_app_manifest(
config: &VmConfig,
current_app: String,
- previous_app: String,
+ previous_app: Option<String>,
) -> Result<Manifest> {
let package_type = (config.os_type, config.package_type, config.architecture);
let current_app_path = find_app(&current_app, false, package_type).await?;
log::info!("Current app: {}", current_app_path.display());
- let previous_app_path = find_app(&previous_app, false, package_type).await?;
- log::info!("Previous app: {}", previous_app_path.display());
+ let previous_app_path = if let Some(previous_app) = previous_app {
+ log::info!("Previous app: {}", previous_app);
+ Some(find_app(&previous_app, false, package_type).await?)
+ } else {
+ log::warn!("No previous app version specified");
+ None
+ };
let capture = VERSION_REGEX
.captures(current_app_path.to_str().unwrap())
@@ -39,8 +44,12 @@ pub async fn get_app_manifest(
.map(|c| c.as_str())
.expect("Could not parse version from package name: {current_app}");
- let ui_e2e_tests_path = find_app(capture, true, package_type).await?;
- log::info!("Runner executable: {}", ui_e2e_tests_path.display());
+ let ui_e2e_tests_path = find_app(capture, true, package_type).await.ok();
+ if let Some(ui_e2e_tests_path) = &ui_e2e_tests_path {
+ log::info!("GUI e2e test binary: {}", ui_e2e_tests_path.display());
+ } else {
+ log::warn!("Could not find UI e2e test binary");
+ }
Ok(Manifest {
current_app_path,
diff --git a/test/test-manager/src/tests/config.rs b/test/test-manager/src/tests/config.rs
index 7ffe737aa7..7fcc1e9f56 100644
--- a/test/test-manager/src/tests/config.rs
+++ b/test/test-manager/src/tests/config.rs
@@ -13,8 +13,8 @@ pub struct TestConfig {
pub artifacts_dir: String,
pub current_app_filename: String,
- pub previous_app_filename: String,
- pub ui_e2e_tests_filename: String,
+ pub previous_app_filename: Option<String>,
+ pub ui_e2e_tests_filename: Option<String>,
/// Used to override MULLVAD_API_*, for conncheck,
/// and for resolving relay IPs.
diff --git a/test/test-manager/src/tests/install.rs b/test/test-manager/src/tests/install.rs
index d7056cce76..274ce173c2 100644
--- a/test/test-manager/src/tests/install.rs
+++ b/test/test-manager/src/tests/install.rs
@@ -22,8 +22,13 @@ pub async fn test_install_previous_app(_: TestContext, rpc: ServiceClient) -> an
// install package
log::debug!("Installing old app");
- rpc.install_app(get_package_desc(&TEST_CONFIG.previous_app_filename)?)
- .await?;
+ rpc.install_app(get_package_desc(
+ TEST_CONFIG
+ .previous_app_filename
+ .as_ref()
+ .context("Missing previous app version")?,
+ )?)
+ .await?;
// verify that daemon is running
if rpc.mullvad_daemon_get_status().await? != ServiceStatus::Running {
diff --git a/test/test-manager/src/tests/mod.rs b/test/test-manager/src/tests/mod.rs
index 255efb5941..23a3976ef2 100644
--- a/test/test-manager/src/tests/mod.rs
+++ b/test/test-manager/src/tests/mod.rs
@@ -59,6 +59,9 @@ pub enum Error {
#[error("The gRPC client ran into an error: {0}")]
ManagementInterface(#[from] mullvad_management_interface::Error),
+ #[error("GUI test binary missing")]
+ MissingGuiTest,
+
#[cfg(target_os = "macos")]
#[error("An error occurred: {0}")]
Other(String),
diff --git a/test/test-manager/src/tests/ui.rs b/test/test-manager/src/tests/ui.rs
index 65093a6758..f4b9af04f3 100644
--- a/test/test-manager/src/tests/ui.rs
+++ b/test/test-manager/src/tests/ui.rs
@@ -37,15 +37,23 @@ pub async fn run_test_env<
Os::Linux => {
bin_path = PathBuf::from("/usr/bin/xvfb-run");
- let ui_runner_path =
- Path::new(&TEST_CONFIG.artifacts_dir).join(&TEST_CONFIG.ui_e2e_tests_filename);
+ let ui_runner_path = Path::new(&TEST_CONFIG.artifacts_dir).join(
+ TEST_CONFIG
+ .ui_e2e_tests_filename
+ .as_ref()
+ .ok_or(Error::MissingGuiTest)?,
+ );
new_params = std::iter::once(ui_runner_path.to_string_lossy().into_owned())
.chain(params.iter().map(|param| param.as_ref().to_owned()))
.collect();
}
_ => {
- bin_path =
- Path::new(&TEST_CONFIG.artifacts_dir).join(&TEST_CONFIG.ui_e2e_tests_filename);
+ bin_path = Path::new(&TEST_CONFIG.artifacts_dir).join(
+ TEST_CONFIG
+ .ui_e2e_tests_filename
+ .as_ref()
+ .ok_or(Error::MissingGuiTest)?,
+ );
new_params = params
.iter()
.map(|param| param.as_ref().to_owned())
diff --git a/test/test-manager/src/vm/provision.rs b/test/test-manager/src/vm/provision.rs
index dfdfd30a39..1170fa1a7f 100644
--- a/test/test-manager/src/vm/provision.rs
+++ b/test/test-manager/src/vm/provision.rs
@@ -117,10 +117,18 @@ fn blocking_ssh(
// Transfer app packages
ssh_send_file_path(&session, &local_app_manifest.current_app_path, temp_dir)
.context("Failed to send current app package to remote")?;
- ssh_send_file_path(&session, &local_app_manifest.previous_app_path, temp_dir)
- .context("Failed to send previous app package to remote")?;
- ssh_send_file_path(&session, &local_app_manifest.ui_e2e_tests_path, temp_dir)
- .context("Failed to send UI test runner to remote")?;
+ if let Some(previous_app_path) = &local_app_manifest.previous_app_path {
+ ssh_send_file_path(&session, previous_app_path, temp_dir)
+ .context("Failed to send previous app package to remote")?;
+ } else {
+ log::warn!("No previous app to send to remote")
+ }
+ if let Some(ui_e2e_tests_path) = &local_app_manifest.ui_e2e_tests_path {
+ ssh_send_file_path(&session, ui_e2e_tests_path, temp_dir)
+ .context("Failed to send ui_e2e_tests_path to remote")?;
+ } else {
+ log::warn!("No UI e2e test to send to remote")
+ }
// Transfer openvpn cert
let dest: std::path::PathBuf = temp_dir.join("openvpn.ca.crt");
@@ -147,28 +155,26 @@ fn blocking_ssh(
.context("failed to send bootstrap script to remote")?;
// Run setup script
+ let current_app_path = local_app_manifest
+ .current_app_path
+ .file_name()
+ .unwrap()
+ .to_string_lossy();
+ let old_app_path = local_app_manifest
+ .previous_app_path
+ .map(|path| path.file_name().unwrap().to_string_lossy().into_owned())
+ .unwrap_or_default();
+ let ui_e2e_tests_path = local_app_manifest
+ .ui_e2e_tests_path
+ .map(|path| path.file_name().unwrap().to_string_lossy().into_owned())
+ .unwrap_or_default();
- let args = format!(
- "{remote_dir} \"{}\" \"{}\" \"{}\"",
- local_app_manifest
- .current_app_path
- .file_name()
- .unwrap()
- .to_string_lossy(),
- local_app_manifest
- .previous_app_path
- .file_name()
- .unwrap()
- .to_string_lossy(),
- local_app_manifest
- .ui_e2e_tests_path
- .file_name()
- .unwrap()
- .to_string_lossy(),
+ let cmd = format!(
+ "sudo {} {remote_dir} \"{current_app_path}\" \"{old_app_path}\" \"{ui_e2e_tests_path}\"",
+ dest.display()
);
-
- log::debug!("Running setup script on remote, args: {args}");
- ssh_exec(&session, &format!("sudo {} {args}", dest.display()))
+ log::debug!("Running setup script on remote, cmd: {cmd}");
+ ssh_exec(&session, &cmd)
.map(drop)
.context("Failed to run setup script")
}