summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSebastian Holmin <sebastian.holmin@mullvad.net>2024-07-19 10:07:32 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2024-07-19 11:40:31 +0200
commit1c35e009b838acad37ce6e596f4480c34ea58ee0 (patch)
treee5a087d098603d8e8bf545f4bd6470320af58356
parent7aa8247f8e2b5e7ca0577293ed9c1604e40eac17 (diff)
downloadmullvadvpn-1c35e009b838acad37ce6e596f4480c34ea58ee0.tar.xz
mullvadvpn-1c35e009b838acad37ce6e596f4480c34ea58ee0.zip
Replace implicit cache folder with `--package-folder` arg
-rwxr-xr-xtest/ci-runtests.sh3
-rw-r--r--test/test-manager/src/main.rs24
-rw-r--r--test/test-manager/src/package.rs17
-rw-r--r--test/test-manager/src/vm/provision.rs4
4 files changed, 26 insertions, 22 deletions
diff --git a/test/ci-runtests.sh b/test/ci-runtests.sh
index 4b8704643a..71aff6061b 100755
--- a/test/ci-runtests.sh
+++ b/test/ci-runtests.sh
@@ -197,8 +197,9 @@ function run_tests_for_os {
RUST_LOG=debug cargo run --bin test-manager \
run-tests \
--account "${ACCOUNT_TOKEN:?Error: ACCOUNT_TOKEN not set}" \
- --current-app "${cur_filename}" \
+ --app-package "${cur_filename}" \
--previous-app "${prev_filename}" \
+ --package-folder "$PACKAGES_DIR" \
--test-report "$SCRIPT_DIR/.ci-logs/${os}_report" \
"$os" 2>&1 | sed "s/${ACCOUNT_TOKEN}/\{ACCOUNT_TOKEN\}/g"
}
diff --git a/test/test-manager/src/main.rs b/test/test-manager/src/main.rs
index 90176fb4d8..db181f99e0 100644
--- a/test/test-manager/src/main.rs
+++ b/test/test-manager/src/main.rs
@@ -80,14 +80,8 @@ enum Commands {
account: String,
/// App package to test. Can be a path to the package, just the package file name, git hash
- /// or tag. If the direct path is not given, the package is assumed to be in the cache
- /// directory for the host OS, given by the following table:
- ///
- /// |Platform | Value | Example |
- /// | ------- | ----------------------------------- | ---------------------------- |
- /// | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/alice/.cache |
- /// | macOS | `$HOME`/Library/Caches | /Users/Alice/Library/Caches |
- /// | Windows | `{FOLDERID_LocalAppData}` | C:\Users\Alice\AppData\Local |
+ /// or tag. If the direct path is not given, the package is assumed to be in the directory
+ /// specified by the `--package-folder` argument.
///
/// # Note
///
@@ -102,9 +96,13 @@ enum Commands {
/// # Note
///
/// The CLI interface must be compatible with the upgrade test.
- #[arg(long, short)]
+ #[arg(long)]
previous_app: Option<String>,
+ /// Folder to search for packages. Defaults to current directory.
+ #[arg(long, value_name = "DIR")]
+ package_folder: Option<PathBuf>,
+
/// Only run tests matching substrings
test_filters: Vec<String>,
@@ -228,6 +226,7 @@ async fn main() -> Result<()> {
account,
current_app,
previous_app,
+ package_folder,
test_filters,
verbose,
test_report,
@@ -261,9 +260,10 @@ async fn main() -> Result<()> {
None => None,
};
- let manifest = package::get_app_manifest(vm_config, current_app, previous_app)
- .await
- .context("Could not find the specified app packages")?;
+ let manifest =
+ package::get_app_manifest(vm_config, current_app, previous_app, package_folder)
+ .await
+ .context("Could not find the specified app packages")?;
let mut instance = vm::run(&config, &name)
.await
diff --git a/test/test-manager/src/package.rs b/test/test-manager/src/package.rs
index cbe6d34155..e428a6514d 100644
--- a/test/test-manager/src/package.rs
+++ b/test/test-manager/src/package.rs
@@ -23,15 +23,17 @@ pub async fn get_app_manifest(
config: &VmConfig,
current_app: String,
previous_app: Option<String>,
+ package_folder: Option<PathBuf>,
) -> 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?;
+ let current_app_path =
+ find_app(&current_app, false, package_type, package_folder.as_ref()).await?;
log::info!("Current app: {}", current_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?)
+ Some(find_app(&previous_app, false, package_type, package_folder.as_ref()).await?)
} else {
log::warn!("No previous app version specified");
None
@@ -44,7 +46,9 @@ 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.ok();
+ let ui_e2e_tests_path = find_app(capture, true, package_type, package_folder.as_ref())
+ .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 {
@@ -62,6 +66,7 @@ async fn find_app(
app: &str,
e2e_bin: bool,
package_type: (OsType, Option<PackageType>, Option<Architecture>),
+ package_folder: Option<&PathBuf>,
) -> Result<PathBuf> {
// If it's a path, use that path
let app_path = Path::new(app);
@@ -73,10 +78,8 @@ async fn find_app(
let mut app = app.to_owned();
app.make_ascii_lowercase();
- let packages_dir = dirs::cache_dir()
- .context("Could not find cache directory")?
- .join("mullvad-test")
- .join("packages");
+ let current_dir = std::env::current_dir().expect("Unable to get current directory");
+ let packages_dir = package_folder.unwrap_or(&current_dir);
fs::create_dir_all(&packages_dir).await?;
let mut dir = fs::read_dir(packages_dir.clone())
.await
diff --git a/test/test-manager/src/vm/provision.rs b/test/test-manager/src/vm/provision.rs
index 1170fa1a7f..2f92b01511 100644
--- a/test/test-manager/src/vm/provision.rs
+++ b/test/test-manager/src/vm/provision.rs
@@ -160,7 +160,7 @@ fn blocking_ssh(
.file_name()
.unwrap()
.to_string_lossy();
- let old_app_path = local_app_manifest
+ let previous_app_path = local_app_manifest
.previous_app_path
.map(|path| path.file_name().unwrap().to_string_lossy().into_owned())
.unwrap_or_default();
@@ -170,7 +170,7 @@ fn blocking_ssh(
.unwrap_or_default();
let cmd = format!(
- "sudo {} {remote_dir} \"{current_app_path}\" \"{old_app_path}\" \"{ui_e2e_tests_path}\"",
+ "sudo {} {remote_dir} \"{current_app_path}\" \"{previous_app_path}\" \"{ui_e2e_tests_path}\"",
dest.display()
);
log::debug!("Running setup script on remote, cmd: {cmd}");