athenad: fix test timeouts and comments (#31540)

* these pass in 0.5s since server sends ping on connect

* comments

* unused

* fix

* fix these too

* check end_event while uploading, throw abort exception if we need to shut down/restart

* Revert "check end_event while uploading, throw abort exception if we need to shut down/restart"

This reverts commit f0b822fca9.

* more tol for lte connection
pull/31543/head
Shane Smiskol 1 year ago committed by GitHub
parent 9dde727974
commit c0e172e0c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      selfdrive/athena/athenad.py
  2. 8
      selfdrive/athena/tests/test_athenad_ping.py

@ -746,6 +746,9 @@ def ws_manage(ws: WebSocket, end_event: threading.Event) -> None:
onroad_prev = onroad
if sock is not None:
# While not sending data, onroad, we can expect to time out in 7 + (7 * 2) = 21s
# offroad, we can expect to time out in 30 + (10 * 3) = 60s
# FIXME: TCP_USER_TIMEOUT is effectively 2x for some reason (32s), so it's mostly unused
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, 16000 if onroad else 0)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 7 if onroad else 30)
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 7 if onroad else 10)

@ -12,6 +12,8 @@ from openpilot.selfdrive.athena import athenad
from openpilot.selfdrive.manager.helpers import write_onroad_params
from openpilot.system.hardware import TICI
TIMEOUT_TOLERANCE = 20 # seconds
def wifi_radio(on: bool) -> None:
if not TICI:
@ -63,7 +65,7 @@ class TestAthenadPing(unittest.TestCase):
mock_create_connection.assert_called_once()
mock_create_connection.reset_mock()
# check normal behaviour
# check normal behaviour, server pings on connection
with self.subTest("Wi-Fi: receives ping"), Timeout(70, "no ping received"):
while not self._received_ping():
time.sleep(0.1)
@ -92,12 +94,12 @@ class TestAthenadPing(unittest.TestCase):
@unittest.skipIf(not TICI, "only run on desk")
def test_offroad(self) -> None:
write_onroad_params(False, self.params)
self.assertTimeout(100) # expect approx 90s
self.assertTimeout(60 + TIMEOUT_TOLERANCE) # based using TCP keepalive settings
@unittest.skipIf(not TICI, "only run on desk")
def test_onroad(self) -> None:
write_onroad_params(True, self.params)
self.assertTimeout(30) # expect 20-30s
self.assertTimeout(21 + TIMEOUT_TOLERANCE)
if __name__ == "__main__":

Loading…
Cancel
Save