diff --git a/CHANGELOG.md b/CHANGELOG.md index 9feb7b6..a03d4d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## 0.7.22 - 2025-01-22 +* Avoid a division-by-zero when processing empty suites. + ## 0.7.21 - 2025-01-16 * Add additional logging for task generation that takes a long time. diff --git a/Cargo.lock b/Cargo.lock index 67a1b19..c8a2e8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "mongo-task-generator" -version = "0.7.21" +version = "0.7.22" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index e5dbbe9..4a64dbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mongo-task-generator" description = "Dynamically split evergreen tasks into subtasks for testing the mongodb/mongo project." license = "Apache-2.0" -version = "0.7.21" +version = "0.7.22" repository = "https://github.com/mongodb/mongo-task-generator" authors = ["Decision Automation Group "] edition = "2018" diff --git a/src/task_types/resmoke_tasks.rs b/src/task_types/resmoke_tasks.rs index 4b90660..999ae83 100644 --- a/src/task_types/resmoke_tasks.rs +++ b/src/task_types/resmoke_tasks.rs @@ -509,12 +509,16 @@ impl GenResmokeTaskServiceImpl { multiversion_name: Option<&str>, multiversion_tags: Option, ) -> Result> { + let mut sub_suites = vec![]; + let origin_suite = multiversion_name.unwrap_or(¶ms.suite_name); let test_list = self.get_test_list(params, multiversion_name)?; + if test_list.is_empty() { + return Ok(sub_suites); + } let n_suites = min(test_list.len(), self.config.n_suites); let tasks_per_suite = test_list.len() / n_suites; - let mut sub_suites = vec![]; let mut current_tests = vec![]; let mut i = 0; for test in test_list { @@ -1306,6 +1310,28 @@ mod tests { } } + #[test] + fn test_split_task_fallback_empty_suite() { + let n_suites = 1; + let test_list = vec![]; + let task_history = TaskRuntimeHistory { + task_name: "my task".to_string(), + test_map: hashmap! {}, + }; + let gen_resmoke_service = + build_mocked_service(test_list.clone(), task_history.clone(), n_suites); + + let params = ResmokeGenParams { + ..Default::default() + }; + + let sub_suites = gen_resmoke_service + .split_task_fallback(¶ms, None, None) + .unwrap(); + + assert_eq!(sub_suites.len(), 0); + } + // tests for get_test_list. #[rstest] #[case(true, 12)]