Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ip_address as argument to listener #871

Draft
wants to merge 2 commits into
base: branch-0.28
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add tests to verify listener's IP/port binding
pentschev committed Aug 17, 2022
commit 60fb15eed22fa4ab950c98a05e0966d172784e68
38 changes: 38 additions & 0 deletions tests/test_listener.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pytest

import ucp


@pytest.mark.asyncio
async def test_bind_ip():
listener = ucp.create_listener(lambda: None, ip_address="127.0.0.1")

assert isinstance(listener.port, int)
assert listener.port >= 1024

assert isinstance(listener.ip, str)
assert listener.ip == "127.0.0.1"


@pytest.mark.asyncio
async def test_bind_port():
listener = None
port = None

for i in range(10000, 20000):
try:
listener = ucp.create_listener(
lambda: None,
i,
)
except ucp.UCXError:
# Port already in use, try another
continue
else:
port = i
break

assert isinstance(listener.port, int)
assert listener.port == port

assert isinstance(listener.ip, str)