-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests and implementation for maximum packet size.
This is for broker outgoing connack and publish packets only.
- Loading branch information
Showing
12 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
|
||
# Test whether setting maximum packet size to smaller than a CONNACK packet | ||
# results in the CONNECT being rejected. | ||
# MQTTv5 | ||
|
||
from mosq_test_helper import * | ||
|
||
rc = 1 | ||
|
||
keepalive = 10 | ||
props = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_MAXIMUM_PACKET_SIZE, 2) | ||
connect_packet = mosq_test.gen_connect("test", proto_ver=5, keepalive=keepalive, properties=props) | ||
|
||
port = mosq_test.get_port() | ||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port) | ||
|
||
try: | ||
sock = mosq_test.do_client_connect(connect_packet, "", port=port) | ||
# Exception occurs if connack packet returned | ||
rc = 0 | ||
finally: | ||
broker.terminate() | ||
broker.wait() | ||
(stdo, stde) = broker.communicate() | ||
if rc: | ||
print(stde) | ||
|
||
exit(rc) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
# Test whether maximum packet size is honoured on a PUBLISH to a client | ||
# MQTTv5 | ||
|
||
from mosq_test_helper import * | ||
|
||
rc = 1 | ||
|
||
keepalive = 10 | ||
props = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_MAXIMUM_PACKET_SIZE, 20) | ||
connect_packet = mosq_test.gen_connect("test", proto_ver=5, keepalive=keepalive, properties=props) | ||
connack_packet = mosq_test.gen_connack(rc=0, proto_ver=5) | ||
|
||
mid = 1 | ||
subscribe_packet = mosq_test.gen_subscribe(mid, "test/topic", 0, proto_ver=5) | ||
suback_packet = mosq_test.gen_suback(mid, 0, proto_ver=5) | ||
|
||
publish1_packet = mosq_test.gen_publish(topic="test/topic", qos=0, payload="12345678901234567890", proto_ver=5) | ||
publish2_packet = mosq_test.gen_publish(topic="test/topic", qos=0, payload="67890", proto_ver=5) | ||
|
||
pingreq_packet = mosq_test.gen_pingreq() | ||
pingresp_packet = mosq_test.gen_pingresp() | ||
|
||
port = mosq_test.get_port() | ||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port) | ||
|
||
try: | ||
sock = mosq_test.do_client_connect(connect_packet, connack_packet, port=port) | ||
mosq_test.do_send_receive(sock, subscribe_packet, suback_packet) | ||
sock.send(publish1_packet) | ||
# We shouldn't receive the publish here because it is > MAXIMUM_PACKET_SIZE | ||
mosq_test.do_send_receive(sock, pingreq_packet, pingresp_packet) | ||
mosq_test.do_send_receive(sock, publish2_packet, publish2_packet) | ||
mosq_test.do_send_receive(sock, pingreq_packet, pingresp_packet) | ||
rc = 0 | ||
finally: | ||
broker.terminate() | ||
broker.wait() | ||
(stdo, stde) = broker.communicate() | ||
if rc: | ||
print(stde) | ||
|
||
exit(rc) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters