Skip to content

test(functional): replace merge-status sleeps with polling helper - #3427

Draft
JohnVillalovos wants to merge 1 commit into
mainfrom
jlvillal/test_accept_request_merge_flaky
Draft

test(functional): replace merge-status sleeps with polling helper#3427
JohnVillalovos wants to merge 1 commit into
mainfrom
jlvillal/test_accept_request_merge_flaky

Conversation

@JohnVillalovos

@JohnVillalovos JohnVillalovos commented Jul 27, 2026

Copy link
Copy Markdown
Member

Trying to make the tests less flaky. Have seen some issues with tests needing to be manually re-run due to failures.

test_accept_request_merge used a blind time.sleep(30) before attempting to merge, which was flaky whenever GitLab hadn't finished evaluating mergeability by the time the sleep ended, causing intermittent CI failures with GitlabMRClosedError: Branch cannot be merged.

Add helpers.poll_until(), a generic poll-until-condition-or-fail helper, and use it to replace the blind sleep with a check on detailed_merge_status, plus the duplicated merged_at polling loops in test_merge_requests.py and the _make_merge_request fixture in conftest.py.

Assisted-by: Claude Sonnet 5

Copilot AI review requested due to automatic review settings July 27, 2026 03:24
@JohnVillalovos
JohnVillalovos requested a review from nejch July 27, 2026 03:24

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 reduces functional test flakiness by replacing fixed sleeps with a reusable polling helper that waits for GitLab state transitions (mergeability evaluation and merge completion) before proceeding.

Changes:

  • Add helpers.poll_until() as a generic “wait until condition or fail” utility using a monotonic timeout.
  • Replace a blind time.sleep(30) in the CLI functional test with polling on detailed_merge_status.
  • Replace duplicated “poll until merged_at is set” loops in merge request API functional tests and the MR fixture with the shared helper.

Reviewed changes

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

File Description
tests/functional/helpers.py Adds a generic polling helper to replace fixed sleeps and duplicated polling loops.
tests/functional/conftest.py Uses polling in the MR fixture to wait for detailed_merge_status to settle.
tests/functional/cli/test_cli_v4.py Replaces a fixed 30s sleep with polling for mergeability evaluation completion.
tests/functional/api/test_merge_requests.py Replaces duplicated merge-completion polling loops with the shared helper.

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

Comment thread tests/functional/helpers.py
@JohnVillalovos
JohnVillalovos force-pushed the jlvillal/test_accept_request_merge_flaky branch from ef88f48 to 4e75be3 Compare July 27, 2026 03:30
@JohnVillalovos
JohnVillalovos marked this pull request as draft July 27, 2026 05:32
@JohnVillalovos
JohnVillalovos removed the request for review from nejch July 27, 2026 05:32
@JohnVillalovos
JohnVillalovos force-pushed the jlvillal/test_accept_request_merge_flaky branch 7 times, most recently from be0995b to 19393df Compare July 28, 2026 04:08
Trying to make the tests less flaky. Have seen some issues with tests
needing to be manually re-run due to failures.

`test_accept_request_merge` used a blind `time.sleep(30)` before
attempting to merge, which was flaky whenever GitLab hadn't finished
evaluating mergeability by the time the sleep ended, causing
intermittent CI failures with `GitlabMRClosedError: Branch cannot be
merged`.

Add `helpers.poll_until()`, a generic poll-until-condition-or-fail
helper, and use it to replace the blind sleep with a check on
`detailed_merge_status`, plus the duplicated `merged_at` polling loops
in `test_merge_requests.py` and the `_make_merge_request` fixture in
conftest.py.

Assisted-by: Claude Sonnet 5
@JohnVillalovos
JohnVillalovos force-pushed the jlvillal/test_accept_request_merge_flaky branch from 19393df to 0bcfec0 Compare July 30, 2026 05:11
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