@@ -108,7 +108,10 @@ start_broker() {
108108 tls_args=" -s $port "
109109 fi
110110 broker_log=" ${TMP_DIR} /broker_p${port} .log"
111- ./$broker_bin " $@ " -p $port $tls_args > " $broker_log " 2>&1 &
111+ # -v 3 = DEBUG; emits PUBLISH/PUBACK/drain events so the
112+ # preserved broker_p<port>.log makes broker-side failures
113+ # actually diagnosable in CI.
114+ ./$broker_bin " $@ " -v 3 -p $port $tls_args > " $broker_log " 2>&1 &
112115 broker_pid=$!
113116 if check_broker; then
114117 return 0
@@ -136,7 +139,7 @@ start_broker_dual() {
136139 port_tls=$port
137140 port=$plain_port
138141 broker_log=" ${TMP_DIR} /broker_dual_p${port} _t${port_tls} .log"
139- ./$broker_bin " $@ " -p $port -s $port_tls > " $broker_log " 2>&1 &
142+ ./$broker_bin " $@ " -v 3 - p $port -s $port_tls > " $broker_log " 2>&1 &
140143 broker_pid=$!
141144 check_broker $port
142145 check_broker $port_tls
@@ -1135,27 +1138,45 @@ else
11351138start_broker
11361139T26_N=20
11371140rm -f " ${TMP_DIR} /t26_sub.ready"
1138- timeout 15 ./$sub_bin -T -h 127.0.0.1 -p $port -n " test/burst" -q 1 \
1139- -i " t26_sub" -C $T26_N -R " ${TMP_DIR} /t26_sub.ready" \
1141+ # Notes on subscriber flags:
1142+ # -C 5000 command timeout per wait, in milliseconds. NOT a message
1143+ # count - mqtt-sub uses -C as cmd_timeout_ms (mqttexample.c
1144+ # case 'C'). Earlier revisions of this test mistakenly
1145+ # passed -C $T26_N (=20), giving a 20 ms timeout that on
1146+ # nonblock builds (--enable-all enables WOLFMQTT_NONBLOCK)
1147+ # tripped MqttClient_Unsubscribe / Ping_ex before any
1148+ # output flushed, especially on macOS arm64.
1149+ # -k 300 keep-alive seconds; bumped above worst-case test duration
1150+ # so the client-side keep-alive does not fire mid-burst on
1151+ # slow CI runners. Inbound PUBLISH traffic does not reset
1152+ # the client keep-alive timer.
1153+ # Subscriber stays alive until the test kills it after the publishers
1154+ # finish; that pattern is below.
1155+ timeout 30 ./$sub_bin -T -h 127.0.0.1 -p $port -n " test/burst" -q 1 \
1156+ -i " t26_sub" -C 5000 -k 300 -R " ${TMP_DIR} /t26_sub.ready" \
11401157 > " ${TMP_DIR} /t26_sub.log" 2>&1 &
11411158T26_SUB_PID=$!
11421159TEST_PIDS+=($T26_SUB_PID )
1143- wait_for_file " ${TMP_DIR} /t26_sub.ready" 5
1160+ wait_for_file " ${TMP_DIR} /t26_sub.ready" 10
11441161# Publish T26_N sequentially numbered QoS 1 messages
11451162for t26_i in $( seq 1 $T26_N ) ; do
11461163 ./$pub_bin -T -h 127.0.0.1 -p $port -n " test/burst" -q 1 \
11471164 -m " burst_${t26_i} " -i " t26_pub_${t26_i} " \
11481165 >> " ${TMP_DIR} /t26_pub.log" 2>&1
11491166done
1150- # Give the subscriber a moment to drain.
1151- sleep 1
1167+ # mqtt-sub has no "exit after N messages" mode, so it never exits on
1168+ # its own. Give the broker a grace window to fan out all 20 messages
1169+ # (each publisher is a separate connect/pub/disconnect; the broker's
1170+ # outbound drain may lag the last publish a bit on slow CI), then kill
1171+ # the subscriber so its log is flushed and we can count what arrived.
1172+ sleep 2
11521173kill $T26_SUB_PID 2> /dev/null
11531174wait $T26_SUB_PID 2> /dev/null || true
11541175TEST_PIDS=()
11551176# Count how many of the burst_N tokens reached the subscriber and check
11561177# that they arrived in publish order (1, 2, ..., N).
11571178T26_RECEIVED=$( grep -oE ' burst_[0-9]+' " ${TMP_DIR} /t26_sub.log" 2> /dev/null \
1158- | wc -l)
1179+ | wc -l | tr -d ' ' )
11591180T26_ORDER_OK=yes
11601181T26_LAST=0
11611182while read -r tok; do
@@ -1165,11 +1186,18 @@ while read -r tok; do
11651186 fi
11661187 T26_LAST=$n
11671188done < <( grep -oE ' burst_[0-9]+' " ${TMP_DIR} /t26_sub.log" 2> /dev/null)
1168- if [ " $T26_RECEIVED " = " $T26_N " ] && [ " $T26_ORDER_OK " = " yes" ]; then
1189+ if [ " $T26_RECEIVED " -eq " $T26_N " ] && [ " $T26_ORDER_OK " = " yes" ]; then
11691190 echo " PASS: QoS 1 burst delivery (received=$T26_RECEIVED order=ok)"
11701191else
11711192 echo " FAIL: Burst delivery (received=$T26_RECEIVED expected=$T26_N " \
11721193 " order=$T26_ORDER_OK )"
1194+ echo " --- t26 broker_log tail ---"
1195+ tail -80 " $broker_log " 2> /dev/null || true
1196+ echo " --- t26_sub.log tail ---"
1197+ tail -40 " ${TMP_DIR} /t26_sub.log" 2> /dev/null || true
1198+ echo " --- t26_pub.log tail ---"
1199+ tail -40 " ${TMP_DIR} /t26_pub.log" 2> /dev/null || true
1200+ echo " --- t26 end ---"
11731201 FAIL=1
11741202fi
11751203fi # skip_plain
0 commit comments