|
5 | 5 |
|
6 | 6 | LOGGER = logging.getLogger(__name__) |
7 | 7 |
|
| 8 | +LOG_FETCH_POLLING_LIMIT = datetime.timedelta(seconds=60) |
| 9 | +LOG_EXPECTED_COUNT = 5 # we expect 4 hello messages plus client connection log |
| 10 | + |
8 | 11 | pytestmark = pytest.mark.anyio |
9 | 12 |
|
10 | 13 | async def test_hello(shell, device, build_conf): |
@@ -38,11 +41,26 @@ async def test_hello(shell, device, build_conf): |
38 | 41 | start = datetime.datetime.now(datetime.UTC) |
39 | 42 | shell._device.readlines_until(regex=".*Sending hello! 3", timeout=110.0) |
40 | 43 |
|
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 | + ) |
42 | 58 |
|
43 | | - end = datetime.datetime.now(datetime.UTC) |
| 59 | + if len(logs) >= LOG_EXPECTED_COUNT: |
| 60 | + break |
44 | 61 |
|
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) |
46 | 64 |
|
47 | 65 | # Test logs received from server |
48 | 66 |
|
|
0 commit comments