Skip to content

Commit 4120d26

Browse files
committed
Fix weird test timeouts on Python 3.12
Any test involving snmpsim on Python 3.12 suddenly started becoming flaky and time out, with no changes to the netsnmp-cffi codebase. Increasing the SNMP timeouts for these tests seems to help.
1 parent 9e9be8f commit 4120d26

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def _verify_localhost_snmp_response(port: int):
1717
from netsnmpy import session
1818

1919
try:
20-
sess = session.SNMPSession(host="localhost", port=port, version=2)
20+
sess = session.SNMPSession(host="localhost", port=port, version=2, timeout=5)
2121
sess.open()
2222
sysobjectid0 = OID(".1.3.6.1.2.1.1.2.0")
2323
return await sess.aget(sysobjectid0)
@@ -42,6 +42,7 @@ async def snmpsim(snmpsimd_path, snmp_fixture_directory, snmp_test_port):
4242
@retry(Exception, tries=3, delay=0.5, backoff=2)
4343
async def _wait_for_snmpsimd():
4444
if await _verify_localhost_snmp_response(snmp_test_port):
45+
print("snmpsimd is responding to queries")
4546
return True
4647
else:
4748
raise TimeoutError("Still waiting for snmpsimd to listen for queries")

tests/test_session.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ def test_when_snmp_version_is_invalid_it_should_raise_valueerror():
102102
def simple_localhost_session(snmpsim, snmp_test_port):
103103
netsnmp.load_mibs()
104104
sess = session.SNMPSession(
105-
host="localhost", port=snmp_test_port, version=2, community="public"
105+
host="localhost",
106+
port=snmp_test_port,
107+
version=2,
108+
community="public",
109+
timeout=5,
106110
)
107111
sess.open()
108112
yield sess

0 commit comments

Comments
 (0)