Skip to content

test(live): cover the quarantine add/remove round-trip - #1801

Merged
mergify[bot] merged 2 commits into
mainfrom
devs/jd/fix/live-tests-tests-show-admin-token/cover-quarantine-add-remove-round-trip--20ed0098
Sep 7, 2026
Merged

test(live): cover the quarantine add/remove round-trip#1801
mergify[bot] merged 2 commits into
mainfrom
devs/jd/fix/live-tests-tests-show-admin-token/cover-quarantine-add-remove-round-trip--20ed0098

Conversation

@jd

@jd jd commented Sep 4, 2026

Copy link
Copy Markdown
Member

MRGFY-9001 dropped ci_application_key from POST and DELETE on
/ci/{owner}/repositories/{repo}/quarantines at the same time it
dropped it from search/tests. Only search/tests had a live
test, so only search/tests turned red; mergify tests quarantines add and remove broke for every ci key with no signal at all.
The first two commits of this stack documented that. This closes
it.

The 20-odd wiremock tests in tests_quarantine.rs cannot cover
this: a mock server never authenticates, so no scope change is
visible to them. It has to be the live suite or nothing.

Shape follows freeze_create_update_delete_roundtrip, the existing
create-and-clean-up test in this file: a Drop guard removes the
entry so a failed assertion mid-test still leaves the canary
repository clean, and it warns rather than panics, because
panicking in Drop during an unwind aborts the process and buries
the assertion message that explains the failure. The guard is
registered before the response is parsed — an unparseable body
still means the row exists server-side.

Two details specific to quarantines:

  • The quarantined name is __mergify_cli_smoke_quarantine_<rand>__
    and matches nothing any real suite reports, so even a completely
    skipped cleanup cannot suppress a genuine failure on the canary
    repository. A leaked row is inert.
  • Removal goes by name rather than by the id add returned, so one
    run covers the list read that resolves the name and the delete.

The guard tolerates exactly two outcomes: exit 0, when the body
failed before its own remove, and MergifyApiError carrying
not_found's '<name>' is not quarantined, when the body already
removed the row. Both halves are load-bearing — that exit code is
every Mergify API error including a 403 on a narrowed scope, and
the message on its own would swallow any failure whose text
happened to contain the phrase. It reads the code off
mergify_core::ExitCode rather than a literal, so a renumbering
cannot silently widen what cleanup calls success.

The 8-char entropy the freeze test generated inline is now
unique_suffix(), shared by both.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com

@mergify
mergify Bot had a problem deploying to Mergify Merge Protections September 4, 2026 15:38 Failure
@jd

jd commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 docs(live-tests): drop the mirror claims for deleted Python files #1799
2 test(live): cover the quarantine add/remove round-trip #1801 👈

@mergify

mergify Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 6 merge protections satisfied — ready to merge.

Show 6 satisfied protections

🟢 🤖 Continuous Integration

  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 🔎 Reviews

  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

@mergify
mergify Bot requested a review from a team September 4, 2026 15:45
The module header promised this file "deliberately mirrors the
Python version 1:1 ... so the port can't drift the contract by
accident", and named `func-tests/test_live_smoke.py` and
`func-tests/conftest.py` as what it mirrors. Both were deleted when
the port completed. Four helpers made the same promise individually
(`Mirrors conftest.py::cli`, `Mirrors Python subprocess.run`,
`Matches Python result.stdout + result.stderr`, and `live_token`'s
"Mirrors Python `live_token` fixture").

AGENTS.md: "There is no Python: the port is complete ... If you
find a doc, comment, or rule mentioning [it], it is stale — fix
it." The harm is concrete rather than cosmetic: a maintainer
auditing which secret each test needs goes looking for the fixture
the header says pins that mapping, and there isn't one.

The header now states the invariant that actually holds — tests are
grouped by credential under a banner, and a test belongs under the
banner matching its helper — which is the thing a reader needs and
the thing the previous commit had to correct. It also spells
`LIVE_TEST_MERGIFY_TOKEN_ADMIN` out rather than abbreviating it to
`_ADMIN`, so grepping for either secret finds this file.

Left alone: the in-body notes recording which wire contracts were
preserved across the Python → Rust port. Those are provenance for
why a contract is shaped the way it is, not claims about a file
that no longer exists.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JBz3hxMUDCuWftT6qAHtnn

Change-Id: Idd9e1e28bfc50b8b71d07c5938b4fa89af2745ff
Copilot AI lite review requested due to automatic review settings September 7, 2026 12:10
@jd
jd force-pushed the devs/jd/fix/live-tests-tests-show-admin-token/cover-quarantine-add-remove-round-trip--20ed0098 branch from fac01c2 to d247f8e Compare September 7, 2026 12:10
@jd

jd commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial fac01c2 2026-09-07 12:10 UTC
2 rebase fac01c2 → d247f8e (rebase only) 2026-09-07 12:10 UTC
3 content d247f8e → 4c11a93 review (copilot): the cleanup guard tolerated any non-zero exit whose output contained "not quarantined", which would swallow an unrelated failure carrying that phrase and did not pin the documented … 2026-09-07 12:20 UTC

@jd
jd deployed to func-tests-live September 7, 2026 12:10 — with GitHub Actions Active
@mergify
mergify Bot had a problem deploying to Mergify Merge Protections September 7, 2026 12:11 Failure

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.

🟡 Changes recommended

The new Drop-based cleanup logic currently tolerates the “not quarantined” case via substring matching without checking the expected exit code, which can mask unexpected cleanup failures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds missing live smoke coverage for the tests quarantines add/remove mutations against the real Mergify API, preventing future auth/URL/payload regressions from slipping past wiremock-only tests.

Changes:

  • Add tests_quarantine_add_remove_roundtrip live test with RAII cleanup via RemoveQuarantineOnDrop.
  • Extract shared randomness into unique_suffix() and reuse it for the existing freeze round-trip test.
  • Minor comment wording tweak for the CI-Insights section header.
File summaries
File Description
crates/mergify-cli/tests/live_smoke.rs Adds a quarantines add/remove live canary test with Drop-based cleanup; factors out unique suffix generation for concurrent-safe live runs.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/mergify-cli/tests/live_smoke.rs Outdated
MRGFY-9001 dropped `ci_application_key` from `POST` and `DELETE` on
`/ci/{owner}/repositories/{repo}/quarantines` at the same time it
dropped it from `search/tests`. Only `search/tests` had a live
test, so only `search/tests` turned red; `mergify tests quarantines
add` and `remove` broke for every `ci` key with no signal at all.
The first two commits of this stack documented that. This closes
it.

The 20-odd wiremock tests in `tests_quarantine.rs` cannot cover
this: a mock server never authenticates, so no scope change is
visible to them. It has to be the live suite or nothing.

Shape follows `freeze_create_update_delete_roundtrip`, the existing
create-and-clean-up test in this file: a `Drop` guard removes the
entry so a failed assertion mid-test still leaves the canary
repository clean, and it warns rather than panics, because
panicking in `Drop` during an unwind aborts the process and buries
the assertion message that explains the failure. The guard is
registered before the response is parsed — an unparseable body
still means the row exists server-side.

Two details specific to quarantines:

- The quarantined name is `__mergify_cli_smoke_quarantine_<rand>__`
  and matches nothing any real suite reports, so even a completely
  skipped cleanup cannot suppress a genuine failure on the canary
  repository. A leaked row is inert.
- Removal goes by name rather than by the id `add` returned, so one
  run covers the list read that resolves the name *and* the delete.

The guard tolerates exactly two outcomes: exit 0, when the body
failed before its own remove, and `MergifyApiError` carrying
`not_found`'s `'<name>' is not quarantined`, when the body already
removed the row. Both halves are load-bearing — that exit code is
every Mergify API error including a 403 on a narrowed scope, and
the message on its own would swallow any failure whose text
happened to contain the phrase. It reads the code off
`mergify_core::ExitCode` rather than a literal, so a renumbering
cannot silently widen what cleanup calls success.

The 8-char entropy the freeze test generated inline is now
`unique_suffix()`, shared by both.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Change-Id: I20ed0098fe86acd633ad6864eed035f6e5f47dd1
@jd
jd force-pushed the devs/jd/fix/live-tests-tests-show-admin-token/cover-quarantine-add-remove-round-trip--20ed0098 branch from d247f8e to 4c11a93 Compare September 7, 2026 12:21
@jd
jd deployed to func-tests-live September 7, 2026 12:21 — with GitHub Actions Active
@mergify
mergify Bot deployed to Mergify Merge Protections September 7, 2026 12:21 Active
@jd
jd marked this pull request as ready for review September 7, 2026 12:43
Base automatically changed from devs/jd/fix/live-tests-tests-show-admin-token/drop-mirror-claims-deleted-python-files--dd9e1e28 to main September 7, 2026 13:28
@mergify
mergify Bot requested a review from a team September 7, 2026 13:29
@mergify

mergify Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 9 minutes 14 seconds in the queue, including 8 minutes 22 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Sep 7, 2026
@mergify
mergify Bot merged commit ae26133 into main Sep 7, 2026
22 checks passed
@mergify
mergify Bot deleted the devs/jd/fix/live-tests-tests-show-admin-token/cover-quarantine-add-remove-round-trip--20ed0098 branch September 7, 2026 13:57
@mergify mergify Bot removed the queued label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants