IPC on windows cannot use socket paths

Fixes #60298
This commit is contained in:
Pedro Algarvio 2021-06-02 18:19:46 +01:00 committed by Megan Wilhite
parent 40d24844cb
commit 4f49389e6d

View file

@ -2,6 +2,8 @@ import pytest
import salt.ext.tornado.iostream
import salt.transport.ipc
import salt.utils.asynchronous
import salt.utils.platform
from saltfactories.utils.ports import get_unused_localhost_port
def test_ipc_connect_in_async_methods():
@ -9,14 +11,21 @@ def test_ipc_connect_in_async_methods():
assert "connect" in salt.transport.ipc.IPCMessageSubscriber.async_methods
def test_ipc_connect_sync_wrapped():
async def test_ipc_connect_sync_wrapped(io_loop, tmp_path):
"""
Ensure IPCMessageSubscriber.connect gets wrapped by
salt.utils.asynchronous.SyncWrapper.
"""
puburi = "/tmp/noexist.ipc"
if salt.utils.platform.is_windows():
socket_path = get_unused_localhost_port()
else:
socket_path = str(tmp_path / "noexist.ipc")
subscriber = salt.utils.asynchronous.SyncWrapper(
salt.transport.ipc.IPCMessageSubscriber, args=(puburi,), loop_kwarg="io_loop",
salt.transport.ipc.IPCMessageSubscriber,
args=(socket_path,),
kwargs={"io_loop": io_loop},
loop_kwarg="io_loop",
)
with pytest.raises(salt.ext.tornado.iostream.StreamClosedError):
# Don't `await subscriber.connect()`, that's the purpose of the SyncWrapper
subscriber.connect()