Skip to content

Commit

Permalink
IPC on windows cannot use socket paths
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch authored and Joe Eacott committed Jun 8, 2021
1 parent 8dd7bf0 commit aa7c5f0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/pytests/unit/transport/test_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
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():
"The connect method is in IPCMessageSubscriber's async_methods property"
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()

0 comments on commit aa7c5f0

Please sign in to comment.