Skip to content

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

test(storage): run e2e suites against each storage driver

Steven Enamakelf6eae6f54725
diff --git a/tests/storage_approvals_e2e.rs b/tests/storage_approvals_e2e.rs
index d51112f8de..0289cf3e4a 100644
--- a/tests/storage_approvals_e2e.rs
+++ b/tests/storage_approvals_e2e.rs
@@ -5,12 +5,16 @@
//! storage slot, which would reroute every other suite's approvals in a
//! shared process.
-use std::sync::Arc;
-
use openhuman_core::config::Config;
use openhuman_core::security::approval::store;
use openhuman_core::security::approval::types::{ApprovalDecision, PendingApproval};
+#[macro_use]
+#[path = "support/storage_drivers.rs"]
+mod storage_drivers;
+
+use storage_drivers::Case;
+
fn pending(id: &str) -> PendingApproval {
PendingApproval::new(
id,
@@ -21,14 +25,13 @@ fn pending(id: &str) -> PendingApproval {
)
}
-#[test]
-fn a_configured_backend_holds_the_approvals_instead_of_approval_db() {
+fn a_configured_backend_holds_the_approvals_instead_of_approval_db(case: Case) {
let workspace = tempfile::tempdir().unwrap();
let config = Config {
workspace_dir: workspace.path().to_path_buf(),
..Config::default()
};
- openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
+ case.install();
store::insert_pending(&config, &pending("r1"), "session").unwrap();
store::insert_flow_trust(&config, "flow-1", "shell").unwrap();
@@ -62,3 +65,5 @@ fn a_configured_backend_holds_the_approvals_instead_of_approval_db() {
.join("approval.db")
.exists());
}
+
+driver_cases!(sync a_configured_backend_holds_the_approvals_instead_of_approval_db);
diff --git a/tests/storage_domains_e2e.rs b/tests/storage_domains_e2e.rs
index 388e449980..b7119ce4b1 100644
--- a/tests/storage_domains_e2e.rs
+++ b/tests/storage_domains_e2e.rs
@@ -5,8 +5,6 @@
//! storage slot, which would reroute every other suite's stores in a shared
//! process. One test, so nothing in this binary races the slot either.
-use std::sync::Arc;
-
use chrono::Utc;
use openhuman_core::config::Config;
use openhuman_core::desktop::notifications::store as notifications;
@@ -16,6 +14,12 @@ use openhuman_core::integrations::task_sources::store as task_sources;
use openhuman_core::integrations::task_sources::types::{FilterSpec, ProviderSlug, SourceTarget};
use openhuman_core::security::devices::store as devices;
+#[macro_use]
+#[path = "support/storage_drivers.rs"]
+mod storage_drivers;
+
+use storage_drivers::Case;
+
fn notification(id: &str) -> IntegrationNotification {
IntegrationNotification {
id: id.to_string(),
@@ -33,14 +37,13 @@ fn notification(id: &str) -> IntegrationNotification {
}
}
-#[test]
-fn a_configured_backend_holds_devices_notifications_and_task_sources() {
+fn a_configured_backend_holds_devices_notifications_and_task_sources(case: Case) {
let workspace = tempfile::tempdir().unwrap();
let config = Config {
workspace_dir: workspace.path().to_path_buf(),
..Config::default()
};
- openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
+ case.install();
devices::insert_device(&config, "ch-1", "iPhone", "pk", "hash").unwrap();
assert_eq!(devices::list_devices(&config).unwrap().len(), 1);
@@ -95,3 +98,5 @@ fn a_configured_backend_holds_devices_notifications_and_task_sources() {
assert!(task_sources::list_sources(&config).unwrap().is_empty());
assert!(workspace.path().join("devices/devices.db").exists());
}
+
+driver_cases!(sync a_configured_backend_holds_devices_notifications_and_task_sources);
diff --git a/tests/storage_flows_e2e.rs b/tests/storage_flows_e2e.rs
index c6f626c58f..835ed408d9 100644
--- a/tests/storage_flows_e2e.rs
+++ b/tests/storage_flows_e2e.rs
@@ -5,22 +5,25 @@
//! storage slot, which would reroute every other suite's stores in a shared
//! process. One test, so nothing in this binary races the slot either.
-use std::sync::Arc;
-
use openhuman_core::config::Config;
use openhuman_core::cron::{self, Schedule};
use openhuman_core::flows;
use openhuman_core::flows::tinyflows::state::FlowState;
use serde_json::json;
-#[tokio::test(flavor = "multi_thread")]
-async fn a_configured_backend_holds_cron_flows_and_flow_state() {
+#[macro_use]
+#[path = "support/storage_drivers.rs"]
+mod storage_drivers;
+
+use storage_drivers::Case;
+
+async fn a_configured_backend_holds_cron_flows_and_flow_state(case: Case) {
let workspace = tempfile::tempdir().unwrap();
let config = Config {
workspace_dir: workspace.path().to_path_buf(),
..Config::default()
};
- openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
+ case.install();
// Cron: the store functions run on blocking threads, as the scheduler does.
let cron_config = config.clone();
@@ -125,3 +128,5 @@ async fn a_configured_backend_holds_cron_flows_and_flow_state() {
openhuman_core::agent::orchestration::open_delegation_checkpointer(&config).unwrap();
assert!(workspace.path().join("graph_checkpoints.db").exists());
}
+
+driver_cases!(async a_configured_backend_holds_cron_flows_and_flow_state);
diff --git a/tests/storage_secrets_e2e.rs b/tests/storage_secrets_e2e.rs
index ccc4572451..816f779197 100644
--- a/tests/storage_secrets_e2e.rs
+++ b/tests/storage_secrets_e2e.rs
@@ -6,14 +6,17 @@
//! reroute every other suite's secrets in a shared process. One test, so
//! nothing in this binary races either.
-use std::sync::Arc;
-
use openhuman_core::security::credentials::http_creds::{HttpCredential, HttpCredentialsStore};
use openhuman_core::security::credentials::profiles::{AuthProfile, AuthProfilesStore};
use openhuman_core::security::keyring;
-#[test]
-fn a_configured_backend_holds_keyring_and_credential_secrets() {
+#[macro_use]
+#[path = "support/storage_drivers.rs"]
+mod storage_drivers;
+
+use storage_drivers::Case;
+
+fn a_configured_backend_holds_keyring_and_credential_secrets(case: Case) {
let workspace = tempfile::tempdir().unwrap();
// Keep any process-backend fallback inside the temp workspace, and give
// the storage secrets a master key without touching an OS keychain.
@@ -42,7 +45,7 @@ fn a_configured_backend_holds_keyring_and_credential_secrets() {
.map(|f| (f, std::fs::read(workspace.path().join(f)).ok()))
.collect();
- openhuman_core::storage::install(Arc::new(openhuman_core::storage::MemoryStorage::new()));
+ case.install();
keyring::set("user-1", "api_token", "tok-123").unwrap();
assert_eq!(
@@ -104,3 +107,5 @@ fn a_configured_backend_holds_keyring_and_credential_secrets() {
assert!(http.get("legacy-http").unwrap().is_some());
assert_eq!(profiles.load().unwrap().profiles.len(), 1);
}
+
+driver_cases!(sync a_configured_backend_holds_keyring_and_credential_secrets);