diff --git a/v2/robotmk/src/bin/scheduler/environment.rs b/v2/robotmk/src/bin/scheduler/environment.rs index 6255e6ba..0ac60b43 100644 --- a/v2/robotmk/src/bin/scheduler/environment.rs +++ b/v2/robotmk/src/bin/scheduler/environment.rs @@ -49,16 +49,16 @@ fn build_environment( ) -> Result> { let suite = match suite.environment.build_instructions() { Some(build_instructions) => { - info!("Building environment for suite {}", suite.name); + info!("Building environment for suite {}", suite.id); let start_time = Utc::now().timestamp(); environment_build_states_administrator - .update(&suite.name, EnvironmentBuildStatus::InProgress(start_time))?; + .update(&suite.id, EnvironmentBuildStatus::InProgress(start_time))?; let environment_build_status = run_environment_build( ChildProcessSupervisor { command_spec: &build_instructions.command_spec, stdio_paths: Some(StdioPaths { - stdout: stdio_directory.join(format!("{}.stdout", suite.name)), - stderr: stdio_directory.join(format!("{}.stderr", suite.name)), + stdout: stdio_directory.join(format!("{}.stdout", suite.id)), + stderr: stdio_directory.join(format!("{}.stderr", suite.id)), }), timeout: build_instructions.timeout, termination_flag: &suite.termination_flag, @@ -66,13 +66,13 @@ fn build_environment( start_time, )?; let drop_suite = matches!(environment_build_status, EnvironmentBuildStatus::Failure(_)); - environment_build_states_administrator.update(&suite.name, environment_build_status)?; + environment_build_states_administrator.update(&suite.id, environment_build_status)?; (!drop_suite).then_some(suite) } None => { - debug!("Nothing to do for suite {}", suite.name); + debug!("Nothing to do for suite {}", suite.id); environment_build_states_administrator - .update(&suite.name, EnvironmentBuildStatus::NotNeeded)?; + .update(&suite.id, EnvironmentBuildStatus::NotNeeded)?; Some(suite) } }; @@ -144,7 +144,7 @@ pub struct RCCEnvironment { impl Environment { pub fn new( - suite_name: &str, + suite_id: &str, rcc_binary_path: &Utf8Path, environment_config: &EnvironmentConfig, ) -> Self { @@ -154,7 +154,7 @@ impl Environment { binary_path: rcc_binary_path.to_path_buf(), robot_yaml_path: rcc_environment_config.robot_yaml_path.clone(), controller: String::from("robotmk"), - space: suite_name.to_string(), + space: suite_id.to_string(), build_timeout: rcc_environment_config.build_timeout, env_json_path: rcc_environment_config.env_json_path.clone(), }), diff --git a/v2/robotmk/src/bin/scheduler/internal_config.rs b/v2/robotmk/src/bin/scheduler/internal_config.rs index 627b71c0..05c9d746 100644 --- a/v2/robotmk/src/bin/scheduler/internal_config.rs +++ b/v2/robotmk/src/bin/scheduler/internal_config.rs @@ -23,7 +23,7 @@ pub struct GlobalConfig { #[derive(Clone)] pub struct Suite { - pub name: String, + pub id: String, pub working_directory: Utf8PathBuf, pub results_file: Utf8PathBuf, pub execution_interval_seconds: u32, @@ -46,14 +46,14 @@ pub fn from_external_config( let mut suites: Vec = external_config .suites .into_iter() - .map(|(suite_name, suite_config)| Suite { - name: suite_name.clone(), + .map(|(suite_id, suite_config)| Suite { + id: suite_id.clone(), working_directory: external_config .working_directory .join("suites") - .join(&suite_name), + .join(&suite_id), results_file: suite_results_directory(&external_config.results_directory) - .join(format!("{}.json", suite_name)), + .join(format!("{}.json", suite_id)), execution_interval_seconds: suite_config.execution_config.execution_interval_seconds, timeout: suite_config.execution_config.timeout, robot: Robot { @@ -63,7 +63,7 @@ pub fn from_external_config( retry_strategy: suite_config.execution_config.retry_strategy, }, environment: Environment::new( - &suite_name, + &suite_id, &external_config.rcc_binary_path, &suite_config.environment_config, ), @@ -75,7 +75,7 @@ pub fn from_external_config( results_directory_locker: results_directory_locker.clone(), }) .collect(); - sort_suites_by_name(&mut suites); + sort_suites_by_id(&mut suites); ( GlobalConfig { working_directory: external_config.working_directory, @@ -88,8 +88,8 @@ pub fn from_external_config( ) } -pub fn sort_suites_by_name(suites: &mut [Suite]) { - suites.sort_by_key(|suite| suite.name.to_string()); +pub fn sort_suites_by_id(suites: &mut [Suite]) { + suites.sort_by_key(|suite| suite.id.to_string()); } #[cfg(test)] @@ -169,7 +169,7 @@ mod tests { assert_eq!(global_config.results_directory, "/results"); assert_eq!(global_config.rcc_binary_path, "/bin/rcc"); assert_eq!(suites.len(), 2); - assert_eq!(suites[0].name, "rcc"); + assert_eq!(suites[0].id, "rcc"); assert_eq!(suites[0].working_directory, "/working/suites/rcc"); assert_eq!(suites[0].results_file, "/results/suites/rcc.json"); assert_eq!(suites[0].execution_interval_seconds, 300); @@ -204,7 +204,7 @@ mod tests { suites[0].working_directory_cleanup_config, WorkingDirectoryCleanupConfig::MaxExecutions(50), ); - assert_eq!(suites[1].name, "system"); + assert_eq!(suites[1].id, "system"); assert_eq!(suites[1].working_directory, "/working/suites/system"); assert_eq!(suites[1].results_file, "/results/suites/system.json"); assert_eq!(suites[1].execution_interval_seconds, 300); diff --git a/v2/robotmk/src/bin/scheduler/results.rs b/v2/robotmk/src/bin/scheduler/results.rs index 9e0d03a1..c6d1b198 100644 --- a/v2/robotmk/src/bin/scheduler/results.rs +++ b/v2/robotmk/src/bin/scheduler/results.rs @@ -62,7 +62,7 @@ impl<'a> EnvironmentBuildStatesAdministrator<'a> { ) -> Result> { let build_states: HashMap<_, _> = suites .iter() - .map(|suite| (suite.name.to_string(), EnvironmentBuildStatus::Pending)) + .map(|suite| (suite.id.to_string(), EnvironmentBuildStatus::Pending)) .collect(); let path = results_directory.join("environment_build_states.json"); BuildStates(&build_states).write(&path, locker)?; @@ -73,8 +73,8 @@ impl<'a> EnvironmentBuildStatesAdministrator<'a> { }) } - pub fn update(&mut self, suite_name: &str, build_status: EnvironmentBuildStatus) -> Result<()> { - self.build_states.insert(suite_name.into(), build_status); + pub fn update(&mut self, suite_id: &str, build_status: EnvironmentBuildStatus) -> Result<()> { + self.build_states.insert(suite_id.into(), build_status); BuildStates(&self.build_states).write(&self.path, self.locker) } } @@ -97,7 +97,7 @@ pub enum EnvironmentBuildStatusError { #[derive(Serialize)] pub struct SuiteExecutionReport { - pub suite_name: String, + pub suite_id: String, pub outcome: ExecutionReport, } diff --git a/v2/robotmk/src/bin/scheduler/scheduling/cleanup.rs b/v2/robotmk/src/bin/scheduler/scheduling/cleanup.rs index 20e21398..cc32e0db 100644 --- a/v2/robotmk/src/bin/scheduler/scheduling/cleanup.rs +++ b/v2/robotmk/src/bin/scheduler/scheduling/cleanup.rs @@ -13,7 +13,7 @@ pub fn cleanup_working_directories<'a>(suites: impl Iterator) for suite in suites { debug!( "Cleaning up working directory {} of suite {}", - suite.working_directory, suite.name + suite.working_directory, suite.id ); let _ = cleanup_working_directory( &suite.working_directory, @@ -21,7 +21,7 @@ pub fn cleanup_working_directories<'a>(suites: impl Iterator) ) .context(format!( "Error while cleaning up working directory of suite {}", - suite.name + suite.id )) .map_err(log_and_return_error); } diff --git a/v2/robotmk/src/bin/scheduler/scheduling/scheduler.rs b/v2/robotmk/src/bin/scheduler/scheduling/scheduler.rs index 76dfbc55..4d93c346 100644 --- a/v2/robotmk/src/bin/scheduler/scheduling/scheduler.rs +++ b/v2/robotmk/src/bin/scheduler/scheduling/scheduler.rs @@ -49,7 +49,7 @@ fn wait_until_all_suites_have_terminated(suites: &[Suite]) { let mut still_running = vec![]; for suite in still_running_suites { let _ = try_acquire_suite_lock(suite).map_err(|_| { - error!("Suite {} is still running", suite.name); + error!("Suite {} is still running", suite.id); still_running.push(suite) }); } diff --git a/v2/robotmk/src/bin/scheduler/scheduling/suites.rs b/v2/robotmk/src/bin/scheduler/scheduling/suites.rs index 0dd6b27c..1cbcf521 100644 --- a/v2/robotmk/src/bin/scheduler/scheduling/suites.rs +++ b/v2/robotmk/src/bin/scheduler/scheduling/suites.rs @@ -18,7 +18,7 @@ pub fn run_suite(suite: &Suite) -> Result<()> { // We hold the lock as long as `_non_parallel_guard` is in scope let _non_parallel_guard = try_acquire_suite_lock(suite).map_err(|err| { let report = SuiteExecutionReport { - suite_name: suite.name.clone(), + suite_id: suite.id.clone(), outcome: ExecutionReport::AlreadyRunning, }; report @@ -32,9 +32,9 @@ pub fn run_suite(suite: &Suite) -> Result<()> { .unwrap_or(err) })?; - debug!("Running suite {}", &suite.name); + debug!("Running suite {}", &suite.id); let report = SuiteExecutionReport { - suite_name: suite.name.clone(), + suite_id: suite.id.clone(), outcome: ExecutionReport::Executed(produce_suite_results(suite)?), }; report @@ -44,7 +44,7 @@ pub fn run_suite(suite: &Suite) -> Result<()> { &suite.results_directory_locker, ) .context("Reporting suite results failed")?; - debug!("Suite {} finished", &suite.name); + debug!("Suite {} finished", &suite.id); Ok(()) } @@ -56,11 +56,11 @@ pub fn try_acquire_suite_lock(suite: &Suite) -> Result> { TryLockError::WouldBlock => { bail!( "Failed to acquire lock for suite {}, skipping this run", - suite.name + suite.id ); } TryLockError::Poisoned(poison_error) => { - error!("Lock for suite {} poisoned, unpoisoning", suite.name); + error!("Lock for suite {} poisoned, unpoisoning", suite.id); Ok(poison_error.into_inner()) } }, @@ -129,10 +129,10 @@ fn run_attempt( attempt: Attempt, output_directory: &Utf8Path, ) -> Result<(AttemptOutcome, Option)> { - let log_message_start = format!("Suite {}, attempt {}", suite.name, attempt.index); + let log_message_start = format!("Suite {}, attempt {}", suite.id, attempt.index); let run_outcome = match suite.session.run(&RunSpec { - id: &format!("robotmk_suite_{}_attempt_{}", suite.name, attempt.index), + id: &format!("robotmk_suite_{}_attempt_{}", suite.id, attempt.index), command_spec: &suite.environment.wrap(attempt.command_spec), base_path: &output_directory.join(attempt.index.to_string()), timeout: suite.timeout, diff --git a/v2/robotmk/src/bin/scheduler/setup/general.rs b/v2/robotmk/src/bin/scheduler/setup/general.rs index d2836adc..f21cc0d2 100644 --- a/v2/robotmk/src/bin/scheduler/setup/general.rs +++ b/v2/robotmk/src/bin/scheduler/setup/general.rs @@ -18,7 +18,7 @@ fn setup_working_directories(working_directory: &Utf8Path, suites: &[Suite]) -> for suite in suites { create_dir_all(&suite.working_directory).context(format!( "Failed to create working directory {} of suite {}", - suite.working_directory, suite.name + suite.working_directory, suite.id ))?; } create_dir_all(environment_building_stdio_directory(working_directory)) diff --git a/v2/robotmk/src/bin/scheduler/setup/rcc.rs b/v2/robotmk/src/bin/scheduler/setup/rcc.rs index 7d98367c..eaaea774 100644 --- a/v2/robotmk/src/bin/scheduler/setup/rcc.rs +++ b/v2/robotmk/src/bin/scheduler/setup/rcc.rs @@ -1,7 +1,7 @@ use super::icacls::run_icacls_command; use crate::command_spec::CommandSpec; use crate::environment::Environment; -use crate::internal_config::{sort_suites_by_name, GlobalConfig, Suite}; +use crate::internal_config::{sort_suites_by_id, GlobalConfig, Suite}; use crate::logging::log_and_return_error; use crate::results::RCCSetupFailures; use crate::sessions::session::{CurrentSession, RunOutcome, RunSpec, Session}; @@ -24,7 +24,7 @@ pub fn setup(global_config: &GlobalConfig, suites: Vec) -> Result) -> Result) -> Result) -> Result) -> Result