Fix tests where broker suddenly disconnects client

This seems to be required just on more modern Python versions.
This commit is contained in:
Roger A. Light 2019-11-06 14:07:07 +00:00
parent aceabcdef2
commit 28c11f4cce
10 changed files with 29 additions and 13 deletions

View File

@ -22,8 +22,10 @@ try:
sock.close()
if len(data) == 0:
rc = 0
except socket.error:
rc = 0
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()
broker.wait()

View File

@ -3,8 +3,6 @@
# 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
@ -17,10 +15,9 @@ try:
sock = mosq_test.do_client_connect(connect_packet, b"", port=port)
sock.close()
rc = 0
except SocketError as e:
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer (very quickly).
# Fine, this is the expected behavior.
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()

View File

@ -51,6 +51,10 @@ try:
rc = 0
sock.close()
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()
broker.wait()

View File

@ -47,6 +47,10 @@ try:
rc = 0
sock.close()
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()
broker.wait()

View File

@ -50,6 +50,10 @@ try:
rc = 0
sock.close()
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()
broker.wait()

View File

@ -53,6 +53,10 @@ try:
rc = 0
sock.close()
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()
broker.wait()

View File

@ -50,6 +50,10 @@ try:
rc = 0
sock.close()
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()
broker.wait()

View File

@ -3,8 +3,6 @@
import struct
from mosq_test_helper import *
from socket import error as SocketError
import errno
rc = 1
keepalive = 60
@ -18,10 +16,9 @@ try:
sock = mosq_test.do_client_connect(connect_packet, b"", timeout=30, port=port)
rc = 0
sock.close()
except SocketError as e:
except socket.error as e:
if e.errno == errno.ECONNRESET:
# Connection has been closed by peer (very quickly).
# Fine, this is the expected behavior.
# Connection has been closed by peer, this is the expected behaviour
rc = 0
finally:
broker.terminate()

View File

@ -3,7 +3,6 @@
# Test whether a client can connect without an SSL certificate if one is required.
from mosq_test_helper import *
import errno
if sys.version < '2.7':
print("WARNING: SSL not supported on Python 2.6")

View File

@ -15,3 +15,4 @@ import ssl
import struct
import subprocess
import time
import errno