From 4a04368695d980820f412bf5d4c6166c373e2240 Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Thu, 30 Nov 2023 17:24:17 +0100 Subject: [PATCH] Add headed suite --- v2/robotmk/tests/test_scheduler.rs | 107 +++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 27 deletions(-) diff --git a/v2/robotmk/tests/test_scheduler.rs b/v2/robotmk/tests/test_scheduler.rs index 4440f9d8..1f9db80d 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; @@ -25,6 +26,7 @@ async fn test_scheduler() -> Result<()> { .join("tests") .join("minimal_suite"), var("RCC_BINARY_PATH")?, + &var("UserName")?, ); run_scheduler(&test_dir, &config, var("RUN_FOR")?.parse::()?).await?; @@ -40,34 +42,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(), } } @@ -112,23 +146,41 @@ async fn assert_working_directory(working_directory: &Utf8Path) -> Result<()> { [ "holotree_initialization_current_user.stderr", "holotree_initialization_current_user.stdout", + "holotree_initialization_user_vagrant.bat", + "holotree_initialization_user_vagrant.exit_code", + "holotree_initialization_user_vagrant.pid", + "holotree_initialization_user_vagrant.run_flag", + "holotree_initialization_user_vagrant.stderr", + "holotree_initialization_user_vagrant.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", + "telemetry_disabling_user_vagrant.bat", + "telemetry_disabling_user_vagrant.exit_code", + "telemetry_disabling_user_vagrant.pid", + "telemetry_disabling_user_vagrant.run_flag", + "telemetry_disabling_user_vagrant.stderr", + "telemetry_disabling_user_vagrant.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 +201,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" ] ); }