From e3c83a26ffdc09d76f61549dd7da4094ecf50c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Tue, 14 Jul 2026 10:58:13 +0200 Subject: [PATCH] ci: cram: validate the actual BulkData MQTT serial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the BulkData MQTT cram test assumes that every DUT uses the legacy SN[A-F0-9]+ serial-number format. SFL devices instead expose the manufacturing serial through readmfg, including values such as ospv2_A8C2463D425C and freedom_58E403D21127. This makes a valid report fail the complete-payload grep even though the reported SN is exactly DeviceInfo.SerialNumber. Both OSPv2 and Freedom jobs show the following assertion failure: $ R 'cat /tmp/mqtt_subscriber' | \ > grep -cP '^\{"Report":\[\{"SN":"SN[A-F0-9]+","CollectionTime":"[0-9]{13}"\}\]\}$' -[1-9][0-9]* (re) +0 +[1] So lets fix the test by reading DeviceInfo.SerialNumber from the DUT and passing that value to jq. Require exactly one report and compare its SN with the live serial. Validate CollectionTime independently as a string of exactly 13 digits. Print the payload when validation fails so future cram diffs preserve the malformed message. Closes: PPW-2102 References: PCF-2643 Assisted-by: codex:gpt-5.6-sol:high Signed-off-by: Petr Štetiar --- .../123-bulkdata-profile-mqtt.t | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.gitlab/tests/cram/generic/acceleration-plan-components/123-bulkdata-profile-mqtt.t b/.gitlab/tests/cram/generic/acceleration-plan-components/123-bulkdata-profile-mqtt.t index 2a268af026..af15f02230 100644 --- a/.gitlab/tests/cram/generic/acceleration-plan-components/123-bulkdata-profile-mqtt.t +++ b/.gitlab/tests/cram/generic/acceleration-plan-components/123-bulkdata-profile-mqtt.t @@ -40,6 +40,11 @@ Disable time synchronization and restart tr181-bulkdata to test BulkData module > R "/etc/init.d/tr181-bulkdata restart" > fi +Get the serial number that BulkData will report: + + $ serial_number=$(R "ba-cli -lj 'DeviceInfo.SerialNumber?'" | jq -er '.[] | .[] | .SerialNumber') + $ test -n "$serial_number" + Enable BulkData and check object status: $ R "ba-cli 'Device.BulkData.Enable=1' | grep -Ev '^(>|$)' | grep 'Enable'" @@ -98,9 +103,20 @@ Wait for 6 seconds: Check message are recieved by mosquitto_sub: - $ R 'cat /tmp/mqtt_subscriber' | \ - > grep -cP '^\{"Report":\[\{"SN":"SN[A-F0-9]+","CollectionTime":"[0-9]{13}"\}\]\}$' - [1-9][0-9]* (re) + $ mqtt_payload=$(R 'cat /tmp/mqtt_subscriber') + $ if printf '%s\n' "$mqtt_payload" | jq -e --arg serial "$serial_number" ' + > (.Report | type) == "array" and + > (.Report | length) == 1 and + > .Report[0].SN == $serial and + > (.Report[0].CollectionTime | type) == "string" and + > (.Report[0].CollectionTime | test("^[0-9]{13}$")) + > ' > /dev/null; then + > echo "BulkData MQTT payload is valid" + > else + > printf 'Invalid BulkData MQTT payload: %s\n' "$mqtt_payload" >&2 + > false + > fi + BulkData MQTT payload is valid $ R 'rm /tmp/mqtt_subscriber' Teardown, Stop mosquitto_sub: