ci: cram: validate the actual BulkData MQTT serial
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 <petr.stetiar@prplfoundation.org>
This commit is contained in:
parent
679f9ba785
commit
e3c83a26ff
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user