# Integration runners

Scripts that orchestrate multi-component integration-test loops —
each one wires up docker fixtures, support binaries, and `dotnet test`
in sequence so a developer (or a CI agent) can get from "freshly
cloned repo" to "green integration suite" with one command.

Unlike `scripts/e2e/test-*.ps1` (which drive the built server through
the CLI for black-box coverage), scripts in this folder operate
**below** the server layer — they bring up the raw fixtures the
driver-level `IntegrationTests` projects need.

## Scripts

| Script | Purpose |
|--------|---------|
| [`run-focas.ps1`](run-focas.ps1) | FOCAS driver: builds shim DLLs + starts focas-mock docker + copies shim into test bin + runs `WireCompatGatedTests` + `FocasSimSmokeTests` + tears down docker |

## run-focas.ps1

### Prerequisites

- **Windows + PowerShell 7+**
- **.NET 10 SDK** — `dotnet --version` prints 10.x
- **Native C compiler** — one of:
  - Visual Studio Build Tools with the C++ workload (then run from an
    "x64 Native Tools Command Prompt for VS" shell), or
  - Zig (`zig.exe` on PATH) as a drop-in alternative
- **Docker Desktop** running, OR pass `-SkipDocker` and run the mock
  externally

### One-shot run

```powershell
cd C:\Users\dohertj2\Desktop\lmxopcua
pwsh .\scripts\integration\run-focas.ps1
```

That's the default invocation: thirtyone profile, debug build,
docker cleans up on exit.

### Development iteration

Re-run the tests without rebuilding the shim or restarting docker:

```powershell
# First run bootstraps everything + keeps the mock up.
pwsh .\scripts\integration\run-focas.ps1 -KeepDocker

# Iterate on test bodies without re-doing the slow steps.
pwsh .\scripts\integration\run-focas.ps1 -SkipShimBuild -SkipDocker
```

### Per-series runs

```powershell
pwsh .\scripts\integration\run-focas.ps1 -Profile thirty     # 30i series
pwsh .\scripts\integration\run-focas.ps1 -Profile zerod      # 0i-D
pwsh .\scripts\integration\run-focas.ps1 -Profile powermotion
```

Full profile list is in
`tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS.IntegrationTests/Docker/docker-compose.yml`.

### Exit codes

| Code | Meaning |
|------|---------|
| 0 | All tests passed or cleanly skipped |
| 1 | `dotnet test` reported failures |
| 2 | The runner itself crashed (missing file, unexpected exception) |
| 3 | No C compiler detected for shim build |
| 4 | Docker CLI not on PATH |

### CI integration

Wire this into the project's CI runner (Gitea Actions, Jenkins,
whatever's hosting this repo) by calling:

```yaml
- name: FOCAS integration
  shell: pwsh
  run: ./scripts/integration/run-focas.ps1
```

The script is idempotent; a previous run's `docker compose down`
failure won't block the next one.
