Skip to content

Commit ef2ed55

Browse files
DAG-1899 Randomize test order when creating all resmoke sub-tasks (#40)
1 parent 7b08730 commit ef2ed55

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.4.5 - 2022-07-01
4+
5+
* Randomize test order when creating all resmoke sub-tasks.
6+
37
## 0.4.4 - 2022-06-30
48

59
* Randomize test order when creating sub-tasks and historic runtime information is not available.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mongo-task-generator"
3-
version = "0.4.4"
3+
version = "0.4.5"
44
repository = "https://github.com/mongodb/mongo-task-generator"
55
authors = ["Decision Automation Group <[email protected]>"]
66
edition = "2018"

src/task_types/resmoke_tasks.rs

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ impl GenResmokeTaskServiceImpl {
489489
}
490490
}
491491

492+
test_list.shuffle(&mut thread_rng());
493+
492494
Ok(test_list)
493495
}
494496

@@ -513,8 +515,7 @@ impl GenResmokeTaskServiceImpl {
513515
multiversion_tags: Option<String>,
514516
) -> Result<Vec<SubSuite>> {
515517
let origin_suite = multiversion_name.unwrap_or(&params.suite_name);
516-
let mut test_list = self.get_test_list(params, multiversion_name)?;
517-
test_list.shuffle(&mut thread_rng());
518+
let test_list = self.get_test_list(params, multiversion_name)?;
518519
let n_suites = min(test_list.len(), self.config.n_suites);
519520
let tasks_per_suite = test_list.len() / n_suites;
520521

@@ -1088,7 +1089,8 @@ mod tests {
10881089
// a single test. The second 2 tests and the third 3 tests. We will set the test runtimes
10891090
// to make this happen.
10901091
let n_suites = 3;
1091-
let test_list: Vec<String> = (0..6)
1092+
let n_tests = 6;
1093+
let test_list: Vec<String> = (0..n_tests)
10921094
.into_iter()
10931095
.map(|i| format!("test_{}.js", i))
10941096
.collect();
@@ -1103,8 +1105,13 @@ mod tests {
11031105
"test_5".to_string() => build_mock_test_runtime("test_5.js", 34.0),
11041106
},
11051107
};
1106-
let gen_resmoke_service =
1107-
build_mocked_service(test_list, task_history.clone(), n_suites, vec![], vec![]);
1108+
let gen_resmoke_service = build_mocked_service(
1109+
test_list.clone(),
1110+
task_history.clone(),
1111+
n_suites,
1112+
vec![],
1113+
vec![],
1114+
);
11081115

11091116
let params = ResmokeGenParams {
11101117
..Default::default()
@@ -1115,15 +1122,14 @@ mod tests {
11151122
.unwrap();
11161123

11171124
assert_eq!(sub_suites.len(), n_suites);
1118-
let suite_0 = &sub_suites[0];
1119-
assert!(suite_0.test_list.contains(&"test_0.js".to_string()));
1120-
let suite_1 = &sub_suites[1];
1121-
assert!(suite_1.test_list.contains(&"test_1.js".to_string()));
1122-
assert!(suite_1.test_list.contains(&"test_2.js".to_string()));
1123-
let suite_2 = &sub_suites[2];
1124-
assert!(suite_2.test_list.contains(&"test_3.js".to_string()));
1125-
assert!(suite_2.test_list.contains(&"test_4.js".to_string()));
1126-
assert!(suite_2.test_list.contains(&"test_5.js".to_string()));
1125+
let all_tests: Vec<String> = sub_suites
1126+
.iter()
1127+
.flat_map(|s| s.test_list.clone())
1128+
.collect();
1129+
assert_eq!(all_tests.len(), n_tests);
1130+
for test_name in test_list {
1131+
assert!(all_tests.contains(&test_name.to_string()));
1132+
}
11271133
}
11281134

11291135
#[test]
@@ -1216,8 +1222,13 @@ mod tests {
12161222
task_name: "my task".to_string(),
12171223
test_map: hashmap! {},
12181224
};
1219-
let gen_resmoke_service =
1220-
build_mocked_service(test_list, task_history.clone(), n_suites, vec![], vec![]);
1225+
let gen_resmoke_service = build_mocked_service(
1226+
test_list.clone(),
1227+
task_history.clone(),
1228+
n_suites,
1229+
vec![],
1230+
vec![],
1231+
);
12211232

12221233
let params = ResmokeGenParams {
12231234
..Default::default()
@@ -1237,6 +1248,9 @@ mod tests {
12371248
.flat_map(|s| s.test_list.clone())
12381249
.collect();
12391250
assert_eq!(all_tests.len(), n_tests);
1251+
for test_name in test_list {
1252+
assert!(all_tests.contains(&test_name.to_string()));
1253+
}
12401254
}
12411255

12421256
// tests for get_test_list.

0 commit comments

Comments
 (0)