tests: drivers that are not closed open a real socket to 192.168.1.1:80 when garbage-collected #17

Closed
opened 2026-11-02 09:25:51 +00:00 by christianmanivong · 0 comments
Owner

What happens

ZyxelVMGDriver.is_alive() (napalm_zyxel/zyxel_driver.py:212) opens a real TCP connection:

sock = socket.create_connection((self.hostname, self.port), timeout=5)

NAPALM's NetworkDriver.__del__ calls is_alive(), so every driver instance in tests/test_zyxel.py that is garbage-collected without having been closed (e.g. the one built at line 486) connects to 192.168.1.1:80 — against the standard's "tests never open a socket". Profiling a test run shows base.py:95(__del__) → socket.connect. Same cause as NAPALM/napalm-fritzbox#11.

Expected

The tests close every driver they build (or patch socket.create_connection for the module); a session-wide no-socket guard in tests/conftest.py (as fritzbox#11 added) keeps it that way.

Priority: P4 — non-hermetic unit tests.

Found during the bug sweep of 2026-11-02 (#15).

## What happens `ZyxelVMGDriver.is_alive()` (`napalm_zyxel/zyxel_driver.py:212`) opens a real TCP connection: ```python sock = socket.create_connection((self.hostname, self.port), timeout=5) ``` NAPALM's `NetworkDriver.__del__` calls `is_alive()`, so every driver instance in `tests/test_zyxel.py` that is garbage-collected without having been closed (e.g. the one built at line 486) connects to 192.168.1.1:80 — against the standard's "tests never open a socket". Profiling a test run shows `base.py:95(__del__)` → `socket.connect`. Same cause as NAPALM/napalm-fritzbox#11. ## Expected The tests close every driver they build (or patch `socket.create_connection` for the module); a session-wide no-socket guard in `tests/conftest.py` (as fritzbox#11 added) keeps it that way. Priority: P4 — non-hermetic unit tests. Found during the bug sweep of 2026-11-02 (#15).
christianmanivong added the
prio
P4
bug
labels 2026-11-02 09:25:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-zyxel#17