Files
scadalink-design/infra/README.md
Joseph Doherty d91aa83665 refactor(docs): move requirements and test infra docs into docs/ subdirectories
Organize documentation by moving requirements (HighLevelReqs, Component-*,
lmxproxy_protocol) to docs/requirements/ and test infrastructure docs to
docs/test_infra/. Updates all cross-references in README, CLAUDE.md,
infra/README, component docs, and 23 plan files.
2026-03-21 01:11:35 -04:00

111 lines
3.8 KiB
Markdown

# ScadaLink Test Infrastructure
Local Docker-based test services for ScadaLink development.
## Quick Start
```bash
docker compose up -d
```
This starts five services:
| Service | Port | Purpose |
|---------|------|---------|
| OPC UA (Azure IoT OPC PLC) | 50000 (OPC UA), 8080 (web) | Simulated OPC UA server with ScadaLink-style tags |
| LDAP (GLAuth) | 3893 | Lightweight LDAP with test users/groups matching ScadaLink roles |
| MS SQL 2022 | 1433 | Configuration and machine data databases |
| SMTP (Mailpit) | 1025 (SMTP), 8025 (web) | Email capture for notification testing |
| REST API (Flask) | 5200 | External REST API for Gateway and Inbound API testing |
| LmxFakeProxy (.NET gRPC) | 50051 (gRPC) | LmxProxy-compatible server bridging to OPC UA test server |
## First-Time SQL Setup
The MS SQL container does not auto-run init scripts. After the first `docker compose up -d`, run:
```bash
docker exec -i scadalink-mssql /opt/mssql-tools18/bin/sqlcmd \
-S localhost -U sa -P 'ScadaLink_Dev1#' -C \
-i /docker-entrypoint-initdb.d/setup.sql
```
This creates the `ScadaLinkConfig` and `ScadaLinkMachineData` databases and the `scadalink_app` login. Then seed the Machine Data database:
```bash
docker exec -i scadalink-mssql /opt/mssql-tools18/bin/sqlcmd \
-S localhost -U sa -P 'ScadaLink_Dev1#' -C \
-i /docker-entrypoint-initdb.d/machinedata_seed.sql
```
## Stopping & Teardown
**Stop containers** (data persists in SQL volume):
```bash
docker compose down
```
**Stop a single service** (leave the others running):
```bash
docker compose stop opcua # or: ldap, mssql, smtp, restapi
docker compose start opcua # bring it back without recreating
```
**Full teardown** (stop containers, delete SQL data volume, remove pulled images):
```bash
./teardown.sh
```
Or manually:
```bash
docker compose down -v # stop containers + delete SQL data volume
docker compose down -v --rmi all # also remove downloaded images
```
After a full teardown, the next `docker compose up -d` starts fresh — you'll need to re-run the SQL setup script.
## CLI Tools
Python CLI tools for interacting with the test services are in `tools/`.
**Set up a Python virtual environment** (one-time):
```bash
python3 -m venv tools/.venv && source tools/.venv/bin/activate
```
**Install dependencies** (one-time, with venv active):
```bash
pip install -r tools/requirements.txt
```
> The `.venv` directory is gitignored.
**Quick readiness check** (all five services, with venv active):
```bash
python tools/opcua_tool.py check
python tools/ldap_tool.py check
python tools/mssql_tool.py check
python tools/smtp_tool.py check
python tools/restapi_tool.py check
```
| Tool | Service | Key Commands |
|------|---------|-------------|
| `tools/opcua_tool.py` | OPC UA | `check`, `browse`, `read`, `write`, `monitor` |
| `tools/ldap_tool.py` | LDAP | `check`, `bind`, `search`, `users`, `groups` |
| `tools/mssql_tool.py` | MS SQL | `check`, `setup`, `query`, `tables` |
| `tools/smtp_tool.py` | SMTP (Mailpit) | `check`, `send`, `list`, `read`, `clear` |
| `tools/restapi_tool.py` | REST API (Flask) | `check`, `call`, `methods` |
Each tool supports `--help` for full usage. See the per-service docs below for detailed examples.
## Detailed Documentation
See `docs/test_infra/` for per-service setup guides:
- [test_infra.md](../docs/test_infra/test_infra.md) — Master test infrastructure overview
- [test_infra_opcua.md](../docs/test_infra/test_infra_opcua.md) — OPC UA server details
- [test_infra_ldap.md](../docs/test_infra/test_infra_ldap.md) — LDAP server details
- [test_infra_db.md](../docs/test_infra/test_infra_db.md) — MS SQL database details
- [test_infra_smtp.md](../docs/test_infra/test_infra_smtp.md) — SMTP server details (Mailpit)
- [test_infra_restapi.md](../docs/test_infra/test_infra_restapi.md) — REST API server details (Flask)