Syndic's async request channel is actually async

This commit is contained in:
Daniel A. Wozniak 2023-08-26 01:22:29 -07:00 committed by Pedro Algarvio
parent ed9d866b62
commit 771abcb739
4 changed files with 29 additions and 1 deletions

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

@ -0,0 +1 @@
Syndic's async_req_channel uses the asynchornous version of request channel

View file

@ -3399,7 +3399,7 @@ class Syndic(Minion):
# add handler to subscriber
self.pub_channel.on_recv(self._process_cmd_socket)
self.req_channel = salt.channel.client.ReqChannel.factory(self.opts)
self.async_req_channel = salt.channel.client.ReqChannel.factory(self.opts)
self.async_req_channel = salt.channel.client.AsyncReqChannel.factory(self.opts)
def _process_cmd_socket(self, payload):
if payload is not None and payload["enc"] == "aes":

View file

@ -35,3 +35,21 @@ def master_opts(tmp_path):
opts[name] = str(dirpath)
opts["log_file"] = "logs/master.log"
return opts
@pytest.fixture
def syndic_opts(tmp_path):
"""
Default master configuration with relative temporary paths to not require root permissions.
"""
root_dir = tmp_path / "syndic"
opts = salt.config.DEFAULT_MINION_OPTS.copy()
opts["syndic_master"] = "127.0.0.1"
opts["__role"] = "minion"
opts["root_dir"] = str(root_dir)
for name in ("cachedir", "pki_dir", "sock_dir", "conf_dir"):
dirpath = root_dir / name
dirpath.mkdir(parents=True)
opts[name] = str(dirpath)
opts["log_file"] = "logs/syndic.log"
return opts

View file

@ -1100,3 +1100,12 @@ async def test_master_type_disable(minion_opts):
assert minion.connected is False
finally:
minion.destroy()
async def test_syndic_async_req_channel(syndic_opts):
syndic_opts["_minion_conf_file"] = ""
syndic_opts["master_uri"] = "tcp://127.0.0.1:4506"
syndic = salt.minion.Syndic(syndic_opts)
syndic.pub_channel = MagicMock()
syndic.tune_in_no_block()
assert isinstance(syndic.async_req_channel, salt.channel.client.AsyncReqChannel)