# OPC Gateway end-to-end tests End-to-end tests run every external dependency for real (MongoDB, Redis, PostgreSQL, MinIO and NATS via testcontainers; OPC UA servers in process with asyncua) and build each gateway pod from the environment exactly like `ingestor/app.py` does. ## Requirements - Docker (for testcontainers), with the reaper disabled once per machine: `echo "ryuk.disabled=true" >> ~/.testcontainers.properties` (see [scenarios.md](scenarios.md)). - Python dev dependencies: `pip install -r requirements.txt -r requirements-dev.txt` ## Run locally ```bash source ./venv/bin/activate pytest e2e/ -o testpaths=e2e -m integration ``` One topic, or stop on first failure: ```bash pytest e2e/test_writes.py -o testpaths=e2e -m integration pytest e2e/ -o testpaths=e2e -m integration -x ``` The default `pytest` run only collects `tests/` (`testpaths`), so the E2E suite never runs there. ## Layout | Path | Content | |---|---| | `conftest.py` | Containers (session), environment + state reset (per test), factories: `opc_servers`, `pods`, `put_slot`, `publish_command`, `client_certificate`, `opc_wire` | | `helpers.py` | `Pod` (one gateway pod, `tick()` = one main loop iteration), `load_scenario_input`, `wait_until`/`stays_false`, Mongo/Postgres/Redis queries, DataValue mask | | `opc_server.py` | In-process OPC UA server (`ns=2;s=` variables, restart, secured mode, received writes) | | `db_schema.sql` | `sientia_data.predictions` DDL, mirrored from production | | `scenario_inputs/` | Slots (v2), connector and write command used by the scenarios | | `test_*.py` | One file per topic, `test_scenario____*` | ## Coverage (separate from unit tests) ```bash COVERAGE_FILE=.coverage.e2e pytest e2e/ -o testpaths=e2e -m integration --cov=ingestor --cov-branch ``` ## Scenario catalog See [scenarios.md](scenarios.md) for the numbered scenarios and which test implements each one.