Skip to content

Commit

Permalink
ip test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGlobus committed Nov 19, 2024
1 parent 772dc52 commit 814b676
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def __init__(
# Tuning info
prefetch_capacity=10,
provider=LocalProvider(),
address="localhost",
address="0:0:0:0:0:0:0:1",
worker_ports=None,
worker_port_range=(54000, 55000),
interchange_port_range=(55000, 56000),
Expand Down Expand Up @@ -300,7 +300,10 @@ def __init__(
self._task_counter = 0

try:
ipaddress.ip_address(address=address)
if address != "localhost":
# 'localhost' works for both v4 and v6 in some circumstances
# where an actual numeric IP isn't required
ipaddress.ip_address(address=address)
except Exception:
log.critical(
f"Invalid address supplied: {address}. "
Expand Down Expand Up @@ -376,14 +379,10 @@ def start(
self.run_dir = run_dir
self.endpoint_id = endpoint_id

self.outgoing_q = zmq_pipes.TasksOutgoing(
"localhost", self.interchange_port_range
)
self.incoming_q = zmq_pipes.ResultsIncoming(
"localhost", self.interchange_port_range
)
self.outgoing_q = zmq_pipes.TasksOutgoing("::1", self.interchange_port_range)
self.incoming_q = zmq_pipes.ResultsIncoming("::1", self.interchange_port_range)
self.command_client = zmq_pipes.CommandClient(
"localhost", self.interchange_port_range
"::1", self.interchange_port_range
)

self.is_alive = True
Expand Down Expand Up @@ -431,7 +430,7 @@ def _start_local_interchange_process(self):
name="Engine-Interchange",
args=(comm_q,),
kwargs={
"client_address": "localhost", # engine and ix are on the same node
"client_address": "0:0:0:0:0:0:0:1", # engine and ix are on same node
"client_ports": (
self.outgoing_q.port,
self.incoming_q.port,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
log = logging.getLogger(__name__)


def remap_ipv6_loopback(self, ip_address):
# Special case for being compatible with ipv4 and v6
if ip_address == "::1":
ip_address = "localhost"
return f"tcp://{ip_address}"


class CommandClient:
"""CommandClient"""

Expand All @@ -24,11 +31,12 @@ def __init__(self, ip_address, port_range):
Port range for the comms between client and interchange
"""

self.context = zmq.Context()
self.zmq_socket = self.context.socket(zmq.DEALER)
self.zmq_socket.set_hwm(0)
self.port = self.zmq_socket.bind_to_random_port(
f"tcp://{ip_address}",
remap_ipv6_loopback(ip_address),
min_port=port_range[0],
max_port=port_range[1],
)
Expand Down Expand Up @@ -68,8 +76,9 @@ def __init__(self, ip_address, port_range):
self.context = zmq.Context()
self.zmq_socket = self.context.socket(zmq.DEALER)
self.zmq_socket.set_hwm(0)

self.port = self.zmq_socket.bind_to_random_port(
f"tcp://{ip_address}",
remap_ipv6_loopback(ip_address),
min_port=port_range[0],
max_port=port_range[1],
)
Expand Down Expand Up @@ -144,7 +153,7 @@ def __init__(self, ip_address, port_range):
self.results_receiver = self.context.socket(zmq.DEALER)
self.results_receiver.set_hwm(0)
self.port = self.results_receiver.bind_to_random_port(
f"tcp://{ip_address}",
remap_ipv6_loopback(ip_address),
min_port=port_range[0],
max_port=port_range[1],
)
Expand Down
2 changes: 1 addition & 1 deletion compute_endpoint/tests/unit/test_htex.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_engine_submit_container_location(

@pytest.mark.parametrize("task_id", (str(uuid.uuid4()), None))
def test_engine_invalid_result_data(task_id: t.Optional[str]):
htex = HighThroughputEngine(address="localhost")
htex = HighThroughputEngine(address="0:0:0:0:0:0:0:1")
htex.incoming_q = mock.MagicMock()
htex.results_passthrough = mock.MagicMock()
htex.tasks = mock.MagicMock()
Expand Down

0 comments on commit 814b676

Please sign in to comment.