Skip to content

Commit b446281

Browse files
committed
examples: zephyr: hello_nrf91_offloaded: poll for logs
Apply the same changes made for the hello sample in 59d0d9b Signed-off-by: Sam Friedman <sam@golioth.io>
1 parent d3b1b9d commit b446281

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

examples/zephyr/hello_nrf91_offloaded/pytest/test_sample.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
LOGGER = logging.getLogger(__name__)
77

8+
LOG_FETCH_POLLING_LIMIT = datetime.timedelta(seconds=60)
9+
LOG_EXPECTED_COUNT = 5 # we expect 4 hello messages plus client connection log
10+
811
pytestmark = pytest.mark.anyio
912

1013
async def test_hello(shell, device, build_conf):
@@ -38,11 +41,26 @@ async def test_hello(shell, device, build_conf):
3841
start = datetime.datetime.now(datetime.UTC)
3942
shell._device.readlines_until(regex=".*Sending hello! 3", timeout=110.0)
4043

41-
# Check logs for hello messages
44+
# Fetch logs
45+
46+
log_fetch_start = datetime.datetime.now(datetime.UTC)
47+
48+
while True:
49+
end = datetime.datetime.now(datetime.UTC)
50+
51+
logs = await device.get_logs(
52+
{
53+
"start": start.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
54+
"end": end.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
55+
"module": "hello_zephyr",
56+
}
57+
)
4258

43-
end = datetime.datetime.now(datetime.UTC)
59+
if len(logs) >= LOG_EXPECTED_COUNT:
60+
break
4461

45-
logs = await device.get_logs({'start': start.strftime('%Y-%m-%dT%H:%M:%S.%fZ'), 'end': end.strftime('%Y-%m-%dT%H:%M:%S.%fZ')})
62+
duration = datetime.datetime.now(datetime.UTC) - log_fetch_start
63+
assert (LOG_FETCH_POLLING_LIMIT > duration)
4664

4765
# Test logs received from server
4866

0 commit comments

Comments
 (0)