Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(cron): add coverage for cron client, ops, and scheduler

Steven Enamakel2abb682ba3ee
diff --git a/crates/openhuman-core/src/cron/client_tests.rs b/crates/openhuman-core/src/cron/client_tests.rs
index f9b4434bc0..4563e55b7b 100644
--- a/crates/openhuman-core/src/cron/client_tests.rs
+++ b/crates/openhuman-core/src/cron/client_tests.rs
@@ -1,12 +1 @@
use super::*;
-use std::time::Instant;
-
-#[tokio::test]
-async fn timing_probe() {
- let t = Instant::now();
- let _ = crate::modules::runtime::runtime().await.unwrap();
- eprintln!("runtime: {:?}", t.elapsed());
- let t = Instant::now();
- crate::modules::tinyflows::fixture_attach_for_probe().await.unwrap();
- eprintln!("attach: {:?}", t.elapsed());
-}
diff --git a/crates/openhuman-core/src/cron/ops_tests.rs b/crates/openhuman-core/src/cron/ops_tests.rs
index ad2f5eb71b..732852981b 100644
--- a/crates/openhuman-core/src/cron/ops_tests.rs
+++ b/crates/openhuman-core/src/cron/ops_tests.rs
@@ -202,6 +202,9 @@ fn update_rejects_expression_for_non_cron_schedule() {
fn add_once_creates_future_at_schedule() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
+ // The first call in a process starts the module runtime and attaches the
+ // module (seconds); take the baseline after it so only the call is timed.
+ list_jobs(&config).unwrap();
let before = chrono::Utc::now();
let job = add_once(&config, "5m", "echo hello").unwrap();
match job.schedule {
diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rs
index 599fa56911..297df0ccbd 100644
--- a/crates/openhuman-core/src/cron/scheduler_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs
@@ -236,6 +236,9 @@ async fn security_policy_block_halts_without_spending_the_retry_budget() {
"fixture must be read-only, or this test does not exercise the blocked path"
);
+ // The first call in a process starts the module runtime and attaches the
+ // module (seconds); warm it so the timing below measures retry sleeps only.
+ cron::list_jobs(&config).unwrap();
let started = std::time::Instant::now();
let (success, output) = execute_job_now(
&crate::core::runtime::DispatchCtx::ambient(),
diff --git a/crates/openhuman-core/src/modules/tinyflows.rs b/crates/openhuman-core/src/modules/tinyflows.rs
index 3c8c6f87e2..f9a7a326dd 100644
--- a/crates/openhuman-core/src/modules/tinyflows.rs
+++ b/crates/openhuman-core/src/modules/tinyflows.rs
@@ -44,7 +44,9 @@ pub(crate) fn disabled_message() -> String {
mod imp {
use super::{disabled_message, HOST_BUS_NAME, MODULE_ID};
use crate::config::Config;
- use crate::modules::{ops, runtime};
+ #[cfg(not(test))]
+ use crate::modules::ops;
+ use crate::modules::runtime;
use tinybus::{ObjectPath, Proxy};
use tinyflows_bus::schedule;
@@ -152,11 +154,6 @@ mod imp {
});
}
- #[cfg(test)]
- pub(crate) async fn fixture_attach_for_probe() -> Result<(), String> {
- fixture::attach().await
- }
-
/// The tinyflows module linked into the test binary.
#[cfg(test)]
pub(crate) mod fixture {
@@ -185,8 +182,6 @@ mod imp {
#[cfg(feature = "modules")]
pub(crate) use imp::{proxy, run_proxy, serve, unserve};
-#[cfg(all(test, feature = "modules"))]
-pub(crate) use imp::fixture_attach_for_probe;
#[cfg(not(feature = "modules"))]
mod imp {