Skip to content

Commit e2e2497

Browse files
committed
CI: zephyr: add polling when fetching logs for ota integration test
poll until fetched log count matches the expected number of entries. Polling includes a timeout and will assert. Signed-off-by: Mike Szczys <[email protected]>
1 parent a65e886 commit e2e2497

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tests/hil/tests/ota/test_ota.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
LOGGER = logging.getLogger(__name__)
77

8+
LOG_FETCH_POLLING_LIMIT = datetime.timedelta(seconds=60)
9+
810
UPDATE_PACKAGE = 'main'
911
DUMMY_VER_OLDER = '1.2.2'
1012
DUMMY_VER_SAME = '1.2.3'
@@ -211,12 +213,30 @@ async def test_reason_and_state(board, device, project, artifacts, cohort):
211213

212214
await trio.sleep(5)
213215

214-
# Check logs for firmware status updates
216+
# Fetch logs
217+
218+
log_fetch_start = datetime.datetime.now(datetime.UTC)
219+
220+
while True:
221+
end = datetime.datetime.now(datetime.UTC)
222+
223+
logs = await device.get_logs(
224+
{
225+
"start": start.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
226+
"end": end.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
227+
"module": "golioth_dfu",
228+
}
229+
)
230+
231+
if len(logs) == GOLIOTH_OTA_REASON_CNT:
232+
break
215233

216-
end = datetime.datetime.now(datetime.UTC)
234+
assert (
235+
LOG_FETCH_POLLING_LIMIT
236+
> datetime.datetime.now(datetime.UTC) - log_fetch_start
237+
)
217238

218-
logs = await device.get_logs({'start': start.strftime('%Y-%m-%dT%H:%M:%S.%fZ'), 'end':
219-
end.strftime('%Y-%m-%dT%H:%M:%S.%fZ'), 'module': 'golioth_dfu'})
239+
await trio.sleep(1)
220240

221241
# Test logs received from server
222242

0 commit comments

Comments
 (0)