Skip to content

Commit 0a0a636

Browse files
committed
Give scheduler + USB-passthrough client timing tests more headroom on slow CI
1 parent 22fe033 commit 0a0a636

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

test/unit_test/headless/test_scheduler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""Tests for the Scheduler headless module."""
22
import time
33

4+
import pytest
5+
46
from je_auto_control.utils.scheduler.scheduler import Scheduler
57

68

@@ -22,6 +24,7 @@ def test_set_enabled_toggles_flag():
2224
assert sched.set_enabled("no-such-job", True) is False
2325

2426

27+
@pytest.mark.flaky(reruns=2, reruns_delay=1)
2528
def test_job_fires_and_updates_runs(monkeypatch):
2629
executed = []
2730
sched = Scheduler(
@@ -35,11 +38,13 @@ def test_job_fires_and_updates_runs(monkeypatch):
3538
job = sched.add_job("fake.json", interval_seconds=0.1, repeat=False)
3639
sched.start()
3740
try:
38-
deadline = time.monotonic() + 2.0
41+
# 8s budget so a sluggish Windows-2022 CI runner has headroom
42+
# past the 100 ms tick — the previous 2s timed out under load.
43+
deadline = time.monotonic() + 8.0
3944
while time.monotonic() < deadline and sched.list_jobs():
4045
time.sleep(0.05)
4146
finally:
42-
sched.stop(timeout=1.0)
47+
sched.stop(timeout=2.0)
4348
assert executed, "executor should have been called at least once"
4449
# Non-repeating job is removed after firing.
4550
assert all(j.job_id != job.job_id for j in sched.list_jobs())

test/unit_test/headless/test_usb_passthrough_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ def __init__(self, host: UsbPassthroughSession,
3838
self._stop = False
3939
self._client = UsbPassthroughClient(
4040
send_frame=self._enqueue,
41-
reply_timeout_s=2.0,
42-
credit_timeout_s=2.0,
41+
# 8s windows give the pump thread room on slow CI runners;
42+
# 2s was tight enough to time out OPEN under load.
43+
reply_timeout_s=8.0,
44+
credit_timeout_s=8.0,
4345
initial_credit_guess=initial_credit_guess,
4446
)
4547
self._thread = threading.Thread(target=self._pump, daemon=True)
@@ -178,6 +180,7 @@ def boom(_kind, _kwargs):
178180
assert "device stalled" in str(exc_info.value)
179181

180182

183+
@pytest.mark.flaky(reruns=2, reruns_delay=1)
181184
def test_transfer_after_close_raises_closed(loop):
182185
pipe, _host, _backend = loop
183186
handle = pipe.client.open(vendor_id="1050", product_id="0407")

0 commit comments

Comments
 (0)