Merge pull request #1487 from grom-42/fix-send-pkt
Fix test on invalid null will topic value in connect packet Fix test on invalid reserved bit value in connect packet Add send of pubcomp in 02-subpub-qos2 script. To keep the broker session working while launching several tests on the same broker, the last packet of this transaction must be sent. Fix way of sending packets in compliance tests. According to the documentation of python 3 socket::send method (https://docs.python.org/3/library/socket.html#socket.socket.send), the call to send must be retry until all data is sent while sending packet with a "large" amount of data.
This commit is contained in:
commit
25f458de74
@ -3,6 +3,8 @@
|
||||
# Test whether a CONNECT with reserved set to 1 results in a disconnect. MQTT-3.1.2-3
|
||||
|
||||
from mosq_test_helper import *
|
||||
from socket import error as SocketError
|
||||
import errno
|
||||
|
||||
rc = 1
|
||||
keepalive = 10
|
||||
@ -15,7 +17,11 @@ try:
|
||||
sock = mosq_test.do_client_connect(connect_packet, b"", port=port)
|
||||
sock.close()
|
||||
rc = 0
|
||||
|
||||
except SocketError as e:
|
||||
if e.errno == errno.ECONNRESET:
|
||||
# Connection has been closed by peer (very quickly).
|
||||
# Fine, this is the expected behavior.
|
||||
rc = 0
|
||||
finally:
|
||||
broker.terminate()
|
||||
broker.wait()
|
||||
|
@ -38,6 +38,7 @@ try:
|
||||
|
||||
if mosq_test.expect_packet(sock, "publish2", publish_packet2):
|
||||
mosq_test.do_send_receive(sock, pubrec_packet2, pubrel_packet2, "pubrel2")
|
||||
sock.send(pubcomp_packet2)
|
||||
# Broker side of flow complete so can quit here.
|
||||
rc = 0
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
import struct
|
||||
|
||||
from mosq_test_helper import *
|
||||
from socket import error as SocketError
|
||||
import errno
|
||||
|
||||
rc = 1
|
||||
keepalive = 60
|
||||
@ -16,6 +18,11 @@ try:
|
||||
sock = mosq_test.do_client_connect(connect_packet, b"", timeout=30, port=port)
|
||||
rc = 0
|
||||
sock.close()
|
||||
except SocketError as e:
|
||||
if e.errno == errno.ECONNRESET:
|
||||
# Connection has been closed by peer (very quickly).
|
||||
# Fine, this is the expected behavior.
|
||||
rc = 0
|
||||
finally:
|
||||
broker.terminate()
|
||||
broker.wait()
|
||||
|
@ -106,7 +106,13 @@ def packet_matches(name, recvd, expected):
|
||||
|
||||
|
||||
def do_send_receive(sock, send_packet, receive_packet, error_string="send receive error"):
|
||||
sock.send(send_packet)
|
||||
size = len(send_packet)
|
||||
total_sent = 0
|
||||
while total_sent < size:
|
||||
sent = sock.send(send_packet[total_sent:])
|
||||
if sent == 0:
|
||||
raise RuntimeError("socket connection broken")
|
||||
total_sent += sent
|
||||
|
||||
if expect_packet(sock, error_string, receive_packet):
|
||||
return sock
|
||||
|
Loading…
Reference in New Issue
Block a user