mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Connect callback closes it's request channel
This commit is contained in:
parent
84c6b703c2
commit
be5ef66a3a
3 changed files with 25 additions and 1 deletions
1
changelog/65464.fixed.md
Normal file
1
changelog/65464.fixed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Publish channel connect callback method properly closes it's request channel.
|
|
@ -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
|
||||
|
|
23
tests/pytests/functional/channel/test_client.py
Normal file
23
tests/pytests/functional/channel/test_client.py
Normal 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()
|
Loading…
Add table
Reference in a new issue