From f224107623eaf9d688b5a79540523c2d05cde343 Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Thu, 30 Jul 2026 15:03:18 +0200 Subject: [PATCH 1/5] fix(tests): Replace fixed sleep with polling for profiler auto-start-stop tests & add temporary github workflow Refs: #6957 & PY-2638 --- .../profiler-auto-start-stop-flake-check.yml | 45 +++++++++++++++++++ tests/profiler/test_continuous_profiler.py | 20 ++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/profiler-auto-start-stop-flake-check.yml diff --git a/.github/workflows/profiler-auto-start-stop-flake-check.yml b/.github/workflows/profiler-auto-start-stop-flake-check.yml new file mode 100644 index 0000000000..b797852043 --- /dev/null +++ b/.github/workflows/profiler-auto-start-stop-flake-check.yml @@ -0,0 +1,45 @@ +name: Profiler Auto Start/Stop Flake Check + +on: + pull_request: + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + profiler-auto-start-stop-flake: + name: py${{ matrix.python-version }} #${{ matrix.attempt }} + timeout-minutes: 15 + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"] + attempt: [1, 2, 3, 4, 5] + env: + TOX_UV_PYTHON_PREFERENCE: ${{ matrix.python-version == '3.6' && 'only-system' || 'managed' }} + TESTPATH: tests/profiler/test_continuous_profiler.py + container: ${{ matrix.python-version == '3.6' && 'python:3.6' || null }} + steps: + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + - name: Install uv + uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 + with: + enable-cache: false + - name: Mark workspace safe for git (3.6 container) + if: ${{ matrix.python-version == '3.6' }} + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Setup Test Env + run: uv sync + - name: Test profiler auto start/stop (attempt ${{ matrix.attempt }}) + run: | + set -x + ./scripts/runtox.sh "py${{ matrix.python-version }}-common" \ + -k "test_continuous_profiler_auto_start_and_stop_sampled" diff --git a/tests/profiler/test_continuous_profiler.py b/tests/profiler/test_continuous_profiler.py index 0997634614..ed75ef700a 100644 --- a/tests/profiler/test_continuous_profiler.py +++ b/tests/profiler/test_continuous_profiler.py @@ -808,7 +808,15 @@ def test_continuous_profiler_auto_start_and_stop_sampled( profiler_ids.add(profiler_id) # wait at least 1 cycle for the profiler to stop - time.sleep(0.2) + # time.sleep(0.2) + # assert get_profiler_id() is None, "profiler should not be running" + + # Poll up to 2.0 seconds (every 10ms) for the profiler to stop + deadline = time.monotonic() + 2.0 + while time.monotonic() < deadline: + if get_profiler_id() is None: + break + time.sleep(0.01) assert get_profiler_id() is None, "profiler should not be running" assert len(profiler_ids) == 1 @@ -892,7 +900,15 @@ def test_continuous_profiler_auto_start_and_stop_sampled_span_streaming( profiler_ids.add(profiler_id) # wait at least 1 cycle for the profiler to stop - time.sleep(0.2) + # time.sleep(0.2) + # assert get_profiler_id() is None, "profiler should not be running" + + # Poll up to 2.0 seconds (every 10ms) for the profiler to stop + deadline = time.monotonic() + 2.0 + while time.monotonic() < deadline: + if get_profiler_id() is None: + break + time.sleep(0.01) assert get_profiler_id() is None, "profiler should not be running" assert len(profiler_ids) == 1 From 6778f4adc9bbd691693832bbfb72b6ba4ee2e5d0 Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Thu, 30 Jul 2026 15:08:51 +0200 Subject: [PATCH 2/5] fix(tests): Update py version handling in workflow Refs: #6957 & PY-2638 --- .../workflows/profiler-auto-start-stop-flake-check.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/profiler-auto-start-stop-flake-check.yml b/.github/workflows/profiler-auto-start-stop-flake-check.yml index b797852043..709453cd4f 100644 --- a/.github/workflows/profiler-auto-start-stop-flake-check.yml +++ b/.github/workflows/profiler-auto-start-stop-flake-check.yml @@ -24,17 +24,18 @@ jobs: python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"] attempt: [1, 2, 3, 4, 5] env: - TOX_UV_PYTHON_PREFERENCE: ${{ matrix.python-version == '3.6' && 'only-system' || 'managed' }} + # 3.6/3.7 have no uv-managed builds; they run in the python:X.Y container. + TOX_UV_PYTHON_PREFERENCE: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && 'only-system' || 'managed' }} TESTPATH: tests/profiler/test_continuous_profiler.py - container: ${{ matrix.python-version == '3.6' && 'python:3.6' || null }} + container: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && format('python:{0}', matrix.python-version) || null }} steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Install uv uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 with: enable-cache: false - - name: Mark workspace safe for git (3.6 container) - if: ${{ matrix.python-version == '3.6' }} + - name: Mark workspace safe for git (3.6/3.7 container) + if: ${{ matrix.python-version == '3.6' || matrix.python-version == '3.7' }} run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Setup Test Env run: uv sync From ba1485238c061248b834f9620fd09c526b0914ff Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Thu, 30 Jul 2026 15:38:30 +0200 Subject: [PATCH 3/5] fix(tests): Reduce polling duration to earliest auto stop --- tests/profiler/test_continuous_profiler.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/tests/profiler/test_continuous_profiler.py b/tests/profiler/test_continuous_profiler.py index ed75ef700a..ab558c3281 100644 --- a/tests/profiler/test_continuous_profiler.py +++ b/tests/profiler/test_continuous_profiler.py @@ -807,12 +807,8 @@ def test_continuous_profiler_auto_start_and_stop_sampled( assert profiler_id is not None, "profiler should be running" profiler_ids.add(profiler_id) - # wait at least 1 cycle for the profiler to stop - # time.sleep(0.2) - # assert get_profiler_id() is None, "profiler should not be running" - - # Poll up to 2.0 seconds (every 10ms) for the profiler to stop - deadline = time.monotonic() + 2.0 + # Poll up to 0.143 seconds (every 10ms) for the profiler to stop + deadline = time.monotonic() + 0.143 while time.monotonic() < deadline: if get_profiler_id() is None: break @@ -899,12 +895,8 @@ def test_continuous_profiler_auto_start_and_stop_sampled_span_streaming( assert profiler_id is not None, "profiler should be running" profiler_ids.add(profiler_id) - # wait at least 1 cycle for the profiler to stop - # time.sleep(0.2) - # assert get_profiler_id() is None, "profiler should not be running" - - # Poll up to 2.0 seconds (every 10ms) for the profiler to stop - deadline = time.monotonic() + 2.0 + # Poll up to 0.143 seconds (every 10ms) for the profiler to stop + deadline = time.monotonic() + 0.143 while time.monotonic() < deadline: if get_profiler_id() is None: break From f4e61636e1ae7faecd428cea43f9d677720c302f Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Thu, 30 Jul 2026 15:50:47 +0200 Subject: [PATCH 4/5] fix(tests): Increase polling duration back to 0.2s --- tests/profiler/test_continuous_profiler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/profiler/test_continuous_profiler.py b/tests/profiler/test_continuous_profiler.py index ab558c3281..af89df6cf0 100644 --- a/tests/profiler/test_continuous_profiler.py +++ b/tests/profiler/test_continuous_profiler.py @@ -807,8 +807,8 @@ def test_continuous_profiler_auto_start_and_stop_sampled( assert profiler_id is not None, "profiler should be running" profiler_ids.add(profiler_id) - # Poll up to 0.143 seconds (every 10ms) for the profiler to stop - deadline = time.monotonic() + 0.143 + # Poll up to 0.2 seconds (every 10ms) for the profiler to stop + deadline = time.monotonic() + 0.2 while time.monotonic() < deadline: if get_profiler_id() is None: break @@ -895,8 +895,8 @@ def test_continuous_profiler_auto_start_and_stop_sampled_span_streaming( assert profiler_id is not None, "profiler should be running" profiler_ids.add(profiler_id) - # Poll up to 0.143 seconds (every 10ms) for the profiler to stop - deadline = time.monotonic() + 0.143 + # Poll up to 0.2 seconds (every 10ms) for the profiler to stop + deadline = time.monotonic() + 0.2 while time.monotonic() < deadline: if get_profiler_id() is None: break From 4a8f3d1d2b57db7fd913c503aa190270b385c28c Mon Sep 17 00:00:00 2001 From: Pablo Deputter Date: Fri, 31 Jul 2026 14:30:18 +0200 Subject: [PATCH 5/5] fix(tests): Remove temporary github workflow --- .../profiler-auto-start-stop-flake-check.yml | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/profiler-auto-start-stop-flake-check.yml diff --git a/.github/workflows/profiler-auto-start-stop-flake-check.yml b/.github/workflows/profiler-auto-start-stop-flake-check.yml deleted file mode 100644 index 709453cd4f..0000000000 --- a/.github/workflows/profiler-auto-start-stop-flake-check.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Profiler Auto Start/Stop Flake Check - -on: - pull_request: - push: - branches: - - master - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - profiler-auto-start-stop-flake: - name: py${{ matrix.python-version }} #${{ matrix.attempt }} - timeout-minutes: 15 - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"] - attempt: [1, 2, 3, 4, 5] - env: - # 3.6/3.7 have no uv-managed builds; they run in the python:X.Y container. - TOX_UV_PYTHON_PREFERENCE: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && 'only-system' || 'managed' }} - TESTPATH: tests/profiler/test_continuous_profiler.py - container: ${{ (matrix.python-version == '3.6' || matrix.python-version == '3.7') && format('python:{0}', matrix.python-version) || null }} - steps: - - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - - name: Install uv - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 - with: - enable-cache: false - - name: Mark workspace safe for git (3.6/3.7 container) - if: ${{ matrix.python-version == '3.6' || matrix.python-version == '3.7' }} - run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - - name: Setup Test Env - run: uv sync - - name: Test profiler auto start/stop (attempt ${{ matrix.attempt }}) - run: | - set -x - ./scripts/runtox.sh "py${{ matrix.python-version }}-common" \ - -k "test_continuous_profiler_auto_start_and_stop_sampled"