Skip to content

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

Merge pull request #7271 from senamakel/saas-isolation-memory

Steven Enamakela8fc01b65d79
diff --cc tests/saas_mode_e2e.rs
index 04d84f27d1,0f3f021d91..94139c95a3
--- a/tests/saas_mode_e2e.rs
+++ b/tests/saas_mode_e2e.rs
@@@ -9,13 -10,78 +9,17 @@@ use std::time::{Duration, Instant}
use serde_json::{json, Value};
+#[path = "saas_mode/support.rs"]
+mod support;
+use support::*;
+
#[path = "saas_mode/cluster.rs"]
mod cluster;
+ #[path = "saas_mode/memory.rs"]
+ mod memory;
+ #[path = "saas_mode/mock_memory.rs"]
+ mod mock_memory;
-const BEARER: &str = "saas-e2e-gateway-bearer-0123456789abcdef";
-
-/// Environment a developer machine may carry that would point the child at a
-/// single user, or that the boot guard refuses outright.
-const SCRUBBED_ENV: &[&str] = &[
- "OPENHUMAN_WORKSPACE",
- "OPENHUMAN_DEV_CONNECT",
- "OPENHUMAN_BACKEND_SESSION_TOKEN",
- "OPENHUMAN_BACKEND_API_KEY",
- "OPENHUMAN_CORE_TOKEN",
- "OPENHUMAN_APPROVAL_GATE",
- "OPENHUMAN_SANDBOX",
- "OPENHUMAN_MODE",
- "OPENHUMAN_STORAGE_URL",
- "OPENHUMAN_NODE_ID",
-];
-
-struct Deployment {
- tmp: tempfile::TempDir,
- root: PathBuf,
- config: PathBuf,
-}
-
-fn deployment(write_token: bool) -> Deployment {
- let tmp = tempfile::tempdir().expect("temp dir");
- let root = tmp.path().join("saas");
- std::fs::create_dir(&root).unwrap();
- set_mode(&root, 0o700);
- if write_token {
- let token = root.join("service.token");
- std::fs::write(&token, format!("{BEARER}\n")).unwrap();
- set_mode(&token, 0o600);
- }
- let config = tmp.path().join("operator.toml");
- std::fs::write(
- &config,
- format!("root = {:?}\n", root.display().to_string()),
- )
- .unwrap();
- Deployment { tmp, root, config }
-}
-
-#[cfg(unix)]
-fn set_mode(path: &Path, mode: u32) {
- use std::os::unix::fs::PermissionsExt;
- std::fs::set_permissions(path, std::fs::Permissions::from_mode(mode)).unwrap();
-}
-
-#[cfg(not(unix))]
-fn set_mode(_: &Path, _: u32) {}
-
-fn core_command(d: &Deployment, extra: &[&str]) -> Command {
- let mut cmd = Command::new(env!("CARGO_BIN_EXE_openhuman-core"));
- cmd.args(["run", "--mode", "saas", "--saas-config"])
- .arg(&d.config)
- .args(extra)
- // Keep the child away from the developer's real `~/.openhuman`.
- .env("HOME", d.tmp.path())
- .env("USERPROFILE", d.tmp.path());
- for var in SCRUBBED_ENV {
- cmd.env_remove(var);
- }
- cmd
-}
-
#[test]
fn an_unsafe_deployment_is_refused_before_it_binds() {
let d = deployment(false);