@@ -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
@@ -1133,27 +1136,45 @@ else
11331136start_broker
11341137T26_N=20
11351138rm -f " ${TMP_DIR} /t26_sub.ready"
1136- timeout 15 ./$sub_bin -T -h 127.0.0.1 -p $port -n " test/burst" -q 1 \
1137- -i " t26_sub" -C $T26_N -R " ${TMP_DIR} /t26_sub.ready" \
1139+ # Notes on subscriber flags:
1140+ # -C 5000 command timeout per wait, in milliseconds. NOT a message
1141+ # count - mqtt-sub uses -C as cmd_timeout_ms (mqttexample.c
1142+ # case 'C'). Earlier revisions of this test mistakenly
1143+ # passed -C $T26_N (=20), giving a 20 ms timeout that on
1144+ # nonblock builds (--enable-all enables WOLFMQTT_NONBLOCK)
1145+ # tripped MqttClient_Unsubscribe / Ping_ex before any
1146+ # output flushed, especially on macOS arm64.
1147+ # -k 300 keep-alive seconds; bumped above worst-case test duration
1148+ # so the client-side keep-alive does not fire mid-burst on
1149+ # slow CI runners. Inbound PUBLISH traffic does not reset
1150+ # the client keep-alive timer.
1151+ # Subscriber stays alive until the test kills it after the publishers
1152+ # finish; that pattern is below.
1153+ timeout 30 ./$sub_bin -T -h 127.0.0.1 -p $port -n " test/burst" -q 1 \
1154+ -i " t26_sub" -C 5000 -k 300 -R " ${TMP_DIR} /t26_sub.ready" \
11381155 > " ${TMP_DIR} /t26_sub.log" 2>&1 &
11391156T26_SUB_PID=$!
11401157TEST_PIDS+=($T26_SUB_PID )
1141- wait_for_file " ${TMP_DIR} /t26_sub.ready" 5
1158+ wait_for_file " ${TMP_DIR} /t26_sub.ready" 10
11421159# Publish T26_N sequentially numbered QoS 1 messages
11431160for t26_i in $( seq 1 $T26_N ) ; do
11441161 ./$pub_bin -T -h 127.0.0.1 -p $port -n " test/burst" -q 1 \
11451162 -m " burst_${t26_i} " -i " t26_pub_${t26_i} " \
11461163 >> " ${TMP_DIR} /t26_pub.log" 2>&1
11471164done
1148- # Give the subscriber a moment to drain.
1149- sleep 1
1165+ # mqtt-sub has no "exit after N messages" mode, so it never exits on
1166+ # its own. Give the broker a grace window to fan out all 20 messages
1167+ # (each publisher is a separate connect/pub/disconnect; the broker's
1168+ # outbound drain may lag the last publish a bit on slow CI), then kill
1169+ # the subscriber so its log is flushed and we can count what arrived.
1170+ sleep 2
11501171kill $T26_SUB_PID 2> /dev/null
11511172wait $T26_SUB_PID 2> /dev/null || true
11521173TEST_PIDS=()
11531174# Count how many of the burst_N tokens reached the subscriber and check
11541175# that they arrived in publish order (1, 2, ..., N).
11551176T26_RECEIVED=$( grep -oE ' burst_[0-9]+' " ${TMP_DIR} /t26_sub.log" 2> /dev/null \
1156- | wc -l)
1177+ | wc -l | tr -d ' ' )
11571178T26_ORDER_OK=yes
11581179T26_LAST=0
11591180while read -r tok; do
@@ -1163,11 +1184,18 @@ while read -r tok; do
11631184 fi
11641185 T26_LAST=$n
11651186done < <( grep -oE ' burst_[0-9]+' " ${TMP_DIR} /t26_sub.log" 2> /dev/null)
1166- if [ " $T26_RECEIVED " = " $T26_N " ] && [ " $T26_ORDER_OK " = " yes" ]; then
1187+ if [ " $T26_RECEIVED " -eq " $T26_N " ] && [ " $T26_ORDER_OK " = " yes" ]; then
11671188 echo " PASS: QoS 1 burst delivery (received=$T26_RECEIVED order=ok)"
11681189else
11691190 echo " FAIL: Burst delivery (received=$T26_RECEIVED expected=$T26_N " \
11701191 " order=$T26_ORDER_OK )"
1192+ echo " --- t26 broker_log tail ---"
1193+ tail -80 " $broker_log " 2> /dev/null || true
1194+ echo " --- t26_sub.log tail ---"
1195+ tail -40 " ${TMP_DIR} /t26_sub.log" 2> /dev/null || true
1196+ echo " --- t26_pub.log tail ---"
1197+ tail -40 " ${TMP_DIR} /t26_pub.log" 2> /dev/null || true
1198+ echo " --- t26 end ---"
11711199 FAIL=1
11721200fi
11731201fi # skip_plain
0 commit comments