Files
scadalink-design/infra
Joseph Doherty 295150751f feat(scripts): realign Test Run with runtime API, add anonymous-object calls and instance binding
The Test Run sandbox and Monaco analysis modelled a script API that had
drifted from the site runtime's ScriptGlobals, so real scripts failed to
compile in Test Run. Realign both to the runtime surface
(Instance/Scripts/ExternalSystem/Attributes/Children/Parent) and drop the
duplicate ScriptHost stub so the two cannot diverge again.

- Script calls (Scripts.CallShared, Instance.CallScript, Route.To().Call)
  accept an anonymous object instead of a hand-built dictionary, via a
  shared ScriptArgs normalizer; existing dictionary calls still compile.
- Test Run can optionally bind to a deployed instance, so Instance/
  Attributes/CallScript route to it cross-site; adds site-side
  RouteToGetAttributes/RouteToSetAttributes handlers.
- Adds Test Run panels to the API method and template script editors.
- Fixes the TestDatabaseQuery seed script, which queried a table that
  never existed.

Also commits unrelated in-progress work already in the tree: the health
monitoring report loop, site streaming changes, and the Admin/Design
data-connection and SMTP page reorganization.
2026-05-16 03:37:56 -04:00
..

ScadaLink Test Infrastructure

Local Docker-based test services for ScadaLink development.

Quick Start

docker compose up -d

This starts the following services:

Service Port Purpose
OPC UA (Azure IoT OPC PLC) 50000 (OPC UA), 8080 (web) Simulated OPC UA server with ScadaLink-style tags
OPC UA 2 (Azure IoT OPC PLC) 50010 (OPC UA), 8081 (web) Second OPC UA server instance (same tags, independent state)
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

First-Time SQL Setup

The MS SQL container does not auto-run init scripts. After the first docker compose up -d, run:

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:

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):

docker compose down

Stop a single service (leave the others running):

docker compose stop opcua      # or: opcua2, ldap, mssql, smtp, restapi
docker compose start opcua     # bring it back without recreating

Full teardown (stop containers, delete SQL data volume, remove pulled images):

./teardown.sh

Or manually:

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):

python3 -m venv tools/.venv && source tools/.venv/bin/activate

Install dependencies (one-time, with venv active):

pip install -r tools/requirements.txt

The .venv directory is gitignored.

Quick readiness check (all five services, with venv active):

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: