rabbit: improvements to QoS
- Don't call _set_qos from both ensure_connection and on_reconnection, instead consolidate and only call from _set_current_channel - Only set QoS on PURPOSE_LISTEN connections. It's a waste of a roundtrip to call it on PURPOSE_SEND connections and slows things down unnecessarily - Guard against rabbit_qos_prefetch_count being set to a negative value - Tests, because we love them Change-Id: I365414c541d895dcd49ebcd32c3a456a92c392d6
This commit is contained in:
@@ -109,6 +109,31 @@ class TestHeartbeat(test_utils.BaseTestCase):
|
||||
'trying to reconnect: %s')
|
||||
|
||||
|
||||
class TestRabbitQos(test_utils.BaseTestCase):
|
||||
|
||||
def connection_with(self, prefetch, purpose):
|
||||
self.config(rabbit_qos_prefetch_count=prefetch,
|
||||
group="oslo_messaging_rabbit")
|
||||
transport = oslo_messaging.get_transport(self.conf,
|
||||
'kombu+memory:////')
|
||||
transport._driver._get_connection(purpose)
|
||||
|
||||
@mock.patch('kombu.transport.memory.Channel.basic_qos')
|
||||
def test_qos_sent_on_listen_connection(self, fake_basic_qos):
|
||||
self.connection_with(prefetch=1, purpose=driver_common.PURPOSE_LISTEN)
|
||||
fake_basic_qos.assert_called_once_with(0, 1, False)
|
||||
|
||||
@mock.patch('kombu.transport.memory.Channel.basic_qos')
|
||||
def test_qos_not_sent_when_cfg_zero(self, fake_basic_qos):
|
||||
self.connection_with(prefetch=0, purpose=driver_common.PURPOSE_LISTEN)
|
||||
fake_basic_qos.assert_not_called()
|
||||
|
||||
@mock.patch('kombu.transport.memory.Channel.basic_qos')
|
||||
def test_qos_not_sent_on_send_connection(self, fake_basic_qos):
|
||||
self.connection_with(prefetch=1, purpose=driver_common.PURPOSE_SEND)
|
||||
fake_basic_qos.assert_not_called()
|
||||
|
||||
|
||||
class TestRabbitDriverLoad(test_utils.BaseTestCase):
|
||||
|
||||
scenarios = [
|
||||
|
||||
Reference in New Issue
Block a user