forked from espressif/esp-mqtt
ci: Extend the MQTT weekend test to check mqtt-enqueue api
This commit is contained in:
committed by
Euripedes Rocha
parent
2c3363e23a
commit
40fdf32793
@ -56,7 +56,7 @@ def on_message(client, userdata, msg):
|
|||||||
message_log += "Received data:" + msg.topic + " " + payload + "\n"
|
message_log += "Received data:" + msg.topic + " " + payload + "\n"
|
||||||
|
|
||||||
|
|
||||||
def test_single_config(dut, transport, qos, repeat, published):
|
def test_single_config(dut, transport, qos, repeat, published, queue = 0):
|
||||||
global expected_count
|
global expected_count
|
||||||
global expected_data
|
global expected_data
|
||||||
global message_log
|
global message_log
|
||||||
@ -65,7 +65,7 @@ def test_single_config(dut, transport, qos, repeat, published):
|
|||||||
expected_count = 0
|
expected_count = 0
|
||||||
message_log = ""
|
message_log = ""
|
||||||
expected_data = sample_string * repeat
|
expected_data = sample_string * repeat
|
||||||
print("PUBLISH TEST: transport:{}, qos:{}, sequence:{}, sample msg:'{}'".format(transport, qos, published, expected_data))
|
print("PUBLISH TEST: transport:{}, qos:{}, sequence:{}, enqueue:{}, sample msg:'{}'".format(transport, qos, published, queue, expected_data))
|
||||||
client = None
|
client = None
|
||||||
try:
|
try:
|
||||||
if transport in ["ws", "wss"]:
|
if transport in ["ws", "wss"]:
|
||||||
@ -89,7 +89,7 @@ def test_single_config(dut, transport, qos, repeat, published):
|
|||||||
if not event_client_connected.wait(timeout=30):
|
if not event_client_connected.wait(timeout=30):
|
||||||
raise ValueError("ENV_TEST_FAILURE: Test script cannot connect to broker: {}".format(broker_host[transport]))
|
raise ValueError("ENV_TEST_FAILURE: Test script cannot connect to broker: {}".format(broker_host[transport]))
|
||||||
client.subscribe(subscribe_topic, qos)
|
client.subscribe(subscribe_topic, qos)
|
||||||
dut.write("{} {} {} {} {}".format(transport, sample_string, repeat, published, qos), eol="\n")
|
dut.write("{} {} {} {} {} {}".format(transport, sample_string, repeat, published, qos, queue), eol="\n")
|
||||||
try:
|
try:
|
||||||
# waiting till subscribed to defined topic
|
# waiting till subscribed to defined topic
|
||||||
dut.expect(re.compile(r"MQTT_EVENT_SUBSCRIBED"), timeout=30)
|
dut.expect(re.compile(r"MQTT_EVENT_SUBSCRIBED"), timeout=30)
|
||||||
@ -105,7 +105,7 @@ def test_single_config(dut, transport, qos, repeat, published):
|
|||||||
if expected_count == published or (expected_count > published and qos == 1):
|
if expected_count == published or (expected_count > published and qos == 1):
|
||||||
print("All data received from ESP32...")
|
print("All data received from ESP32...")
|
||||||
else:
|
else:
|
||||||
raise ValueError("Not all data received from ESP32: Expected:{}x{}, Received:{}x{}".format(expected_data, published, message_log, expected_count))
|
raise ValueError("Not all data received from ESP32: Expected:{}x{}, Received:{}x{}".format(expected_count, published, expected_data, message_log))
|
||||||
finally:
|
finally:
|
||||||
event_stop_client.set()
|
event_stop_client.set()
|
||||||
thread1.join()
|
thread1.join()
|
||||||
@ -149,29 +149,30 @@ def test_weekend_mqtt_publish(env, extra_data):
|
|||||||
raise
|
raise
|
||||||
for qos in [0, 1, 2]:
|
for qos in [0, 1, 2]:
|
||||||
for transport in ["tcp", "ssl", "ws", "wss"]:
|
for transport in ["tcp", "ssl", "ws", "wss"]:
|
||||||
if broker_host[transport] is None:
|
for q in [0, 1]:
|
||||||
print('Skipping transport: {}...'.format(transport))
|
if broker_host[transport] is None:
|
||||||
continue
|
print('Skipping transport: {}...'.format(transport))
|
||||||
# simple test with empty message
|
continue
|
||||||
test_single_config(dut1, transport, qos, 0, 5)
|
# simple test with empty message
|
||||||
# decide on broker what level of test will pass (local broker works the best)
|
test_single_config(dut1, transport, qos, 0, 5, q)
|
||||||
if broker_host[transport].startswith("192.168") and qos < 1:
|
# decide on broker what level of test will pass (local broker works the best)
|
||||||
# medium size, medium repeated
|
if broker_host[transport].startswith("192.168") and qos > 0 and q == 0:
|
||||||
test_single_config(dut1, transport, qos, 5, 50)
|
# medium size, medium repeated
|
||||||
# long data
|
test_single_config(dut1, transport, qos, 5, 50, q)
|
||||||
test_single_config(dut1, transport, qos, 1000, 10)
|
# long data
|
||||||
# short data, many repeats
|
test_single_config(dut1, transport, qos, 1000, 10, q)
|
||||||
test_single_config(dut1, transport, qos, 2, 200)
|
# short data, many repeats
|
||||||
elif transport in ["ws", "wss"]:
|
test_single_config(dut1, transport, qos, 2, 200, q)
|
||||||
# more relaxed criteria for websockets!
|
elif transport in ["ws", "wss"]:
|
||||||
test_single_config(dut1, transport, qos, 2, 5)
|
# more relaxed criteria for websockets!
|
||||||
test_single_config(dut1, transport, qos, 50, 1)
|
test_single_config(dut1, transport, qos, 2, 5, q)
|
||||||
test_single_config(dut1, transport, qos, 10, 20)
|
test_single_config(dut1, transport, qos, 50, 1, q)
|
||||||
else:
|
test_single_config(dut1, transport, qos, 10, 20, q)
|
||||||
# common configuration should be good for most public mosquittos
|
else:
|
||||||
test_single_config(dut1, transport, qos, 5, 10)
|
# common configuration should be good for most public mosquittos
|
||||||
test_single_config(dut1, transport, qos, 500, 3)
|
test_single_config(dut1, transport, qos, 5, 10, q)
|
||||||
test_single_config(dut1, transport, qos, 1, 50)
|
test_single_config(dut1, transport, qos, 500, 3, q)
|
||||||
|
test_single_config(dut1, transport, qos, 1, 50, q)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user