diff --git a/v2/robotmk/tests/test_scheduler.rs b/v2/robotmk/tests/test_scheduler.rs index 4440f9d8..7dbb020b 100644 --- a/v2/robotmk/tests/test_scheduler.rs +++ b/v2/robotmk/tests/test_scheduler.rs @@ -3,7 +3,8 @@ use assert_cmd::cargo::cargo_bin; use camino::{Utf8Path, Utf8PathBuf}; use robotmk::config::{ Config, EnvironmentConfig, ExecutionConfig, RCCEnvironmentConfig, RetryStrategy, - RobotFrameworkConfig, SessionConfig, SuiteConfig, WorkingDirectoryCleanupConfig, + RobotFrameworkConfig, SessionConfig, SuiteConfig, UserSessionConfig, + WorkingDirectoryCleanupConfig, }; use robotmk::section::Host; use serde_json::to_string; @@ -19,17 +20,19 @@ use walkdir::WalkDir; async fn test_scheduler() -> Result<()> { let test_dir = Utf8PathBuf::from(var("TEST_DIR")?); create_dir_all(&test_dir)?; + let current_user_name = var("UserName")?; let config = create_config( &test_dir, &Utf8PathBuf::from(var("CARGO_MANIFEST_DIR")?) .join("tests") .join("minimal_suite"), var("RCC_BINARY_PATH")?, + ¤t_user_name, ); run_scheduler(&test_dir, &config, var("RUN_FOR")?.parse::()?).await?; - assert_working_directory(&config.working_directory).await?; + assert_working_directory(&config.working_directory, ¤t_user_name).await?; assert_results_directory(&config.results_directory); assert_rcc(&config.rcc_binary_path).await?; @@ -40,34 +43,66 @@ fn create_config( test_dir: &Utf8Path, suite_dir: &Utf8Path, rcc_binary_path: impl Into, + user_name_headed: &str, ) -> Config { Config { working_directory: test_dir.join("working"), results_directory: test_dir.join("results"), rcc_binary_path: rcc_binary_path.into(), - suites: [( - String::from("suite"), - SuiteConfig { - robot_framework_config: RobotFrameworkConfig { - robot_target: suite_dir.join("tasks.robot"), - command_line_args: vec![], + suites: [ + ( + String::from("headless"), + SuiteConfig { + robot_framework_config: RobotFrameworkConfig { + robot_target: suite_dir.join("tasks.robot"), + command_line_args: vec![], + }, + execution_config: ExecutionConfig { + n_attempts_max: 1, + retry_strategy: RetryStrategy::Complete, + execution_interval_seconds: 30, + timeout: 10, + }, + environment_config: EnvironmentConfig::Rcc(RCCEnvironmentConfig { + robot_yaml_path: suite_dir.join("robot.yaml"), + build_timeout: 1200, + env_json_path: None, + }), + session_config: SessionConfig::Current, + working_directory_cleanup_config: WorkingDirectoryCleanupConfig::MaxExecutions( + 4, + ), + host: Host::Source, }, - execution_config: ExecutionConfig { - n_attempts_max: 1, - retry_strategy: RetryStrategy::Complete, - execution_interval_seconds: 30, - timeout: 10, + ), + ( + String::from("headed"), + SuiteConfig { + robot_framework_config: RobotFrameworkConfig { + robot_target: suite_dir.join("tasks.robot"), + command_line_args: vec![], + }, + execution_config: ExecutionConfig { + n_attempts_max: 1, + retry_strategy: RetryStrategy::Complete, + execution_interval_seconds: 45, + timeout: 15, + }, + environment_config: EnvironmentConfig::Rcc(RCCEnvironmentConfig { + robot_yaml_path: suite_dir.join("robot.yaml"), + build_timeout: 1200, + env_json_path: None, + }), + session_config: SessionConfig::SpecificUser(UserSessionConfig { + user_name: user_name_headed.into(), + }), + working_directory_cleanup_config: WorkingDirectoryCleanupConfig::MaxExecutions( + 4, + ), + host: Host::Source, }, - environment_config: EnvironmentConfig::Rcc(RCCEnvironmentConfig { - robot_yaml_path: suite_dir.join("robot.yaml"), - build_timeout: 1200, - env_json_path: None, - }), - session_config: SessionConfig::Current, - working_directory_cleanup_config: WorkingDirectoryCleanupConfig::MaxExecutions(4), - host: Host::Source, - }, - )] + ), + ] .into(), } } @@ -100,7 +135,10 @@ async fn run_scheduler(test_dir: &Utf8Path, config: &Config, n_seconds_run: u64) Ok(()) } -async fn assert_working_directory(working_directory: &Utf8Path) -> Result<()> { +async fn assert_working_directory( + working_directory: &Utf8Path, + headed_user_name: &str, +) -> Result<()> { assert_working_directory_permissions(&working_directory).await?; assert!(working_directory.is_dir()); assert_eq!( @@ -112,23 +150,41 @@ async fn assert_working_directory(working_directory: &Utf8Path) -> Result<()> { [ "holotree_initialization_current_user.stderr", "holotree_initialization_current_user.stdout", + &format!("holotree_initialization_user_{headed_user_name}.bat"), + &format!("holotree_initialization_user_{headed_user_name}.exit_code"), + &format!("holotree_initialization_user_{headed_user_name}.pid"), + &format!("holotree_initialization_user_{headed_user_name}.run_flag",), + &format!("holotree_initialization_user_{headed_user_name}.stderr"), + &format!("holotree_initialization_user_{headed_user_name}.stdout"), "long_path_support_enabling.stderr", "long_path_support_enabling.stdout", "shared_holotree_init.stderr", "shared_holotree_init.stdout", "telemetry_disabling_current_user.stderr", - "telemetry_disabling_current_user.stdout" + "telemetry_disabling_current_user.stdout", + &format!("telemetry_disabling_user_{headed_user_name}.bat"), + &format!("telemetry_disabling_user_{headed_user_name}.exit_code"), + &format!("telemetry_disabling_user_{headed_user_name}.pid"), + &format!("telemetry_disabling_user_{headed_user_name}.run_flag"), + &format!("telemetry_disabling_user_{headed_user_name}.stderr"), + &format!("telemetry_disabling_user_{headed_user_name}.stdout") ] ); assert_eq!( directory_entries(working_directory.join("environment_building_stdio"), 1), - ["suite.stderr", "suite.stdout"] + [ + "headed.stderr", + "headed.stdout", + "headless.stderr", + "headless.stdout" + ] ); assert_eq!( directory_entries(working_directory.join("suites"), 1), - ["suite"] + ["headed", "headless"] ); - assert!(!directory_entries(working_directory.join("suites").join("suite"), 1).is_empty()); + assert!(!directory_entries(working_directory.join("suites").join("headed"), 1).is_empty()); + assert!(!directory_entries(working_directory.join("suites").join("headless"), 1).is_empty()); Ok(()) } @@ -149,7 +205,8 @@ fn assert_results_directory(results_directory: &Utf8Path) { "rcc_setup_failures.json", "scheduler_phase.json", "suites", - "suites\\suite.json" + "suites\\headed.json", + "suites\\headless.json" ] ); }