ci: faster test_camerad (#33933)

* once

* timeout
pull/33935/head
Maxime Desroches 6 months ago committed by GitHub
parent 5a06d1df43
commit 39dbee0329
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      Jenkinsfile
  2. 27
      system/camerad/test/test_camerad.py

4
Jenkinsfile vendored

@ -221,12 +221,12 @@ node {
'camerad': { 'camerad': {
deviceStage("AR0231", "tici-ar0231", ["UNSAFE=1"], [ deviceStage("AR0231", "tici-ar0231", ["UNSAFE=1"], [
step("build", "cd system/manager && ./build.py"), step("build", "cd system/manager && ./build.py"),
step("test camerad", "pytest system/camerad/test/test_camerad.py"), step("test camerad", "pytest system/camerad/test/test_camerad.py", [timeout: 60]),
step("test exposure", "pytest system/camerad/test/test_exposure.py"), step("test exposure", "pytest system/camerad/test/test_exposure.py"),
]) ])
deviceStage("OX03C10", "tici-ox03c10", ["UNSAFE=1"], [ deviceStage("OX03C10", "tici-ox03c10", ["UNSAFE=1"], [
step("build", "cd system/manager && ./build.py"), step("build", "cd system/manager && ./build.py"),
step("test camerad", "pytest system/camerad/test/test_camerad.py"), step("test camerad", "pytest system/camerad/test/test_camerad.py", [timeout: 60]),
step("test exposure", "pytest system/camerad/test/test_exposure.py"), step("test exposure", "pytest system/camerad/test/test_exposure.py"),
]) ])
}, },

@ -21,39 +21,40 @@ CAMERAS = ('roadCameraState', 'driverCameraState', 'wideRoadCameraState')
@flaky(max_runs=3) @flaky(max_runs=3)
@pytest.mark.tici @pytest.mark.tici
class TestCamerad: class TestCamerad:
def setup_method(self): @classmethod
def setup_class(cls):
# run camerad and record logs # run camerad and record logs
managed_processes['camerad'].start() managed_processes['camerad'].start()
time.sleep(3) time.sleep(3)
socks = {c: messaging.sub_sock(c, conflate=False, timeout=100) for c in CAMERAS} socks = {c: messaging.sub_sock(c, conflate=False, timeout=100) for c in CAMERAS}
self.logs = defaultdict(list) cls.logs = defaultdict(list)
start_time = time.monotonic() start_time = time.monotonic()
while time.monotonic()- start_time < TEST_TIMESPAN: while time.monotonic()- start_time < TEST_TIMESPAN:
for cam, s in socks.items(): for cam, s in socks.items():
self.logs[cam] += messaging.drain_sock(s) cls.logs[cam] += messaging.drain_sock(s)
time.sleep(0.2) time.sleep(0.2)
managed_processes['camerad'].stop() managed_processes['camerad'].stop()
self.log_by_frame_id = defaultdict(list) cls.log_by_frame_id = defaultdict(list)
self.sensor_type = None cls.sensor_type = None
for cam, msgs in self.logs.items(): for cam, msgs in cls.logs.items():
if self.sensor_type is None: if cls.sensor_type is None:
self.sensor_type = getattr(msgs[0], msgs[0].which()).sensor.raw cls.sensor_type = getattr(msgs[0], msgs[0].which()).sensor.raw
expected_frames = SERVICE_LIST[cam].frequency * TEST_TIMESPAN expected_frames = SERVICE_LIST[cam].frequency * TEST_TIMESPAN
assert expected_frames*0.95 < len(msgs) < expected_frames*1.05, f"unexpected frame count {cam}: {expected_frames=}, got {len(msgs)}" assert expected_frames*0.95 < len(msgs) < expected_frames*1.05, f"unexpected frame count {cam}: {expected_frames=}, got {len(msgs)}"
dts = np.abs(np.diff([getattr(m, m.which()).timestampSof/1e6 for m in msgs]) - 1000/SERVICE_LIST[cam].frequency) dts = np.abs(np.diff([getattr(m, m.which()).timestampSof/1e6 for m in msgs]) - 1000/SERVICE_LIST[cam].frequency)
assert (dts < FRAME_DELTA_TOLERANCE[self.sensor_type]).all(), f"{cam} dts(ms) out of spec: max diff {dts.max()}, 99 percentile {np.percentile(dts, 99)}" assert (dts < FRAME_DELTA_TOLERANCE[cls.sensor_type]).all(), f"{cam} dts(ms) out of spec: max diff {dts.max()}, 99 percentile {np.percentile(dts, 99)}"
for m in msgs: for m in msgs:
self.log_by_frame_id[getattr(m, m.which()).frameId].append(m) cls.log_by_frame_id[getattr(m, m.which()).frameId].append(m)
# strip beginning and end # strip beginning and end
for _ in range(3): for _ in range(3):
mn, mx = min(self.log_by_frame_id.keys()), max(self.log_by_frame_id.keys()) mn, mx = min(cls.log_by_frame_id.keys()), max(cls.log_by_frame_id.keys())
del self.log_by_frame_id[mn] del cls.log_by_frame_id[mn]
del self.log_by_frame_id[mx] del cls.log_by_frame_id[mx]
def test_frame_skips(self): def test_frame_skips(self):
skips = {} skips = {}

Loading…
Cancel
Save