diff --git a/.gitea/workflows/ci-cd.yaml b/.gitea/workflows/ci-cd.yaml index 9fd2b29..8ee2b96 100644 --- a/.gitea/workflows/ci-cd.yaml +++ b/.gitea/workflows/ci-cd.yaml @@ -214,6 +214,19 @@ jobs: curl -fsS "http://$VPS_HOST:3100/health" curl -fsS "http://$VPS_HOST:3100/ready" + - name: Run VPS e2e tests + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' + env: + OPENBRAIN_E2E_REMOTE: "true" + OPENBRAIN_E2E_BASE_URL: http://${{ secrets.VPS_HOST }}:3100 + OPENBRAIN_E2E_API_KEY: ${{ secrets.OPENBRAIN_E2E_API_KEY }} + OPENBRAIN__AUTH__ENABLED: "true" + run: | + set -euxo pipefail + : "${OPENBRAIN_E2E_API_KEY:?Set repository secret OPENBRAIN_E2E_API_KEY}" + . "$HOME/.cargo/env" + cargo test --test e2e_mcp -- --test-threads=1 + - name: Cleanup SSH key if: always() run: | diff --git a/README.md b/README.md index c254d55..00bf5f9 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,24 @@ Run pending migrations explicitly before starting or restarting the service: If you use the deploy script or CI workflow in [`.gitea/deploy.sh`](/Users/bobbytables/ai/openbrain-mcp/.gitea/deploy.sh) and [`.gitea/workflows/ci-cd.yaml`](/Users/bobbytables/ai/openbrain-mcp/.gitea/workflows/ci-cd.yaml), they already run this for you. +### E2E Test Modes + +The end-to-end test suite supports two modes: + +- Local mode: default. Assumes the test process can manage schema setup against a local PostgreSQL instance and, for one auth-only test, spawn a local `openbrain-mcp` child process. +- Remote mode: set `OPENBRAIN_E2E_REMOTE=true` and point `OPENBRAIN_E2E_BASE_URL` at a deployed server such as `http://76.13.116.52:3100` or `https://ob.ingwaz.work`. In this mode the suite does not try to create schema locally and skips the local process auth smoke test. + +Recommended env for VPS-backed runs: + +```bash +OPENBRAIN_E2E_REMOTE=true +OPENBRAIN_E2E_BASE_URL=https://ob.ingwaz.work +OPENBRAIN_E2E_API_KEY=your_live_api_key +OPENBRAIN__AUTH__ENABLED=true +``` + +The CI workflow uses this remote mode after `main` deploys so e2e coverage validates the VPS deployment rather than the local runner host. + ## Agent Zero Developer Prompt For Agent Zero / A0, add the following section to the Developer agent role diff --git a/tests/e2e_mcp.rs b/tests/e2e_mcp.rs index 8003a55..3d2b178 100644 --- a/tests/e2e_mcp.rs +++ b/tests/e2e_mcp.rs @@ -8,6 +8,12 @@ fn base_url() -> String { std::env::var("OPENBRAIN_E2E_BASE_URL").unwrap_or_else(|_| "http://127.0.0.1:3100".to_string()) } +fn remote_mode() -> bool { + std::env::var("OPENBRAIN_E2E_REMOTE") + .map(|v| v == "true" || v == "1") + .unwrap_or(false) +} + fn api_key() -> Option { std::env::var("OPENBRAIN_E2E_API_KEY").ok() .or_else(|| std::env::var("OPENBRAIN__AUTH__API_KEYS").ok()) @@ -27,6 +33,10 @@ fn db_url() -> String { } async fn ensure_schema() { + if remote_mode() { + return; + } + let (client, connection) = tokio_postgres::connect(&db_url(), NoTls) .await .expect("connect to postgres for e2e schema setup"); @@ -891,6 +901,11 @@ async fn wait_for_status(url: &str, expected_status: reqwest::StatusCode) { #[tokio::test] async fn e2e_auth_enabled_accepts_test_key() { + if remote_mode() { + println!("Skipping local auth spawn test in OPENBRAIN_E2E_REMOTE mode"); + return; + } + ensure_schema().await; let port = pick_free_port();