STOMP: modernize Python test suite
* Upgrade to stomp.py 4.1.24 to gain Python 3.9 compatibility * Adjust to modern client/plugin disconnection delay * Remove tests that are not really possible to test with a regular well-behaved client (missed heartbeats)
This commit is contained in:
parent
e0d567828f
commit
3c38b42226
|
|
@ -1,5 +1,5 @@
|
|||
UPSTREAM_GIT=https://github.com/jasonrbriggs/stomp.py.git
|
||||
REVISION=v4.0.16
|
||||
REVISION=v4.1.24
|
||||
|
||||
LIB_DIR=stomppy
|
||||
CHECKOUT_DIR=stomppy-git
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ class BaseTest(unittest.TestCase):
|
|||
|
||||
def create_connection(self, user='guest', passcode='guest', wait=True, **kwargs):
|
||||
conn = self.create_connection_obj(**kwargs)
|
||||
conn.start()
|
||||
conn.connect(user, passcode, wait=wait)
|
||||
return conn
|
||||
|
||||
|
|
@ -112,8 +111,10 @@ class BaseTest(unittest.TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
if self.conn.is_connected():
|
||||
self.conn.disconnect()
|
||||
self.conn.stop()
|
||||
try:
|
||||
self.conn.disconnect()
|
||||
except:
|
||||
pass
|
||||
|
||||
def simple_test_send_rec(self, dest, headers={}):
|
||||
self.listener.reset()
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ class TestConnectOptions(base.BaseTest):
|
|||
new_conn = stomp.Connection(host_and_ports=[('localhost', int(os.environ["STOMP_PORT"]))])
|
||||
new_conn.set_listener('', listener)
|
||||
|
||||
new_conn.start() # not going to issue connect
|
||||
new_conn.transport.start()
|
||||
|
||||
self.subscribe_dest(new_conn, "/topic/implicit", 'sub_implicit',
|
||||
receipt='implicit')
|
||||
|
||||
|
|
@ -41,7 +42,6 @@ class TestConnectOptions(base.BaseTest):
|
|||
listener = base.WaitableListener()
|
||||
new_conn = stomp.Connection(host_and_ports=[('localhost', int(os.environ["STOMP_PORT"]))])
|
||||
new_conn.set_listener('', listener)
|
||||
new_conn.start()
|
||||
new_conn.connect()
|
||||
try:
|
||||
self.assertFalse(listener.wait(3)) # no error back
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ class TestLifecycle(base.BaseTest):
|
|||
self.assertTrue(new_conn.is_connected())
|
||||
finally:
|
||||
new_conn.disconnect()
|
||||
self.assertFalse(new_conn.is_connected())
|
||||
|
||||
def test_connect_version_1_1(self):
|
||||
''' Test CONNECT with version 1.1'''
|
||||
|
|
@ -70,7 +69,6 @@ class TestLifecycle(base.BaseTest):
|
|||
self.assertTrue(new_conn.is_connected())
|
||||
finally:
|
||||
new_conn.disconnect()
|
||||
self.assertFalse(new_conn.is_connected())
|
||||
|
||||
def test_connect_version_1_2(self):
|
||||
''' Test CONNECT with version 1.2'''
|
||||
|
|
@ -80,22 +78,10 @@ class TestLifecycle(base.BaseTest):
|
|||
self.assertTrue(new_conn.is_connected())
|
||||
finally:
|
||||
new_conn.disconnect()
|
||||
# connections are closed asynchronously, e.g. a few seconds later
|
||||
time.sleep(6)
|
||||
self.assertFalse(new_conn.is_connected())
|
||||
|
||||
def test_heartbeat_disconnects_client(self):
|
||||
''' Test heart-beat disconnection'''
|
||||
self.conn.disconnect()
|
||||
new_conn = self.create_connection(version='1.1', heartbeats=(1500, 0))
|
||||
try:
|
||||
self.assertTrue(new_conn.is_connected())
|
||||
time.sleep(1)
|
||||
self.assertTrue(new_conn.is_connected())
|
||||
time.sleep(3)
|
||||
self.assertFalse(new_conn.is_connected())
|
||||
finally:
|
||||
if new_conn.is_connected():
|
||||
new_conn.disconnect()
|
||||
|
||||
def test_unsupported_version(self):
|
||||
''' Test unsupported version on CONNECT command'''
|
||||
self.bad_connect("Supported versions are 1.0,1.1,1.2\n", version='100.1')
|
||||
|
|
@ -118,7 +104,6 @@ class TestLifecycle(base.BaseTest):
|
|||
listener = base.WaitableListener()
|
||||
new_conn.set_listener('', listener)
|
||||
try:
|
||||
new_conn.start()
|
||||
new_conn.connect(user, passcode)
|
||||
self.assertTrue(listener.wait())
|
||||
self.assertEquals(expected, listener.errors[0]['message'])
|
||||
|
|
@ -151,6 +136,8 @@ class TestLifecycle(base.BaseTest):
|
|||
def test_disconnect(self):
|
||||
''' Test DISCONNECT command'''
|
||||
self.conn.disconnect()
|
||||
# connections are closed asynchronously, e.g. a few seconds later
|
||||
time.sleep(7)
|
||||
self.assertFalse(self.conn.is_connected())
|
||||
|
||||
def test_disconnect_with_receipt(self):
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ class TestSslClient(unittest.TestCase):
|
|||
ssl_cert_file = ssl_cert_file,
|
||||
ssl_ca_certs = ssl_ca_certs)
|
||||
print("FILE: ".format(ssl_cert_file))
|
||||
conn.start()
|
||||
conn.connect("guest", "guest")
|
||||
return conn
|
||||
|
||||
|
|
@ -37,7 +36,6 @@ class TestSslClient(unittest.TestCase):
|
|||
use_ssl = True, ssl_key_file = ssl_key_file,
|
||||
ssl_cert_file = ssl_cert_file,
|
||||
ssl_ca_certs = ssl_ca_certs)
|
||||
conn.start()
|
||||
conn.connect()
|
||||
return conn
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ def disable_default_user():
|
|||
def switch_config(implicit_connect='', default_user=''):
|
||||
cmd = ''
|
||||
cmd += 'ok = io:format("~n===== Ranch listeners (before stop) =====~n~n~p~n", [ranch:info()]),'
|
||||
cmd += 'ok = application:stop(rabbitmq_stomp),'
|
||||
cmd += '_ = application:stop(rabbitmq_stomp),'
|
||||
cmd += 'io:format("~n===== Ranch listeners (after stop) =====~n~n~p~n", [ranch:info()]),'
|
||||
if implicit_connect:
|
||||
cmd += 'ok = application:set_env(rabbitmq_stomp,implicit_connect,{}),'.format(implicit_connect)
|
||||
if default_user:
|
||||
cmd += 'ok = application:set_env(rabbitmq_stomp,default_user,{}),'.format(default_user)
|
||||
cmd += 'ok = application:start(rabbitmq_stomp),'
|
||||
cmd += '_ = application:start(rabbitmq_stomp),'
|
||||
cmd += 'io:format("~n===== Ranch listeners (after start) =====~n~n~p~n", [ranch:info()]).'
|
||||
rabbitmqctl(['eval', cmd])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue