Dockerize Modbus + AB CIP + S7 test fixtures for reproducibility #162
Reference in New Issue
Block a user
Delete Branch "fixtures-all-docker"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every driver integration simulator is now a pinned Docker image with a compose-file launcher. Matches the opc-plc/OpcUaClient pattern from #215 so the full fleet (Modbus, AB CIP, S7, OpcUaClient) shares one compose-up/test/compose-down loop. Native launchers kept as fallbacks. Verified end-to-end: Modbus DL205 1/1, S7 3/3, AB CIP ControlLogix 4/4 against live containers.
docker compose up. Modbus — new tests/ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests/Docker/ with Dockerfile (python:3.12-slim-bookworm+pymodbus[simulator]==3.13.0) + docker-compose.yml with four compose profiles (standard/dl205/mitsubishi/s7_1500) backed by the existing profile JSONs copied underDocker/profiles/as canonical; native fallback inPymodbus/retained with the same JSON set (symlink-equivalent — manual re-sync when profiles change, noted in both READMEs). Port 5020 unchanged soMODBUS_SIM_ENDPOINT+ModbusSimulatorFixturework without code change. Dropped the--no_httpCLI arg the old serve.ps1 + compose draft passed — pymodbus 3.13 doesn't recognize it; the simulator's http ui just binds inside the container where nothing maps it out and costs nothing. S7 — new tests/ZB.MOM.WW.OtOpcUa.Driver.S7.IntegrationTests/Docker/ with Dockerfile (python:3.12-slim-bookworm+python-snap7>=2.0) + docker-compose.yml with ones7_1500compose profile; copies the existingserver.pyshim +s7_1500.jsonseed profile; runspython -u server.py ... --port 1102. Native fallback inPythonSnap7/retained. Port 1102 unchanged. AB CIP — hardest because ab_server is a source-only C tool in libplctag'ssrc/tools/ab_server/. New tests/ZB.MOM.WW.OtOpcUa.Driver.AbCip.IntegrationTests/Docker/ Dockerfile is multi-stage: build stage (debian:bookworm-slim+ build-essential + cmake) clones libplctag at a pinned tag +cmake --build build --target ab_server; runtime stage (debian:bookworm-slim) copies just the binary from/src/build/bin_dist/ab_server. docker-compose.yml ships four compose profiles (controllogix/compactlogix/micro800/guardlogix) with per-familyab_serverCLI args matchingAbServerProfile.cs. AbServerFixture updated: tries TCP probe on127.0.0.1:44818first (Docker path) + spawns the native binary only as fallback when no listener is there.AB_SERVER_ENDPOINTenv var supported for pointing at a real PLC. AbServerFact/Theory attributes updated toIsServerAvailable()which accepts any of: live listener on 44818, AB_SERVER_ENDPOINT set, or binary on PATH. Required two CLI-compat fixes to ab_server's argument expectations that the existing native profile never caught because it was never actually run at CI:--plcis case-sensitive (ControlLogixnotcontrollogix), CIP tags need[size]bracket notation (DINT[1]not bareDINT), ControlLogix also requires--path=1,0. Compose files carry the corrected flags; the existing native-pathAbServerProfile.cswas never invoked in practice so we don't rewrite it here.Micro800now uses the--plc=Micro800mode rather than falling back to ControlLogix emulation — ab_server does have the dedicated mode, the old Notes saying otherwise were wrong. Updated docs: three fixture coverage docs (Modbus-Test-Fixture.md, S7-Test-Fixture.md, AbServer-Test-Fixture.md) flip their "What the fixture is" section from native-only to Docker-primary-with-native-fallback; dev-environment.md §Resource Inventory replaces the old ambiguous "Docker Desktop + ab_server native" mix with four per-driver rows (each listing the image, compose file, compose profiles, port, credentials) + a newDocker fixtures — quick referencesubsection giving the one-linedocker compose -f <…> --profile <…> upfor each driver + the env-var override names + the native fallback install recipes. drivers/README.md coverage map table updated — Modbus/AB CIP/S7 entries now read "Dockerized …" consistent with OpcUaClient's line. Verified end-to-end against live containers: Modbus DL205 smoke 1/1, S7 3/3, AB CIP ControlLogix 4/4 (all family theory rows). Container lifecycle clean (up/test/down, no leaked state). Every fixture keeps its skip-when-absent probe + env-var endpoint override sodotnet teston a fresh clone without Docker running still gets a green run. 6609141493