Extend db_dump tests, and fix minor bugs.
parent
4612901128
commit
86f3a6b484
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from mosq_test_helper import *
|
||||
|
||||
def do_test(file, stderr, rc_expected):
|
||||
|
||||
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
|
||||
f'db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
|
||||
if res.stderr != stderr:
|
||||
print(res.stderr)
|
||||
raise mosq_test.TestError
|
||||
if res.returncode != rc_expected:
|
||||
print(file)
|
||||
print(res.returncode)
|
||||
raise mosq_test.TestError
|
||||
|
||||
do_test('missing.test-db', "Error: Unable to open db_dump/missing.test-db\n", 0)
|
||||
do_test('bad-magic.test-db', "Error: Unrecognised file format.\n", 1)
|
||||
do_test('short.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('bad-dbid-size.test-db', "Error: Incompatible database configuration (dbid size is 5 bytes, expected 8)", 1)
|
||||
do_test('bad-chunk.test-db', 'Warning: Unsupported chunk "2816" of length 65696 in persistent database file at position 29. Ignoring.\n', 0)
|
||||
do_test('v3-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v4-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v5-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v6-corrupt.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v6-corrupt-client.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v6-corrupt-cmsg.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v6-corrupt-retain.test-db', "Error: Corrupt persistent database.\n", 1)
|
||||
do_test('v6-corrupt-sub.test-db', "Error: Corrupt persistent database.\n", 1)
|
@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from mosq_test_helper import *
|
||||
|
||||
def do_test(file, stdout):
|
||||
|
||||
cmd = [mosq_test.get_build_root() + '/apps/db_dump/mosquitto_db_dump',
|
||||
f'db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3, encoding='utf-8')
|
||||
if res.stdout != stdout:
|
||||
print(res.stdout)
|
||||
raise mosq_test.TestError
|
||||
|
||||
stdout = """Mosquitto DB dump
|
||||
CRC: 0
|
||||
DB version: 6
|
||||
DB_CHUNK_CFG:
|
||||
Length: 16
|
||||
Shutdown: 1
|
||||
DB ID size: 8
|
||||
Last DB ID: 273732472648936
|
||||
DB_CHUNK_BASE_MSG:
|
||||
Length: 187
|
||||
Store ID: 273732462748327
|
||||
Source Port: 1883
|
||||
Source MID: 1
|
||||
Topic: test-topic
|
||||
QoS: 1
|
||||
Retain: 0
|
||||
Payload Length: 7
|
||||
Expiry Time: 1669799825
|
||||
Payload: message
|
||||
Properties:
|
||||
Content type: text/plain
|
||||
Correlation data: 35636638653064652D356666612D346131302D393036622D346535623266393038363162
|
||||
Payload format indicator: 1
|
||||
Response topic: pub-response-topic
|
||||
User property: pub-key , pub-value
|
||||
DB_CHUNK_BASE_MSG:
|
||||
Length: 132
|
||||
Store ID: 273732472648936
|
||||
Source Port: 0
|
||||
Source MID: 0
|
||||
Topic: will-topic
|
||||
QoS: 2
|
||||
Retain: 1
|
||||
Payload Length: 12
|
||||
Expiry Time: 1669799786
|
||||
Payload: will-payload
|
||||
Properties:
|
||||
Content type: text/plain
|
||||
Correlation data: 636F7272656C6174696F6E2D64617461
|
||||
Payload format indicator: 1
|
||||
Response topic: will-response-topic
|
||||
User property: key , value
|
||||
DB_CHUNK_CLIENT:
|
||||
Length: 32
|
||||
Client ID: clientid
|
||||
Last MID: 1
|
||||
Session expiry time: 1669799784
|
||||
Session expiry interval: 60
|
||||
DB_CHUNK_CLIENT_MSG:
|
||||
Length: 27
|
||||
Client ID: clientid
|
||||
Store ID: 273732462748327
|
||||
MID: 1
|
||||
QoS: 1
|
||||
Retain: 0
|
||||
Direction: 1
|
||||
State: 11
|
||||
Dup: 0
|
||||
Subscription identifier: 42
|
||||
DB_CHUNK_SUB:
|
||||
Length: 30
|
||||
Client ID: clientid
|
||||
Topic: test-topic
|
||||
QoS: 1
|
||||
Subscription ID: 42
|
||||
Options: 0x00
|
||||
DB_CHUNK_RETAIN:
|
||||
Length: 8
|
||||
Store ID: 273732472648936
|
||||
"""
|
||||
do_test('v6-mqtt-v5-props.test-db', stdout)
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
This is a text file, not a persistence file.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue