Skip to content

Commit

Permalink
feat: add toggle for load tests (#583)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Apr 18, 2024
1 parent 1ec0ba5 commit a78d682
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/bolt/config/src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@ impl Default for RivetLogin {

#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct RivetTest {}
pub struct RivetTest {
#[serde(default)]
pub load_tests: bool,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
Expand Down
17 changes: 15 additions & 2 deletions lib/bolt/core/src/tasks/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ pub async fn test_services<T: AsRef<str>>(
}
}

let run_load_tests = ctx
.ns()
.rivet
.test
.as_ref()
.map(|test| test.load_tests)
.unwrap_or_default();

// Resolve services
let svc_names = test_ctx
.svc_names
Expand All @@ -99,10 +107,12 @@ pub async fn test_services<T: AsRef<str>>(
.collect::<Vec<_>>();
let all_svcs = ctx.services_with_patterns(&svc_names).await;

// Find all services that are executables
let rust_svcs = all_svcs
.iter()
// Find all services that are executables
.filter(|svc_ctx| matches!(svc_ctx.config().runtime, RuntimeKind::Rust {}))
// Filter/include load tests
.filter(|svc_ctx| run_load_tests || !svc_ctx.config().service.load_test)
.collect::<Vec<_>>();
eprintln!();
rivet_term::status::progress("Preparing", format!("{} services", rust_svcs.len()));
Expand All @@ -128,7 +138,10 @@ pub async fn test_services<T: AsRef<str>>(
.or_insert_with(Vec::new);
workspace.push(svc.cargo_name().expect("no cargo name"));
}
ensure!(!svcs_by_workspace.is_empty(), "no matching services");
ensure!(
!svcs_by_workspace.is_empty(),
"no matching services (to run load tests set `rivet.test.load_tests = true`)"
);

// Run build
let test_binaries = cargo::cli::build_tests(
Expand Down

0 comments on commit a78d682

Please sign in to comment.