Connect callback closes it's request channel

This commit is contained in:
Daniel A. Wozniak 2023-11-02 15:11:39 -07:00 committed by Pedro Algarvio
parent 84c6b703c2
commit be5ef66a3a
3 changed files with 25 additions and 1 deletions

1
changelog/65464.fixed.md Normal file
View file

@ -0,0 +1 @@
Publish channel connect callback method properly closes it's request channel.

View file

@ -564,7 +564,7 @@ class AsyncPubChannel:
log.info("fire_master failed", exc_info=True)
finally:
# SyncWrapper will call either close() or destroy(), whichever is available
del req_channel
req_channel.close()
else:
self._reconnected = True
except Exception as exc: # pylint: disable=broad-except

View file

@ -0,0 +1,23 @@
import salt.channel.client
from tests.support.mock import MagicMock, patch
async def test_async_pub_channel_connect_cb(minion_opts):
"""
Validate connect_callback closes the request channel it creates.
"""
minion_opts["master_uri"] = "tcp://127.0.0.1:4506"
minion_opts["master_ip"] = "127.0.0.1"
channel = salt.channel.client.AsyncPubChannel.factory(minion_opts)
async def send_id(*args):
return
channel.send_id = send_id
channel._reconnected = True
mock = MagicMock(salt.channel.client.AsyncReqChannel)
with patch("salt.channel.client.AsyncReqChannel.factory", return_value=mock):
await channel.connect_callback(None)
mock.send.assert_called_once()
mock.close.assert_called_once()