fix(modbus-fixture): run pymodbus sim without asyncio debug mode; FC03 healthcheck + watchdog (#909)
Root cause: pymodbus 3.13's `pymodbus.simulator` console script hard-codes asyncio.run(run_main(), debug=True). Debug mode captures a traceback per scheduled callback and logs callbacks slower than 100 ms (the "took 0.146 seconds" lines in #909). Side by side on the shared docker host (closed-loop FC03 clients, 2 s deadline): 100 clients got ~120-170 req/s, p99 1.6-1.9 s with client timeouts in debug mode vs ~2400 req/s, p99 ~135 ms without it. The shared sim also carries the docker-dev rig's 49 Modbus drivers on each of central-1/central-2 (98 sockets, ~220 req/s at idle), which is above the debug-mode capacity, so a test run on top was answered late ("Cancel send, because not connected!") and timed out. - run_simulator.py: same CLI as pymodbus.simulator, debug=False, plus a watchdog thread that exits after 3 failed FC03 probes so restart: unless-stopped replaces the container (docker has no restart-on-unhealthy). - fc3_probe.py: stdlib FC03 read with a deadline (MBAP or RTU framing); the compose healthcheck. - docker-compose.yml: shared anchor for every pymodbus service: new entrypoint, `project: lmxopcua` label, restart: unless-stopped, healthcheck, bounded json-file logs. - README: why, the numbers, and how to diagnose load.
This commit is contained in:
@@ -21,16 +21,23 @@ COPY profiles/ /fixtures/
|
||||
# compose profile. See Docker/README.md §exception injection.
|
||||
COPY exception_injector.py /fixtures/
|
||||
|
||||
# #909: launcher that runs the simulator with asyncio debug mode OFF (pymodbus 3.13
|
||||
# hard-codes debug=True, which made it >10x slower and let it be swamped by one test run),
|
||||
# plus the FC03 liveness probe it uses as an in-container watchdog and compose uses as
|
||||
# the healthcheck. See run_simulator.py.
|
||||
COPY run_simulator.py fc3_probe.py /fixtures/
|
||||
|
||||
# 5020 = the shared port for the standard/dl205/mitsubishi/s7_1500/exception_injection
|
||||
# profiles (only one binds it at a time); 5021 = the rtu_over_tcp profile, which co-runs
|
||||
# with standard. Image-metadata honesty only — compose's ports: mapping doesn't need EXPOSE.
|
||||
EXPOSE 5020 5021
|
||||
|
||||
# Default to the standard profile; docker-compose.yml overrides per service.
|
||||
# Never launch the stock `pymodbus.simulator` console script: it runs asyncio in debug mode (#909).
|
||||
# --http_port intentionally omitted; pymodbus 3.13's web UI binds on a
|
||||
# container-local default we don't publish, so it's not reachable from the
|
||||
# host and costs nothing.
|
||||
CMD ["pymodbus.simulator", \
|
||||
CMD ["python", "/fixtures/run_simulator.py", \
|
||||
"--modbus_server", "srv", \
|
||||
"--modbus_device", "dev", \
|
||||
"--json_file", "/fixtures/standard.json"]
|
||||
|
||||
Reference in New Issue
Block a user