Repository navigation
Conversation
dklawren
requested review from
Xzzz and
cgsheeh
and
a balanced review from Copilot
October 18, 2026 18:23
There was a problem hiding this comment.
🟡 Changes recommended
Fixture ID collisions and unrealistic attachment responses undermine test isolation and integration coverage.
2 open issues
What changed in this PR
Expands PhabBugz integration testing against BMO using an in-process fake Phabricator Conduit service.
Changes:
- Adds reusable fixtures, request simulation and test-environment helpers.
- Covers models, synchronization, permissions, approval flags and failure handling.
- Seeds product-scoped and disabled uplift approval flags.
| File | Description |
|---|---|
| scripts/generate_bmo_data.pl | Seeds uplift approval flag types. |
| extensions/PhabBugz/t/bmo/webservice.t | Tests endpoints and permissions. |
| extensions/PhabBugz/t/bmo/util.t | Tests attachments and reviewer helpers. |
| extensions/PhabBugz/t/bmo/model-user.t | Tests account lookup and synchronization. |
| extensions/PhabBugz/t/bmo/model-revision.t | Tests revision models and privacy helpers. |
| extensions/PhabBugz/t/bmo/model-repository-comment.t | Tests repository and comment models. |
| extensions/PhabBugz/t/bmo/model-project.t | Tests project lookup and updates. |
| extensions/PhabBugz/t/bmo/model-policy.t | Tests custom policy handling. |
| extensions/PhabBugz/t/bmo/lib/PhabTest/Fixtures.pm | Builds Conduit fixtures. |
| extensions/PhabBugz/t/bmo/lib/PhabTest/Env.pm | Provides setup and teardown helpers. |
| extensions/PhabBugz/t/bmo/lib/PhabTest/Conduit.pm | Simulates and records Conduit requests. |
| extensions/PhabBugz/t/bmo/feed-users.t | Tests new-user synchronization. |
| extensions/PhabBugz/t/bmo/feed-stories.t | Tests revision synchronization and failures. |
| extensions/PhabBugz/t/bmo/feed-run-query.t | Tests daemon error handling and cleanup. |
| extensions/PhabBugz/t/bmo/feed-groups.t | Tests group membership synchronization. |
| extensions/PhabBugz/t/bmo/conduit-request.t | Tests transport encoding and errors. |
| extensions/PhabBugz/t/bmo/approval-flags.t | Tests uplift approval flag behavior. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add a mocked PhabBugz test suite and seed approval-mozilla-* flag types
Summary
Adds a test suite for the Bugzilla/Phabricator integration that runs without
a Phabricator server. Every Conduit call goes to an in-process fake that
answers with the response shapes from the Conduit API docs. The tests live in
extensions/PhabBugz/t/bmo/, so CI's existingtest_bmojob picks them upand runs them against the real MySQL database. No CI changes are needed.
Also seeds the
approval-mozilla-*flag types ingenerate_bmo_data.pl, soset_attachment_approval_flagscan be tested. This includes the commonproduction failure where the flag is not enabled for the bug's
product/component.
No production code is changed.
Changes
Test helpers (
extensions/PhabBugz/t/bmo/lib/PhabTest/)Conduit.pm: a fake Conduit server. It overridesMojo::UserAgent::postand records every call. It answers from an in-memory directory of users,
projects, revisions, repositories, policies, feed stories, transactions and
edges, and applies
*.editcalls to that directory. Tests can queuefailures: Conduit errors, HTTP errors, non-JSON bodies, network errors and
an invalid feed cursor. A call to a method the fake doesn't handle fails the
test.
Fixtures.pm: builders for complete Conduit objects.Env.pm: per-file setup and teardown for the shared database. It createsfixtures with unique names, restores the
phabbugzcursors, deactivatestest groups, and only ever sets PhabBugz params in memory.
Tests (13 files)
conduit-request.t: howrequest()encodes calls, and how it handlesmissing config, HTTP 4xx/5xx, bad or truncated JSON, Conduit errors (with
and without
no_die), network failures and a missingresult.model-{user,project,policy,revision,repository-comment}.t: lookups,paging, lazy builders, the exact transactions each mutator sends, privacy
helpers, and errors from Phabricator.
model-user.talso covers syncing adisabled BMO account to Phabricator.
util.t: bug role PHIDs, revision attachments, auto-assignment, reviewerrotation and intermittent reviewers.
webservice.t:bug_revisions,userand the phab-bot permission checks.approval-flags.t:?on new revisions,+only from release managers,Xhandlingdirectly and through the feed
feed-stories.t,feed-users.t,feed-groups.t: the daemon's periodicloops, covering:
feed-run-query.t: the daemon wrapper logs errors, clears the watchdogalarm and keeps running.
Seed data (
scripts/generate_bmo_data.pl)approval-mozilla-{beta,release,esr140}: enabled only forFirefox :: General, so
bugzilla.mozilla.organd Firefox :: Installerreproduce the "flag not enabled" case.
approval-mozilla-esr115: seeded but disabled (is_active = 0).is_active, defaulting to 1. The existingflag types are unchanged.
Issues found (left as TODO tests, not fixed here)
feed_queryhas noper-story error handling, so the cursor never moves past the failing story.
The most likely trigger is an approval flag that isn't enabled for the
bug's product/component:
set_flagsthrowsinvalid_flag_associationandthe whole story is rolled back.
Project::updatenever sends thejoinpolicy.revision/comments.html.tmpldoesn't loadterms. Theinvalid-bug comment posted to Phabricator reads "invalid ID", with the
word "bug" missing.
Also noted, but tested as current behavior rather than as TODOs:
Policy->create([])sends a fallback rule without arulekey.needs-revisioncreates an approval-flag without arelease manager check.
Testing
test_bmo: 40 files, 1,786 tests pass. The PhabBugz suite was also runtwice in one database session to check that it cleans up after itself.
test_webservices: 45 files, 3,907 tests pass with the new seed data.test_sanity: the critic, goodperl and whitespace checks pass.🤖 Generated with Claude Code