Skip to content

Commit ad95d56

Browse files
committed
up
1 parent 755fc4e commit ad95d56

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tests/test_perf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import logging
1818
from threading import Event
1919
from typing import Dict, cast
20+
import time
2021

2122
import pytest
2223
from docker.models.containers import Container
@@ -144,6 +145,7 @@ def test_perf_comm_change(
144145
I'm not sure it can be done, i.e is this info even kept anywhere).
145146
"""
146147
with system_profiler as profiler:
148+
time.sleep(2)
147149
# first run - we get the changed name, because the app started before perf began recording.
148150
_assert_comm_in_profile(profiler, application_pid, False)
149151

@@ -170,6 +172,7 @@ def test_perf_thread_comm_is_process_comm(
170172
starts after perf, the exec comm of the process should be used (see test_perf_comm_change)
171173
"""
172174
with system_profiler as profiler:
175+
time.sleep(2)
173176
# running perf & script now with --show-task-events would show:
174177
# pative 1925947 [010] 987095.272656: PERF_RECORD_COMM: pative:1925904/1925947
175178
# our perf will prefer to use the exec comm, OR oldest comm available if exec

tests/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,16 @@ def assert_ldd_version_container(container: Container, version: str) -> None:
206206

207207

208208
def snapshot_pid_profile(profiler: ProfilerInterface, pid: int) -> ProfileData:
209-
last_snapshot = None
209+
last_snapshot = profiler.snapshot()
210210

211211
def has_profile() -> bool:
212212
nonlocal last_snapshot
213+
if pid in last_snapshot:
214+
return True
213215
last_snapshot = profiler.snapshot()
214216
return pid in last_snapshot
215217

216-
wait_event(timeout=5, stop_event=Event(), condition=has_profile, interval=1)
218+
wait_event(timeout=5, stop_event=Event(), condition=has_profile, interval=0.1)
217219
return last_snapshot[pid] # type: ignore
218220

219221

0 commit comments

Comments
 (0)