Skip to content

Commit

Permalink
ip test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGlobus committed Nov 22, 2024
1 parent cfe5f06 commit 10bced0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ def __init__(
self._task_counter = 0

try:
# 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(
Expand Down Expand Up @@ -431,7 +434,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": "localhost", # 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(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_bad_endpoint_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
_MOCK_BASE = "globus_compute_endpoint.engines.high_throughput.engine."


@pytest.mark.parametrize("address", ("localhost", "login1.theta.alcf.anl.gov", "*"))
@pytest.mark.parametrize("address", ("example.com", "login1.theta.alcf.anl.gov", "*"))
def test_invalid_address(address, htex_warns):
with mock.patch(f"{_MOCK_BASE}log") as mock_log:
with pytest.raises(ValueError):
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ New Functionality
.. code-block:: python
engine = GlobusComputeEngine(
address="localhost",
address="127.0.0.1",
heartbeat_period_s=1,
heartbeat_threshold=1,
provider=LocalProvider(
Expand Down

0 comments on commit 10bced0

Please sign in to comment.