Skip to content

Commit 9a3f53f

Browse files
authored
DEVPROD-11978 pass --skipTestsCoveredByMoreComplexSuites flag to resmoke when generating tasks in a patch build. (#83)
1 parent b0eb390 commit 9a3f53f

File tree

6 files changed

+46
-4
lines changed

6 files changed

+46
-4
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.7.18 - 2024-10-11
4+
* DEVPROD-11978 use --skipTestsCoveredByMoreComplexSuites when generating tasks in a patch build.
5+
36
## 0.7.17 - 2024-10-09
47
* DEVPROD-11914 Update shrub-rs dependency that includes github.generate_token command
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
@@ -2,7 +2,7 @@
22
name = "mongo-task-generator"
33
description = "Dynamically split evergreen tasks into subtasks for testing the mongodb/mongo project."
44
license = "Apache-2.0"
5-
version = "0.7.17"
5+
version = "0.7.18"
66
repository = "https://github.com/mongodb/mongo-task-generator"
77
authors = ["Decision Automation Group <[email protected]>"]
88
edition = "2018"

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ pub struct ExecutionConfiguration<'a> {
136136
pub config_location: &'a str,
137137
/// Should burn_in tasks be generated.
138138
pub gen_burn_in: bool,
139+
/// True if the generator should skip tests covered by more complex suites.
140+
pub skip_covered_tests: bool,
139141
/// Command to execute burn_in_tests.
140142
pub burn_in_tests_command: &'a str,
141143
/// S3 endpoint to get test stats from.
@@ -163,7 +165,10 @@ impl Dependencies {
163165
/// A set of dependencies to run against.
164166
pub fn new(execution_config: ExecutionConfiguration) -> Result<Self> {
165167
let fs_service = Arc::new(FsServiceImpl::new());
166-
let discovery_service = Arc::new(ResmokeProxy::new(execution_config.resmoke_command));
168+
let discovery_service = Arc::new(ResmokeProxy::new(
169+
execution_config.resmoke_command,
170+
execution_config.skip_covered_tests,
171+
));
167172
let multiversion_service = Arc::new(MultiversionServiceImpl::new(
168173
discovery_service.get_multiversion_config()?,
169174
)?);

src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ struct EvgExpansions {
3131
pub task_name: String,
3232
/// ID of Evergreen version running.
3333
pub version_id: String,
34+
/// True if the patch is a patch build.
35+
#[serde(default, deserialize_with = "deserialize_bool_string")]
36+
pub is_patch: bool,
37+
/// True if we should NOT skip tests covered by more complex suites.
38+
#[serde(default, deserialize_with = "deserialize_bool_string")]
39+
pub run_covered_tests: bool,
40+
}
41+
42+
// The boolean YAML fields `is_patch` and `run_covered_tests` are set to the
43+
// string "true" rather than a boolean `true`. Therefore we need a custom
44+
// deserializer to convert from the string "true" to the boolean `true`, and
45+
// in all other cases return `false`.
46+
fn deserialize_bool_string<'de, D>(deserializer: D) -> Result<bool, D::Error>
47+
where
48+
D: serde::Deserializer<'de>,
49+
{
50+
let s: &str = serde::Deserialize::deserialize(deserializer)?;
51+
match s {
52+
"true" => Ok(true),
53+
_ => Ok(false),
54+
}
3455
}
3556

3657
impl EvgExpansions {
@@ -136,6 +157,7 @@ async fn main() {
136157
generating_task: &evg_expansions.task_name,
137158
config_location: &evg_expansions.config_location(),
138159
gen_burn_in: args.burn_in,
160+
skip_covered_tests: evg_expansions.is_patch && !evg_expansions.run_covered_tests,
139161
burn_in_tests_command: &args.burn_in_tests_command,
140162
s3_test_stats_endpoint: &args.s3_test_stats_endpoint,
141163
};

src/resmoke/resmoke_proxy.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub struct ResmokeProxy {
4141
resmoke_cmd: String,
4242
/// Script to invoke resmoke.
4343
resmoke_script: Vec<String>,
44+
/// True if the generator should skip tests already run in more complex suites.
45+
skip_covered_tests: bool,
4446
}
4547

4648
impl ResmokeProxy {
@@ -49,13 +51,15 @@ impl ResmokeProxy {
4951
/// # Arguments
5052
///
5153
/// * `resmoke_cmd` - Command to invoke resmoke.
52-
pub fn new(resmoke_cmd: &str) -> Self {
54+
/// * `skip_covered_tests` - Whether the generator should skip tests run in more complex suites.
55+
pub fn new(resmoke_cmd: &str, skip_covered_tests: bool) -> Self {
5356
let cmd_parts: Vec<_> = resmoke_cmd.split(' ').collect();
5457
let cmd = cmd_parts[0];
5558
let script = cmd_parts[1..].iter().map(|s| s.to_string()).collect();
5659
Self {
5760
resmoke_cmd: cmd.to_string(),
5861
resmoke_script: script,
62+
skip_covered_tests,
5963
}
6064
}
6165
}
@@ -85,6 +89,14 @@ impl TestDiscovery for ResmokeProxy {
8589
let mut cmd = vec![&*self.resmoke_cmd];
8690
cmd.append(&mut self.resmoke_script.iter().map(|s| s.as_str()).collect());
8791
cmd.append(&mut vec!["test-discovery", "--suite", suite_name]);
92+
93+
// When running in a patch build, we use the --skipTestsCoveredByMoreComplexSuites
94+
// flag to tell Resmoke to exclude any tests in the given suite that will
95+
// also be run on a more complex suite.
96+
if self.skip_covered_tests {
97+
cmd.append(&mut vec!["--skipTestsCoveredByMoreComplexSuites"]);
98+
}
99+
88100
let start = Instant::now();
89101
let cmd_output = run_command(&cmd).unwrap();
90102

0 commit comments

Comments
 (0)