From 564578bb20bfca45c4e5ea3ca8ef79d1edbd0397 Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Fri, 22 Mar 2024 18:33:19 +0000 Subject: [PATCH] feat: add toggle for load tests --- lib/bolt/config/src/ns.rs | 5 ++++- lib/bolt/core/src/tasks/test.rs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/bolt/config/src/ns.rs b/lib/bolt/config/src/ns.rs index 8c060377f1..fc26625671 100644 --- a/lib/bolt/config/src/ns.rs +++ b/lib/bolt/config/src/ns.rs @@ -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)] diff --git a/lib/bolt/core/src/tasks/test.rs b/lib/bolt/core/src/tasks/test.rs index 0bd525aa90..59e6a04961 100644 --- a/lib/bolt/core/src/tasks/test.rs +++ b/lib/bolt/core/src/tasks/test.rs @@ -85,6 +85,14 @@ pub async fn test_services>( } } + 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 @@ -95,10 +103,12 @@ pub async fn test_services>( .collect::>(); 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::>(); eprintln!(); rivet_term::status::progress("Preparing", format!("{} services", rust_svcs.len())); @@ -124,7 +134,7 @@ pub async fn test_services>( .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(