Skip to content

Commit

Permalink
feat: add toggle for load tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Apr 4, 2024
1 parent 496b4bf commit 564578b
Show file tree
Hide file tree
Showing 2 changed files with 16 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 @@ -596,7 +596,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
14 changes: 12 additions & 2 deletions lib/bolt/core/src/tasks/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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 @@ -95,10 +103,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 @@ -124,7 +134,7 @@ 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 564578b

Please sign in to comment.