From d20e6218e3a63808a37f968e772313d6f57c15d5 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 15 Aug 2024 22:30:33 -0700 Subject: [PATCH] 1m old-commit-hash: b1f2c30a27bba59927eb6ae3aabd96eb4376af6d --- Jenkinsfile | 4 ++- .../pandad/tests/test_pandad_loopback.py | 2 +- selfdrive/test/process_replay/model_replay.py | 2 +- system/camerad/test/test_camerad.py | 29 ++++++++++--------- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 799b4fbbeb932e..1fe19810efc47e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,7 +87,9 @@ def deviceStage(String stageName, String deviceType, List extra_env, def steps) device(device_ip, "git checkout", extra + "\n" + readFile("selfdrive/test/setup_device_ci.sh")) } steps.each { item -> - device(device_ip, item[0], item[1]) + timeout(time: 1, unit: 'MINUTES') { + device(device_ip, item[0], item[1]) + } } } } diff --git a/selfdrive/pandad/tests/test_pandad_loopback.py b/selfdrive/pandad/tests/test_pandad_loopback.py index 3f0926662c854a..d04e1a002fffb8 100644 --- a/selfdrive/pandad/tests/test_pandad_loopback.py +++ b/selfdrive/pandad/tests/test_pandad_loopback.py @@ -83,7 +83,7 @@ def test_loopback(self): sm = messaging.SubMaster(['pandaStates']) time.sleep(1) - n = 200 + n = 20 for i in range(n): print(f"pandad loopback {i}/{n}") diff --git a/selfdrive/test/process_replay/model_replay.py b/selfdrive/test/process_replay/model_replay.py index a58a58107e4385..32296ffa39faa6 100755 --- a/selfdrive/test/process_replay/model_replay.py +++ b/selfdrive/test/process_replay/model_replay.py @@ -14,7 +14,7 @@ TEST_ROUTE = "2f4452b03ccb98f0|2022-12-03--13-45-30" SEGMENT = 6 -MAX_FRAMES = 100 if PC else 600 +MAX_FRAMES = 100 if PC else 60 NO_MODEL = "NO_MODEL" in os.environ SEND_EXTRA_INPUTS = bool(int(os.getenv("SEND_EXTRA_INPUTS", "0"))) diff --git a/system/camerad/test/test_camerad.py b/system/camerad/test/test_camerad.py index ada9594895e425..ac09709ba30970 100644 --- a/system/camerad/test/test_camerad.py +++ b/system/camerad/test/test_camerad.py @@ -9,7 +9,7 @@ from cereal.services import SERVICE_LIST from openpilot.system.manager.process_config import managed_processes -TEST_TIMESPAN = 30 +TEST_TIMESPAN = 10 LAG_FRAME_TOLERANCE = {log.FrameData.ImageSensor.ar0231: 0.5, # ARs use synced pulses for frame starts log.FrameData.ImageSensor.ox03c10: 1.1} # OXs react to out-of-sync at next frame FRAME_DELTA_TOLERANCE = {log.FrameData.ImageSensor.ar0231: 1.0, @@ -21,39 +21,40 @@ @flaky(max_runs=3) @pytest.mark.tici class TestCamerad: - def setup_method(self): + @classmethod + def setup_method(cls): # run camerad and record logs managed_processes['camerad'].start() time.sleep(3) 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() while time.monotonic()- start_time < TEST_TIMESPAN: for cam, s in socks.items(): - self.logs[cam] += messaging.drain_sock(s) + cls.logs[cam] += messaging.drain_sock(s) time.sleep(0.2) managed_processes['camerad'].stop() - self.log_by_frame_id = defaultdict(list) - self.sensor_type = None - for cam, msgs in self.logs.items(): - if self.sensor_type is None: - self.sensor_type = getattr(msgs[0], msgs[0].which()).sensor.raw + cls.log_by_frame_id = defaultdict(list) + cls.sensor_type = None + for cam, msgs in cls.logs.items(): + if cls.sensor_type is None: + cls.sensor_type = getattr(msgs[0], msgs[0].which()).sensor.raw 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)}" 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: - 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 for _ in range(3): - mn, mx = min(self.log_by_frame_id.keys()), max(self.log_by_frame_id.keys()) - del self.log_by_frame_id[mn] - del self.log_by_frame_id[mx] + mn, mx = min(cls.log_by_frame_id.keys()), max(cls.log_by_frame_id.keys()) + del cls.log_by_frame_id[mn] + del cls.log_by_frame_id[mx] def test_frame_skips(self): skips = {}