[verified] fix: preserve tracker precision eligibility
This commit is contained in:
@@ -553,9 +553,23 @@ def test_legacy_start_falls_back_to_env_tracker_and_model(monkeypatch):
|
||||
assert captured["model_id"] == "Qwen/Qwen2.5-0.5B-Instruct"
|
||||
|
||||
|
||||
def test_legacy_start_without_port_uses_next_available_port(monkeypatch):
|
||||
"Omitting --port skips an occupied default port before startup loads the model.\n\nTags: general"
|
||||
from meshnet_node.cli import main
|
||||
def test_first_available_port_skips_an_occupied_custom_port():
|
||||
"Port search skips an occupied custom base port.\n\nTags: general"
|
||||
from meshnet_node.cli import _first_available_port
|
||||
|
||||
occupied = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
occupied.bind(("127.0.0.1", 0))
|
||||
start = occupied.getsockname()[1]
|
||||
occupied.listen(1)
|
||||
try:
|
||||
assert _first_available_port("127.0.0.1", start=start, attempts=100) > start
|
||||
finally:
|
||||
occupied.close()
|
||||
|
||||
|
||||
def test_legacy_start_without_port_uses_port_search(monkeypatch):
|
||||
"Omitting --port delegates legacy startup to the port-search helper.\n\nTags: general"
|
||||
from meshnet_node import cli as cli_mod
|
||||
|
||||
captured = {}
|
||||
|
||||
@@ -566,26 +580,20 @@ def test_legacy_start_without_port_uses_next_available_port(monkeypatch):
|
||||
def stop(self): pass
|
||||
return _FakeNode()
|
||||
|
||||
occupied = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
occupied.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
occupied.bind(("127.0.0.1", 7000))
|
||||
occupied.listen(1)
|
||||
try:
|
||||
monkeypatch.setattr(sys, "argv", [
|
||||
"meshnet-node", "start",
|
||||
"--tracker", "http://192.168.0.179:8081",
|
||||
"--model", "Qwen/Qwen2.5-0.5B-Instruct",
|
||||
"--host", "127.0.0.1",
|
||||
])
|
||||
monkeypatch.setattr(cli_mod, "_first_available_port", lambda *_args, **_kwargs: 7001)
|
||||
monkeypatch.setattr(sys, "argv", [
|
||||
"meshnet-node", "start",
|
||||
"--tracker", "http://192.168.0.179:8081",
|
||||
"--model", "Qwen/Qwen2.5-0.5B-Instruct",
|
||||
"--host", "127.0.0.1",
|
||||
])
|
||||
|
||||
with patch("meshnet_node.startup.run_startup", side_effect=fake_run_startup):
|
||||
with patch("time.sleep", side_effect=KeyboardInterrupt):
|
||||
try:
|
||||
main()
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 0
|
||||
finally:
|
||||
occupied.close()
|
||||
with patch("meshnet_node.startup.run_startup", side_effect=fake_run_startup):
|
||||
with patch("time.sleep", side_effect=KeyboardInterrupt):
|
||||
try:
|
||||
cli_mod.main()
|
||||
except SystemExit as exc:
|
||||
assert exc.code == 0
|
||||
|
||||
assert captured["port"] == 7001
|
||||
|
||||
|
||||
Reference in New Issue
Block a user