File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import asyncio
55import logging
6+ import shutil
7+ import tempfile
68from pathlib import Path
7- from typing import AsyncGenerator
9+ from typing import AsyncGenerator , Generator
810
911import pytest
1012import 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 ,
You can’t perform that action at this time.
0 commit comments