Skip to content

Commit

Permalink
Merge branch 'test-runner-dir'
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Aug 14, 2024
2 parents 7781ac5 + b7ebc08 commit 92eab6f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/test-manager/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl VmConfig {
Some((self.ssh_user.as_ref()?, self.ssh_password.as_ref()?))
}

pub fn get_runner_dir(&self) -> PathBuf {
pub fn get_default_runner_dir(&self) -> PathBuf {
let target_dir = self.get_target_dir();
let subdir = match self.architecture {
None | Some(Architecture::X64) => self.get_x64_runner_subdir(),
Expand Down
9 changes: 8 additions & 1 deletion test/test-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{net::SocketAddr, path::PathBuf};

use anyhow::{Context, Result};
use clap::Parser;
use vm::provision;

use crate::tests::config::OpenVPNCertificate;

Expand Down Expand Up @@ -126,6 +127,10 @@ enum Commands {
/// Path to output test results in a structured format
#[arg(long, value_name = "PATH")]
test_report: Option<PathBuf>,

/// Path to the directory containing the test runner
#[arg(long, value_name = "DIR")]
runner_dir: Option<PathBuf>,
},

/// Output an HTML-formatted summary of one or more reports
Expand Down Expand Up @@ -238,6 +243,7 @@ async fn main() -> Result<()> {
test_filters,
verbose,
test_report,
runner_dir,
} => {
let mut config = config.clone();
config.runtime_opts.display = match (display, vnc.is_some()) {
Expand Down Expand Up @@ -282,7 +288,8 @@ async fn main() -> Result<()> {
.unwrap_or_default();

let mut instance = vm::run(&config, &vm).await.context("Failed to start VM")?;
let artifacts_dir = vm::provision(&config, &vm, &*instance, &manifest)
let runner_dir = runner_dir.unwrap_or_else(|| vm_config.get_default_runner_dir());
let artifacts_dir = provision::provision(vm_config, &*instance, &manifest, runner_dir)
.await
.context("Failed to run provisioning for VM")?;

Expand Down
16 changes: 1 addition & 15 deletions test/test-manager/src/vm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use anyhow::{Context, Result};
use std::net::IpAddr;

use crate::{
config::{Config, ConfigFile, VmConfig, VmType},
package,
};
use crate::config::{Config, ConfigFile, VmConfig, VmType};

mod logging;
pub mod network;
Expand Down Expand Up @@ -63,17 +60,6 @@ pub async fn run(config: &Config, name: &str) -> Result<Box<dyn VmInstance>> {
Ok(instance)
}

/// Returns the directory in the test runner where the test-runner binary is installed.
pub async fn provision(
config: &Config,
name: &str,
instance: &dyn VmInstance,
app_manifest: &package::Manifest,
) -> Result<String> {
let vm_config = get_vm_config(config, name)?;
provision::provision(vm_config, instance, app_manifest).await
}

pub async fn update_packages(
config: VmConfig,
instance: &dyn VmInstance,
Expand Down
3 changes: 2 additions & 1 deletion test/test-manager/src/vm/provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub async fn provision(
config: &VmConfig,
instance: &dyn super::VmInstance,
app_manifest: &package::Manifest,
runner_dir: PathBuf,
) -> Result<String> {
match config.provisioner {
Provisioner::Ssh => {
Expand All @@ -25,7 +26,7 @@ pub async fn provision(
provision_ssh(
instance,
config.os_type,
&config.get_runner_dir(),
&runner_dir,
app_manifest,
user,
password,
Expand Down

0 comments on commit 92eab6f

Please sign in to comment.