|
10 | 10 |
|
11 | 11 | import pytest
|
12 | 12 | import torch
|
| 13 | +import zmq |
13 | 14 | from vllm_test_utils.monitor import monitor
|
14 | 15 |
|
15 | 16 | from vllm.config import ParallelConfig, VllmConfig, set_current_vllm_config
|
16 | 17 | from vllm.utils import (CacheInfo, FlexibleArgumentParser, LRUCache,
|
17 | 18 | MemorySnapshot, PlaceholderModule, StoreBoolean,
|
18 | 19 | bind_kv_cache, deprecate_kwargs, get_open_port,
|
19 | 20 | memory_profiling, merge_async_iterators, sha256,
|
20 |
| - supports_kw, swap_dict_values) |
| 21 | + split_zmq_path, supports_kw, swap_dict_values) |
21 | 22 |
|
22 | 23 | from .utils import create_new_process_for_each_test, error_on_warning
|
23 | 24 |
|
@@ -662,3 +663,46 @@ def test_sha256(input: tuple, output: int):
|
662 | 663 |
|
663 | 664 | # hashing different input, returns different value
|
664 | 665 | assert hash != sha256(input + (1, ))
|
| 666 | + |
| 667 | + |
| 668 | +@pytest.mark.parametrize( |
| 669 | + "path,expected", |
| 670 | + [ |
| 671 | + ("ipc://some_path", ("ipc", "some_path", "")), |
| 672 | + ("tcp://127.0.0.1:5555", ("tcp", "127.0.0.1", "5555")), |
| 673 | + ("tcp://[::1]:5555", ("tcp", "::1", "5555")), # IPv6 address |
| 674 | + ("inproc://some_identifier", ("inproc", "some_identifier", "")), |
| 675 | + ] |
| 676 | +) |
| 677 | +def test_split_zmq_path(path, expected): |
| 678 | + assert split_zmq_path(path) == expected |
| 679 | + |
| 680 | + |
| 681 | +@pytest.mark.parametrize( |
| 682 | + "invalid_path", |
| 683 | + [ |
| 684 | + "invalid_path", # Missing scheme |
| 685 | + "tcp://127.0.0.1", # Missing port |
| 686 | + "tcp://[::1]", # Missing port for IPv6 |
| 687 | + "tcp://:5555", # Missing host |
| 688 | + ] |
| 689 | +) |
| 690 | +def test_split_zmq_path_invalid(invalid_path): |
| 691 | + with pytest.raises(ValueError): |
| 692 | + split_zmq_path(invalid_path) |
| 693 | + |
| 694 | + |
| 695 | +def test_make_zmq_socket_ipv6(): |
| 696 | + ctx = zmq.Context() |
| 697 | + ipv6_path = "tcp://[::1]:5555" # IPv6 loopback address |
| 698 | + socket_type = zmq.REP # Example socket type |
| 699 | + |
| 700 | + # Create the socket |
| 701 | + socket = make_zmq_socket(ctx, ipv6_path, socket_type) |
| 702 | + |
| 703 | + # Verify that the IPV6 option is set |
| 704 | + assert socket.getsockopt(zmq.IPV6) == 1, "IPV6 option should be enabled for IPv6 addresses" |
| 705 | + |
| 706 | + # Clean up |
| 707 | + socket.close() |
| 708 | + ctx.term() |
0 commit comments