Skip to main content

Testing Guide

Version française : ../../fr/guides/testing.md

This guide shows how to test an agent, a skill, a plugin or a pack before it is deployed, and how the platform checks its own API, contracts and documentation. Who: developers and release managers. Every test below fails when a tool it needs is missing: nothing is skipped silently.

Functional​

Every project template holds its pytest tests; evaluation suites run through POST /v1/evaluations/runs and the quality gate through POST /v1/evaluations/gates/check.

enterprise-ai test --suite regression --target agent/agt_ap@1.4.0

Screens: Quality > Evaluation suites defines the suites and their metrics, Quality > Evaluation runs shows each run and its scores, Quality > Quality gates shows the verdict that allows or blocks a deployment.

Security​

enterprise-ai test security starts a red team run and exits with code 1 above the threshold; enterprise-ai test authz runs the OPA and OpenFGA tests.

enterprise-ai test security --threshold 0
enterprise-ai test authz

The red team engine is builtin by default; --engine garak and --probe <name> select another engine and probe. Screen: Quality > Red team.

Conformance and performance​

enterprise-ai test sdk-conformance checks the contracts/v1 contracts of the SDK against the endpoint. The API surface is checked by services/control-plane/tests/test_api_surface.py; the developer documentation by services/control-plane/tests/test_developer_guides.py, which also compiles the TypeScript, Go and Java snippets of the SDK guides. Performance is measured by the telemetry SLOs (GET /v1/telemetry/slo).

enterprise-ai test sdk-conformance

Procedures​

  1. Run the unit tests of your project. They prove the logic of the agent or the skill without calling the platform, so they run first and fast.

    python -m pytest -q tests

    Expected result: every test passes; the template tests cover the manifest and the policies it ships.

    If it fails: read the assertion message, fix the code, run the failing test alone.

  2. Run the authorization tests. They prove that the OPA policies and the OpenFGA model of the project allow what they should and refuse the rest.

    enterprise-ai test authz

    Expected result: exit code 0, every opa test and fga model test case passes.

    If it fails: exit code 1 names the failing case, or reports a missing opa or fga binary; install the binary and run the command again.

  3. Run the red team. It sends the attack probes of the red team engine to the agent and measures the rate of successful attacks.

    enterprise-ai test security --agent ticket-helper --threshold 0

    Expected result: exit code 0, the attack success rate is at or below --threshold.

    If it fails: exit code 1; open the run in Quality > Red team, fix the prompt, the policy or the tool scope that let the probe through, then run it again.

  4. Run an evaluation suite. It scores the answers of the agent against the metrics and targets of the suite.

    enterprise-ai test --suite regression --target agent/agt_ap@1.4.0

    regression: name of the suite; agent/agt_ap@1.4.0: the agent and version under test.

    Expected result: exit code 0, each metric meets its target.

    If it fails: exit code 1 with the metric below its target; 404 not_found means an unknown suite.

  5. Check the quality gate. The gate is what a deployment and a promotion read: the latest evaluation and red team results of the target.

    Screen: Quality > Quality gates. API: POST /v1/evaluations/gates/check.

    Expected result: the verdict allows the target.

    If it fails: 409 gate_failed lists every failing check in details.failures.

  6. Check the SDK conformance. It proves the SDK you use and the Control Plane agree on the contracts.

    enterprise-ai test sdk-conformance

    Expected result: exit code 0.

    If it fails: exit code 1 reports a contract mismatch; upgrade the SDK (see the Migration Guide).

  7. Run the platform checks (contributors). They prove the published API, the request surface and these guides match the code.

    cd services/control-plane
    .venv/bin/python -m pytest -q tests/test_api_surface.py tests/test_developer_guides.py tests/test_docs_kit.py

    Expected result: every test passes.

    If it fails: the assertion names the page and the route, command, setting or path that does not exist.

  8. Measure performance (operators). The load generator starts a throwaway PostgreSQL, a fake model upstream and the Control Plane on free ports of this host, then runs the scenarios and the quota checks; nothing is sent to a cluster or a cloud account.

    bash tools/perf/run.sh /tmp/eai-perf

    Expected result: the output folder holds the measurements; compare them with the SLOs of Observability > SLO and error budgets (GET /v1/telemetry/slo).

    If it fails: exit code 3 means the Control Plane virtualenv or redis-server is missing.

Running the tests of one repository unit (contributors)​

The repository is a monorepo: every unit (Control Plane, Manager, sector agents) has its own pyproject.toml and its own .venv virtualenv. The system python has none of the project packages: python -m pytest from the root fails at collection with ModuleNotFoundError: No module named 'navin_courtier' (or navin_rag, navin_compliance, eai). Two rules are enough.

  1. A test file runs with the virtualenv of its unit, from the unit folder. Never mix two units in one command: pytest would take the pyproject.toml of the first one as its rootdir.

    cd navin-enterprise-assurance-courtier-distribution/backend
    .venv/bin/python -m pytest -q tests/test_kpis_hardening.py

    Expected result: 2 passed.

  2. The Hub pipeline tests run with the system python3 and three external tools. opa is looked up on the PATH, then in OPA_BIN; yara_x and shellcheck are Python packages pinned by the Hub CI (shellcheck-py==0.11.0.1, yara-x==1.22.1). On a workstation where those tools live in /tmp/toolchains:

    env OPA_BIN=/tmp/toolchains/opa \
    PYTHONPATH=/tmp/toolchains/yarax-1.22.1-venv/lib/python3.12/site-packages \
    python3 -m pytest -q hub/pipeline/tests/test_pipeline_files.py -k "not shellcheck"

    Expected result: 57 passed, 1 deselected. Without -k, test_shellcheck_clean requires shellcheck to be installed; it then passes too (58 in total). The binaries in /tmp/toolchains vanish on reboot: an opa is required or No module named 'yara_x' failure after a reboot comes from that, not from the code.

UnitInterpreterRun fromExample
Control Planeservices/control-plane/.venv/bin/pythonservices/control-plane.venv/bin/python -m pytest -q tests/test_api_surface.py
Manager (server)navin-manager/server/.venv/bin/pythonnavin-manager/server.venv/bin/python -m pytest -q tests
RAG Agentnavin-enterprise-rag/backend/.venv/bin/pythonnavin-enterprise-rag/backend.venv/bin/python -m pytest -q -p no:cacheprovider tests/test_template_artifacts.py
Compliance & Auditnavin-enterprise-compliance/backend/.venv/bin/pythonnavin-enterprise-compliance/backend.venv/bin/python -m pytest -q -p no:cacheprovider tests/test_migrations.py
Banking back-officenavin-enterprise-banking-backoffice/backend/.venv/bin/pythonnavin-enterprise-banking-backoffice/backend.venv/bin/python -m pytest -q tests
Insurance agents (5 folders navin-enterprise-assurance-*)<folder>/backend/.venv/bin/python<folder>/backend.venv/bin/python -m pytest -q tests
Hub pipelinesystem python3 + OPA_BIN, yara_x, shellcheckrepository rootsee above
Contracts, packaging, tools (contracts/tests, sdks/tests, os/tests)services/control-plane/.venv/bin/pythonrepository rootservices/control-plane/.venv/bin/python -m pytest -q contracts/tests

Run the tests closest to your change, once, after the last edit; the full suite of a unit is the job of the CI.

Test tools​

NeedCommandUsed by
OCI, policy and observability toolsbash tools/oci/fetch.shpack tests, opa test, fga model test, trivy fs
Storage emulatorsbash tools/emulators/fetch.shservices/control-plane/tests/test_storage_s3_seaweedfs.py and the other storage tests
Pack interpreterbash packs/bootstrap.shpack test suites
Load testsbash tools/perf/run.shperformance and quota measurements

Troubleshooting​

SymptomCauseFix
enterprise-ai test authz exit code 1, binary not foundopa or fga missinginstall it (bash tools/oci/fetch.sh fetches pinned versions)
enterprise-ai test security exit code 1attack success rate above --thresholdfix the weakness, run again; never raise the threshold to pass
409 gate_failedan evaluation or red team result below targetread details.failures, fix, run the suite again
403 forbidden on an evaluation runrole missing (details.required_roles)ask for a role that may write evaluations
400 invalid_request with details.engineunknown red team engineuse builtin or garak
tools/perf/run.sh exit code 3virtualenv or redis-server missingcreate services/control-plane/.venv, install redis-server
ModuleNotFoundError: No module named 'navin_...' at pytest collectionsystem python instead of the unit virtualenvrun again with <unit>/.venv/bin/python -m pytest from the unit folder
pytest rootdir points at another backend than the one under testtwo units in one pytest commandone command per unit
opa is required, No module named 'yara_x', shellcheck is required in hub/pipeline/testsexternal tools missing from the PATH (or /tmp/toolchains emptied by a reboot)OPA_BIN=<opa path>, PYTHONPATH to a venv holding yara-x==1.22.1, pip install shellcheck-py==0.11.0.1

Next steps​