Skip to content

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

test(mcp_registry_e2e): isolate module storage per test

Steven Enamakel80237e0a5927
diff --git a/tests/mcp_registry_e2e.rs b/tests/mcp_registry_e2e.rs
index f55b8739e4..a368abc9ec 100644
--- a/tests/mcp_registry_e2e.rs
+++ b/tests/mcp_registry_e2e.rs
@@ -12,9 +12,21 @@ mod env_guard;
use openhuman_core::config::{schema::ModuleOverride, Config};
use serde_json::{json, Map, Value};
+static STORAGE_SETUP_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+static TEST_MASTER_KEY: std::sync::Once = std::sync::Once::new();
-fn fresh_workspace_config() -> (tempfile::TempDir, Config) {
+async fn fresh_workspace_config() -> (tempfile::TempDir, Config) {
+ TEST_MASTER_KEY.call_once(|| {
+ // This target owns a process-wide module callback and storage slot.
+ // Give the module host the same configured secret key as production.
+ std::env::set_var("OPENHUMAN_KEYRING_MASTER_KEY", "55".repeat(32));
+ std::env::remove_var("OPENHUMAN_KEYRING_MASTER_KEY_FILE");
+ });
env_guard::init_keyring_workspace();
+ let backend = openhuman_core::storage::open("memory")
+ .await
+ .expect("open isolated module storage backend");
+ openhuman_core::storage::install(backend);
let tmp = tempfile::tempdir().expect("tempdir");
let artifact = openhuman_core::modules::local_artifact("tinymcp")
.expect("build tinymcp with scripts/modules/build.mjs and set OPENHUMAN_MODULE_SOURCE_DIR");
@@ -79,7 +91,8 @@ fn http_server(url: &str) -> Value {
async fn disabled_server_accepts_environment_update_without_reconnecting() {
use std::collections::HashMap;
- let (_tmp, config) = fresh_workspace_config();
+ let _storage_lock = STORAGE_SETUP_LOCK.lock().await;
+ let (_tmp, config) = fresh_workspace_config().await;
let server_id = install_server(&config, "@openhuman-test/echo", stdio_server()).await;
let mut env = HashMap::new();
env.insert("API_KEY".to_owned(), "test-only-secret".to_owned());
@@ -102,14 +115,15 @@ async fn per_config_auth_failure_surfaces_401_reason_without_cross_workspace_lea
use wiremock::matchers::any;
use wiremock::{Mock, MockServer, ResponseTemplate};
+ let _storage_lock = STORAGE_SETUP_LOCK.lock().await;
let upstream = MockServer::start().await;
Mock::given(any())
.respond_with(ResponseTemplate::new(401))
.mount(&upstream)
.await;
- let (_tmp_a, config_a) = fresh_workspace_config();
- let (_tmp_b, config_b) = fresh_workspace_config();
+ let (_tmp_a, config_a) = fresh_workspace_config().await;
+ let (_tmp_b, config_b) = fresh_workspace_config().await;
let server_id = install_server(
&config_a,
"@openhuman-test/remote",