Skip to content

test: stabilize timing-sensitive checks - #3

Merged
dejay-vu merged 1 commit into
mainfrom
agent/stabilize-tests
Jul 13, 2026
Merged

test: stabilize timing-sensitive checks#3
dejay-vu merged 1 commit into
mainfrom
agent/stabilize-tests

Conversation

@dejay-vu

Copy link
Copy Markdown
Owner

Summary

  • measure the 500 ms query/render budget with process CPU time so shared-runner scheduling pauses do not cause false failures
  • wait for background login-build processes to exit before asserting cleanup
  • wait for Textual modal messages and child mounting before clicking the confirmation button
  • run push CI only on main while retaining pull-request CI for changes targeting main

Why

PR #2 exposed three timing-sensitive failures that passed on the same commit in other matrix runs: a near-threshold performance sample, a short process-reaping window, and a modal child-mount race. Feature branches also produced duplicate push and pull-request matrices, increasing CI noise and cost.

Impact

Runtime behavior is unchanged. The test suite preserves its existing performance threshold and behavioral assertions while synchronizing on the states it actually depends on. CI continues to validate every pull request and every update to main without duplicate feature-branch push runs.

Validation

  • targeted tests passed for 10 consecutive rounds (30 test executions)
  • conda run -n slurmdeck-dev ruff format .
  • conda run -n slurmdeck-dev ruff check .
  • conda run -n slurmdeck-dev mypy
  • conda run -n slurmdeck-dev python -m pytest -q (510 passed)
  • workflow YAML parsed successfully with yq
  • git diff --check

actionlint was not run because it is not installed locally.

@dejay-vu
dejay-vu marked this pull request as ready for review July 13, 2026 22:50
Copilot AI review requested due to automatic review settings July 13, 2026 22:50
@dejay-vu
dejay-vu merged commit 6a4f936 into main Jul 13, 2026
6 checks passed
@dejay-vu
dejay-vu deleted the agent/stabilize-tests branch July 13, 2026 22:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stabilizes timing-sensitive test assertions by synchronizing on the actual states under test (process lifecycle, UI mounting, and CPU-time performance budgets) and reduces duplicated CI runs by limiting push workflows to main.

Changes:

  • Add a helper to wait for background login-build processes to exit before asserting cleanup.
  • Switch the “1,000 runs query + render” performance budget to use process CPU time (and rename the test accordingly).
  • Add extra synchronization in a Textual modal flow, and restrict CI push/pull_request triggers to main.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/unit/test_env_executors.py Adds a helper to wait for background process exit before cleanup assertions.
tests/tui/test_pilot.py Adds extra UI synchronization to avoid modal/child-mount race before clicking.
tests/perf/test_ux_budgets.py Measures query/render budget using CPU time and renames the test to reflect that.
.github/workflows/ci.yml Reduces CI noise by running push CI only on main and scoping PR CI to main.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +141 to +149
def _wait_for_process_exit(pid: int, *, timeout: float = 5.0) -> None:
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
try:
os.kill(pid, 0)
except OSError:
return
time.sleep(0.05)
pytest.fail(f"background process {pid} did not exit within {timeout:.1f}s")
dejay-vu added a commit that referenced this pull request Jul 14, 2026
## Summary

- reject non-positive process IDs before probing for process exit
- treat only `ProcessLookupError` as evidence that the process is gone
- fail explicitly when `os.kill(pid, 0)` raises another `OSError`
- wait for the asynchronous GC preview callback before inspecting its
modal

## Why

The process-exit helper follows up on Copilot feedback from PR #3:
catching every
`OSError` could incorrectly pass when a process still existed but could
not be
inspected. The Python 3.14 check also exposed a separate TUI race where
the test
could inspect the screen before the GC callback had pushed the
confirmation
modal.

## Impact

Production behavior is unchanged. These tests now distinguish a missing
process
from a failed process probe and synchronize with both the GC callback
and modal
mounting before making assertions.

## Validation

- GC preview test passed 20 consecutive runs
- targeted background login-build test passed
- `conda run -n slurmdeck-dev ruff format .`
- `conda run -n slurmdeck-dev ruff check .`
- `conda run -n slurmdeck-dev mypy`
- `conda run -n slurmdeck-dev python -m pytest -q` (`510 passed`)
- `git diff --check`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants