Skip to content

Commit a6b5ab1

Browse files
authored
DAG-1987: Remove _misc sub-task creation for generated tasks (#50)
1 parent db9a512 commit a6b5ab1

File tree

10 files changed

+48
-134
lines changed

10 files changed

+48
-134
lines changed

CHANGELOG.md

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

3+
## 0.6.3 - 2022-10-07
4+
* Remove _misc task generation.
5+
36
## 0.6.2 - 2022-09-14
47
* Propogate up errors when calling resmoke.
58

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.6.2"
3+
version = "0.6.3"
44
repository = "https://github.com/mongodb/mongo-task-generator"
55
authors = ["Decision Automation Group <[email protected]>"]
66
edition = "2018"

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async fn main() {
129129
let result = generate_configuration(&deps, &args.target_directory).await;
130130
event!(
131131
Level::INFO,
132-
"generation completed: {} seconds",
132+
"generation completed: {duration_secs} seconds",
133133
duration_secs = start.elapsed().as_secs()
134134
);
135135
if let Err(err) = result {

src/task_types/burn_in_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl BurnInServiceImpl {
235235
let origin_suite = suite_info.build_origin_suite(&params.suite_name);
236236

237237
let sub_suite = SubSuite {
238-
index: Some(index),
238+
index,
239239
name: suite_info.build_display_name(),
240240
test_list: vec![test.to_string()],
241241
exclude_test_list: None,

src/task_types/fuzzer_tasks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn build_fuzzer_sub_task(
272272
) -> EvgTask {
273273
let sub_task_name = name_generated_task(
274274
display_name,
275-
Some(sub_task_index),
275+
sub_task_index,
276276
params.num_tasks as usize,
277277
params.is_enterprise,
278278
params.platform.as_deref(),

src/task_types/resmoke_config_writer.rs

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ impl WriteConfigActorImpl {
121121
// Create suite files for all the sub-suites.
122122
self.write_sub_suites(&suite_info.sub_suites, &mut resmoke_config_cache)?;
123123

124-
// Create a suite file for the '_misc' sub-task.
125-
self.write_misc_suites(&suite_info.sub_suites, &mut resmoke_config_cache)?;
126-
127124
Ok(())
128125
}
129126

@@ -166,46 +163,6 @@ impl WriteConfigActorImpl {
166163
results?;
167164
Ok(())
168165
}
169-
170-
/// Write resmoke configurations for a "_misc" suite.
171-
///
172-
/// # Arguments
173-
///
174-
/// * `sub_suites` - List of sub-suites comprising the generated suite.
175-
/// * `resmoke_config_cache` - Cache to get resmoke suite configurations.
176-
fn write_misc_suites(
177-
&self,
178-
sub_suites: &[SubSuite],
179-
resmoke_config_cache: &mut ResmokeConfigCache,
180-
) -> Result<()> {
181-
let total_tasks = sub_suites.len();
182-
let results: Result<Vec<()>> = sub_suites
183-
.iter()
184-
.filter(|s| s.exclude_test_list.is_some())
185-
.map(|s| {
186-
let origin_config = resmoke_config_cache.get_config(&s.origin_suite)?;
187-
let test_list = s.exclude_test_list.clone().unwrap();
188-
let misc_config = origin_config.with_new_tests(None, Some(&test_list));
189-
let filename = format!(
190-
"{}.yml",
191-
name_generated_task(
192-
&s.name,
193-
s.index,
194-
total_tasks,
195-
s.is_enterprise,
196-
s.platform.as_deref()
197-
)
198-
);
199-
let mut path = PathBuf::from(&self.target_dir);
200-
path.push(filename);
201-
self.fs_service
202-
.write_file(&path, &misc_config.to_string())?;
203-
Ok(())
204-
})
205-
.collect();
206-
results?;
207-
Ok(())
208-
}
209166
}
210167

211168
#[async_trait]
@@ -446,35 +403,26 @@ mod tests {
446403
generate_multiversion_combos: false,
447404
sub_suites: vec![
448405
SubSuite {
449-
index: Some(0),
406+
index: 0,
450407
name: "suite_name".to_string(),
451408
origin_suite: "suite".to_string(),
452409
test_list: vec!["test_0.js".to_string(), "test_1.js".to_string()],
453410
..Default::default()
454411
},
455412
SubSuite {
456-
index: Some(1),
413+
index: 1,
457414
name: "suite_name".to_string(),
458415
origin_suite: "suite".to_string(),
459416
test_list: vec!["test_2.js".to_string(), "test_3.js".to_string()],
460417
..Default::default()
461418
},
462-
SubSuite {
463-
index: None,
464-
name: "suite_name".to_string(),
465-
origin_suite: "suite".to_string(),
466-
test_list: vec![],
467-
exclude_test_list: Some((0..4).map(|i| format!("test_{}.js", i)).collect()),
468-
..Default::default()
469-
},
470419
],
471420
};
472421

473422
resmoke_config_actor.write_suite_files(suite_info);
474423

475424
assert_eq!(fs_service.get_call_counts("target/suite_name_0.yml"), 1);
476425
assert_eq!(fs_service.get_call_counts("target/suite_name_1.yml"), 1);
477-
assert_eq!(fs_service.get_call_counts("target/suite_name_misc.yml"), 1);
478426
}
479427

480428
#[tokio::test]
@@ -489,14 +437,14 @@ mod tests {
489437
generate_multiversion_combos: false,
490438
sub_suites: vec![
491439
SubSuite {
492-
index: Some(0),
440+
index: 0,
493441
name: "suite".to_string(),
494442
origin_suite: "suite".to_string(),
495443
test_list: vec!["test_0.js".to_string(), "test_1.js".to_string()],
496444
..Default::default()
497445
},
498446
SubSuite {
499-
index: Some(1),
447+
index: 1,
500448
name: "suite".to_string(),
501449
origin_suite: "suite".to_string(),
502450
test_list: vec!["test_2.js".to_string(), "test_3.js".to_string()],

src/task_types/resmoke_tasks.rs

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
//! This service will query the historic runtime of tests in the given task and then
44
//! use that information to divide the tests into sub-suites that can be run in parallel.
55
//!
6-
//! Each task will contain the generated sub-suites and a '_misc' suite. The '_misc' suite
7-
//! tries to run all the tests for the original suite minus tests that were added to generated
8-
//! suites. This catches tests that were not included in the historic runtime data. For example,
9-
//! newly added tests that have not yet be run.
6+
//! Each task will contain the generated sub-suites.
107
use std::{cmp::min, collections::HashMap, sync::Arc};
118

129
use anyhow::Result;
@@ -181,8 +178,8 @@ impl ResmokeGenParams {
181178
/// Representation of generated sub-suite.
182179
#[derive(Clone, Debug, Default)]
183180
pub struct SubSuite {
184-
/// Index value of generated suite (None for the '_misc' sub-task).
185-
pub index: Option<usize>,
181+
/// Index value of generated suite.
182+
pub index: usize,
186183

187184
/// Name of generated sub-suite.
188185
pub name: String,
@@ -443,7 +440,7 @@ impl GenResmokeTaskServiceImpl {
443440
let mut sub_suites = vec![];
444441
for (i, slice) in running_tests.iter().enumerate() {
445442
sub_suites.push(SubSuite {
446-
index: Some(i),
443+
index: i,
447444
name: multiversion_name.unwrap_or(&params.task_name).to_string(),
448445
test_list: slice.clone(),
449446
origin_suite: origin_suite.to_string(),
@@ -481,10 +478,7 @@ impl GenResmokeTaskServiceImpl {
481478

482479
if !params.is_enterprise {
483480
if let Some(enterprise_dir) = &self.config.enterprise_dir {
484-
test_list = test_list
485-
.into_iter()
486-
.filter(|s| !s.starts_with(enterprise_dir))
487-
.collect();
481+
test_list.retain(|s| !s.starts_with(enterprise_dir));
488482
}
489483
}
490484

@@ -525,7 +519,7 @@ impl GenResmokeTaskServiceImpl {
525519
current_tests.push(test);
526520
if current_tests.len() >= tasks_per_suite {
527521
sub_suites.push(SubSuite {
528-
index: Some(i),
522+
index: i,
529523
name: multiversion_name.unwrap_or(&params.task_name).to_string(),
530524
test_list: current_tests,
531525
origin_suite: origin_suite.to_string(),
@@ -541,7 +535,7 @@ impl GenResmokeTaskServiceImpl {
541535

542536
if !current_tests.is_empty() {
543537
sub_suites.push(SubSuite {
544-
index: Some(i),
538+
index: i,
545539
name: multiversion_name.unwrap_or(&params.task_name).to_string(),
546540
test_list: current_tests,
547541
origin_suite: origin_suite.to_string(),
@@ -614,8 +608,7 @@ impl GenResmokeTaskServiceImpl {
614608
multiversion_name: Option<&str>,
615609
multiversion_tags: Option<String>,
616610
) -> Result<Vec<SubSuite>> {
617-
let origin_suite = multiversion_name.unwrap_or(&params.suite_name);
618-
let mut sub_suites = if self.config.use_task_split_fallback {
611+
let sub_suites = if self.config.use_task_split_fallback {
619612
self.split_task_fallback(params, multiversion_name, multiversion_tags.clone())?
620613
} else {
621614
let task_history = self
@@ -643,22 +636,6 @@ impl GenResmokeTaskServiceImpl {
643636
}
644637
};
645638

646-
// Add a `_misc` sub-task to the list of tasks.
647-
let full_test_list: Vec<String> = sub_suites
648-
.iter()
649-
.flat_map(|s| s.test_list.clone())
650-
.collect();
651-
sub_suites.push(SubSuite {
652-
index: None,
653-
name: multiversion_name.unwrap_or(&params.task_name).to_string(),
654-
test_list: vec![],
655-
origin_suite: origin_suite.to_string(),
656-
exclude_test_list: Some(full_test_list),
657-
mv_exclude_tags: multiversion_tags,
658-
is_enterprise: params.is_enterprise,
659-
platform: params.platform.clone(),
660-
});
661-
662639
Ok(sub_suites)
663640
}
664641
}
@@ -1408,14 +1385,14 @@ mod tests {
14081385
let version_combos = vec!["new_new_new".to_string(), "old_new_old".to_string()];
14091386
let sub_suites = vec![
14101387
SubSuite {
1411-
index: Some(0),
1388+
index: 0,
14121389
name: "suite".to_string(),
14131390
origin_suite: "suite".to_string(),
14141391
test_list: vec!["test_0.js".to_string(), "test_1.js".to_string()],
14151392
..Default::default()
14161393
},
14171394
SubSuite {
1418-
index: Some(1),
1395+
index: 1,
14191396
name: "suite".to_string(),
14201397
origin_suite: "suite".to_string(),
14211398
test_list: vec!["test_2.js".to_string(), "test_3.js".to_string()],
@@ -1431,7 +1408,12 @@ mod tests {
14311408
test_map: hashmap! {},
14321409
};
14331410
let gen_resmoke_service = build_mocked_service(
1434-
vec![],
1411+
vec![
1412+
"test_0.js".to_string(),
1413+
"test_1.js".to_string(),
1414+
"test_2.js".to_string(),
1415+
"test_3.js".to_string(),
1416+
],
14351417
task_history,
14361418
1,
14371419
old_version.clone(),
@@ -1490,7 +1472,7 @@ mod tests {
14901472
.unwrap();
14911473

14921474
assert_eq!(suite.display_name(), "my_task".to_string());
1493-
assert_eq!(suite.sub_tasks().len(), n_suites + 1); // +1 for _misc suite.
1475+
assert_eq!(suite.sub_tasks().len(), n_suites);
14941476
}
14951477

14961478
// resmoke_commands tests.

src/utils/task_name.rs

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const GEN_SUFFIX: &str = "_gen";
1414
/// * `platform` - Platform that task will run on.
1515
pub fn name_generated_task(
1616
display_name: &str,
17-
sub_task_index: Option<usize>,
17+
sub_task_index: usize,
1818
total_tasks: usize,
1919
is_enterprise: bool,
2020
platform: Option<&str>,
@@ -29,18 +29,14 @@ pub fn name_generated_task(
2929
suffix = format!("-{}{}", platform, suffix)
3030
}
3131

32-
if let Some(index) = sub_task_index {
33-
let alignment = (total_tasks as f64).log10().ceil() as usize;
34-
format!(
35-
"{}_{:0fill$}{}",
36-
display_name,
37-
index,
38-
suffix,
39-
fill = alignment
40-
)
41-
} else {
42-
format!("{}_misc{}", display_name, suffix)
43-
}
32+
let alignment = (total_tasks as f64).log10().ceil() as usize;
33+
format!(
34+
"{}_{:0fill$}{}",
35+
display_name,
36+
sub_task_index,
37+
suffix,
38+
fill = alignment
39+
)
4440
}
4541

4642
/// Remove the '_gen' from end of the given task name if it exists.
@@ -67,32 +63,17 @@ mod tests {
6763
use rstest::*;
6864

6965
#[rstest]
70-
#[case("task", Some(0), 10, false, None, "task_0")]
71-
#[case("task", Some(0), 10, false, Some("linux"), "task_0-linux")]
72-
#[case("task", Some(42), 1001, false, None, "task_0042")]
73-
#[case("task", Some(42), 1001, false, Some("linux"), "task_0042-linux")]
74-
#[case("task", None, 1001, false, None, "task_misc")]
75-
#[case("task", None, 1001, false, Some("linux"), "task_misc-linux")]
76-
#[case("task", None, 0, false, None, "task_misc")]
77-
#[case("task", None, 0, false, Some("linux"), "task_misc-linux")]
78-
#[case("task", Some(0), 10, true, None, "task_0-enterprise")]
79-
#[case("task", Some(0), 10, true, Some("linux"), "task_0-linux-enterprise")]
80-
#[case("task", Some(42), 1001, true, None, "task_0042-enterprise")]
81-
#[case(
82-
"task",
83-
Some(42),
84-
1001,
85-
true,
86-
Some("linux"),
87-
"task_0042-linux-enterprise"
88-
)]
89-
#[case("task", None, 1001, true, None, "task_misc-enterprise")]
90-
#[case("task", None, 1001, true, Some("linux"), "task_misc-linux-enterprise")]
91-
#[case("task", None, 0, true, None, "task_misc-enterprise")]
92-
#[case("task", None, 0, true, Some("linux"), "task_misc-linux-enterprise")]
66+
#[case("task", 0, 10, false, None, "task_0")]
67+
#[case("task", 0, 10, false, Some("linux"), "task_0-linux")]
68+
#[case("task", 42, 1001, false, None, "task_0042")]
69+
#[case("task", 42, 1001, false, Some("linux"), "task_0042-linux")]
70+
#[case("task", 0, 10, true, None, "task_0-enterprise")]
71+
#[case("task", 0, 10, true, Some("linux"), "task_0-linux-enterprise")]
72+
#[case("task", 42, 1001, true, None, "task_0042-enterprise")]
73+
#[case("task", 42, 1001, true, Some("linux"), "task_0042-linux-enterprise")]
9374
fn test_name_generated_task_should_not_include_suffix(
9475
#[case] name: &str,
95-
#[case] index: Option<usize>,
76+
#[case] index: usize,
9677
#[case] total: usize,
9778
#[case] is_enterprise: bool,
9879
#[case] platform: Option<&str>,

tests/integration_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn test_end2end_execution() {
2929
assert!(tmp_dir_path.exists());
3030

3131
let files = std::fs::read_dir(tmp_dir_path).unwrap();
32-
assert_eq!(2647, files.into_iter().collect::<Vec<_>>().len());
32+
assert_eq!(2206, files.into_iter().collect::<Vec<_>>().len());
3333
}
3434

3535
#[test]

0 commit comments

Comments
 (0)