Skip to content

Commit b9dda96

Browse files
committed
Fix Unix socket path too long in Nix build sandbox (use /tmp directly)
1 parent 60dcdbc commit b9dda96

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

pkgs/grpclib-nri/tests/conftest.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
import asyncio
55
import logging
6+
import shutil
7+
import tempfile
68
from pathlib import Path
7-
from typing import AsyncGenerator
9+
from typing import AsyncGenerator, Generator
810

911
import pytest
1012
import pytest_asyncio
@@ -30,9 +32,18 @@ def test_server_bin() -> Path:
3032

3133

3234
@pytest.fixture
33-
def socket_path(tmp_path: Path) -> Path:
34-
"""Create a unique socket path for each test."""
35-
return tmp_path / "nri.sock"
35+
def socket_path() -> Generator[Path, None, None]:
36+
"""Create a unique socket path for each test.
37+
38+
Uses /tmp directly instead of pytest's tmp_path because Unix sockets have
39+
a 108-byte path limit, and Nix build sandboxes set TMPDIR to a long path
40+
that causes bind() to fail with EINVAL.
41+
"""
42+
tmp_dir = Path(tempfile.mkdtemp(prefix="nri", dir="/tmp"))
43+
try:
44+
yield tmp_dir / "s"
45+
finally:
46+
shutil.rmtree(tmp_dir, ignore_errors=True)
3647

3748

3849
@pytest_asyncio.fixture
@@ -100,6 +111,7 @@ async def nri_server(
100111
"""
101112
logger = logging.getLogger("test.nri_server")
102113

114+
assert test_server_process.returncode is None, "Test server should still be running"
103115
plugin = DummyPlugin()
104116
server = NriServer(
105117
plugin,

0 commit comments

Comments
 (0)