Skip to content

Commit 67eb70a

Browse files
committed
test(smoke): wait for opcua_bridge subscription before PLC inject
Smoke flaked on CI: inject-photoeye-flicker fired ~540 ms before the opcua_bridge completed its AlarmConditionType subscription handshake with plc-sim. The OPC UA raise event then had no listener, the bridge caught only the later clear events from restore-line, and the MANYMOVE_PLC_PHOTOEYE_FLICKER fault never made it to FaultManager. Probe the bridge container logs for 'subscribed to AlarmConditionType events' before the inject, plus a 1s margin for the asyncua handshake to complete on the plc-sim side. Skip gracefully when the host docker socket is not reachable from the test environment.
1 parent 6ebe454 commit 67eb70a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/smoke_test_manymove_industrial.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,41 @@ if api_get "/components"; then
8181
fi
8282
fi
8383

84+
# Wait for opcua_bridge to actually subscribe to AlarmConditionType
85+
# events before injecting. Container manifest discovery (above) only
86+
# proves the gateway routed the component, not that the asyncua
87+
# subscription handshake on plc-sim completed. Without this wait the
88+
# inject can fire 100-500ms before bridge is ready, the OPC UA raise
89+
# event goes unheard and the test flakes.
90+
#
91+
# Skipped gracefully if the host docker CLI is not reachable (e.g.
92+
# running the smoke script from inside a container without the socket
93+
# mounted), since the belt-and-suspenders sleep below covers the race
94+
# in practice.
95+
# Probe once first; if docker logs of the bridge isn't reachable from
96+
# this environment (script running from inside a container without the
97+
# socket mounted, etc.) skip the check entirely - the sleep below
98+
# covers the race for the common-case smoke runs.
99+
PROBE=$(docker logs manymove_industrial-opcua-bridge-1 2>/dev/null || true)
100+
if [ -n "$PROBE" ]; then
101+
BRIDGE_LOGS="$PROBE"
102+
for _ in $(seq 1 20); do
103+
if echo "$BRIDGE_LOGS" | grep -q "subscribed to AlarmConditionType events"; then
104+
pass "opcua_bridge subscribed to AlarmConditionType events"
105+
break
106+
fi
107+
sleep 1
108+
BRIDGE_LOGS=$(docker logs manymove_industrial-opcua-bridge-1 2>/dev/null || true)
109+
done
110+
if ! echo "$BRIDGE_LOGS" | grep -q "subscribed to AlarmConditionType events"; then
111+
fail "opcua_bridge never subscribed to AlarmConditionType events"
112+
fi
113+
fi
114+
# Belt-and-suspenders: small extra delay so subscription is fully active
115+
# on the plc-sim side too (asyncua handshake completes ~50-200ms after
116+
# the bridge logs the subscribe call).
117+
sleep 1
118+
84119
# Photoeye flicker injection -> MANYMOVE_PLC_PHOTOEYE_FLICKER (WARN)
85120
if curl -fsS -X POST -H "Content-Type: application/json" -d "$EXEC_BODY" \
86121
"$API_BASE/components/conveyor-line/scripts/inject-photoeye-flicker/executions" >/dev/null; then

0 commit comments

Comments
 (0)