Phabricator/TestPlan: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
(84 intermediate revisions by 8 users not shown)
Line 2: Line 2:
== Getting Started ==
== Getting Started ==


The following steps are required to get QA up and running for Phabricator testing on Mozilla's staging server.
'''NOTE:''' We are using the dev server for QA test runs.


1.  Clone the following repositories to the same directory on your machine:
The following manual steps are required to get QA up and running for Phabricator testing on Mozilla's staging server.


* https://github.com/phacility/libphutil
Alternatively, you can try out the a preset environment using Docker from this [https://github.com/dklawren/phabricator-qa Github repo]. Once checked out run:
* https://github.com/phacility/arcanist


2.  Open your `~/.bash_profile` file and add the following:
    docker-compose build
    docker-compose run qa su - phab


    alias arc='/Users/youruser/path/to/arcanist/bin/arc'
You will still need to perform step 8 using your own Conduit API keys.


Doing so will allow you to use the `arc` command from anywhere on your machine
'''Manual Setup'''


3. Clone the repo(s) you plan to test on:
1. Install git-cinnabar:


*  Staging:  https://hg.mozilla.org/automation/phabricator-qa-stage/
    git clone https://github.com/glandium/git-cinnabar.git --branch master --single-branch
*  Dev: https://hg.mozilla.org/automation/phabricator-qa-dev/
    export PATH=$PATH:`pwd`/git-cinnabar
    cd git-cinnabar && git cinnabar download


3. In the local repository checkout, run:  
2. Install the moz-phab arcanist wrapper used for submitting stacked revisions to Phabricator. You can see instructions on how to install from the [https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html#setting-up-mozphab]. Usually it's enough to just <code>pip3 install MozPhab</code>.


    arc install-certificate
6. Reload your .bash_profile:


Follow the instructions presented in the command line to associate your local machine with the phabricator instance via an API key.
    source $HOME/.bash_profile


4. Test away!  You can create branches within your local repository checkout, add commits, and send them to Phabricator via `arc diff HEAD^`. 
7. Clone the repo(s) you plan to test on:


This should be all you need to get going with arc and our staging and dev servers!
*  <code>hg clone https://hg.mozilla.org/automation/phabricator-qa-dev/</code>
*  <code>git clone hg::https://hg.mozilla.org/automation/phabricator-qa-dev/ phabricator-qa-dev-cinnabar</code>


8. In the local <code>phabricator-qa-dev</code> repository checkout, run:
    moz-phab install-certificate
Follow the instructions presented in the command line to associate your local machine with the Phabricator instance via an API key.
9. Test away!  You can create branches within your local <code>phabricator-qa-dev</code> repository checkout, add commits, and send them to Phabricator via <code>mozphab</code>.  See the [http://moz-conduit.readthedocs.io/en/latest/phabricator-user.html Mozilla Phabricator User Documentation] for more. 
This should be all you need to get going with moz-phab, arc, and our staging and dev servers!


== Test Plan ==
== Test Plan ==
These tests will be useful when upgrading Phabricator to newer versions or when
adding new features to the integration to ensure everything works as expected.


* Update this doc with new tests as features are added/changed.
These tests will help ensure that our extensions continue to work as expected when Phabricator is upgraded.  They are important as Phacility make no guarantees that internal modules/objects/APIs won't change.  See the [[Phabricator/UpgradeProcess|upgrade process]] for more.
* Use a [FAILING] to denote tests which do not work as expected in the
 
with the current Phabricator/BMO on production. Ideally link to a bug
Please update this doc with new tests as features are added/changed and as holes in the plan are discovered.
with the fix.
 
* See the end of this doc for instructions on how to setup a local test
----
environment if that is what you need.
 
=== T1 - Signing up is successful ===
 
'''NOTE:''' Selenium test?
 
====Test Plan====
# Create a new BMO account.
# Make sure to include an irc nick in the Real Name field.
#* E.g. "John Doe [:jdoe]"
# Go to Phabricator and login as the new user.
# Finish account creation.
 
====Results====
# After logging into Phabricator, on the "Create a New Account" page,
## Username should be prefilled with the irc nick,
## Real Name is correct and does not contain [] or any other extraneous characters.
# Clicking register approval completes account creation without error.
# The account works as expected.
 
----
 
=== T2 - Creating a revision is successful ===
 
====Test Plan====
# Make sure you have moz-phab properly setup on your machine and have run <code>moz-phab install-certificate</code> using the Phabricator user you wish to test with as documented above.
# Go to BMO and create a new bug as the Bugzilla user that the Phabricator account is connected to. (Or use an existing public bug).
#* To create bugs directly and bypass triaging, go to https://bugzilla.allizom.org/enter_bug.cgi?product=Firefox&format=__default__ (staging) or https://bugzilla-dev.allizom.org/enter_bug.cgi?product=Firefox&format=__default__ (dev)
# Using the repo listed in the "Getting Started" section above that matches the environment you are testing, make some change to a file.
# Run <code>hg commit -A -m 'Bug <bugid>: New changes'</code>
# Run <code>moz-phab</code>
 
====Results====
# <code>moz-phab</code> only submitted the 1 newly created commit.
# Visit Phabricator and there should be a new revision with the title.
# The revision should contain the correct diff of the changes that were made.
# The "Bugzilla Bug ID" is correct.
## The Bug number is correct.
## The link is correct based on the environment (bugzilla.allizom.org for staging, bugzilla-dev.allizom.org for dev).
## If the bug in Bugzilla is a public bug, the revision should also be public.
# Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section.
# Author received an email from <code>mozphab-dev@mozilla.com</code>. It has a title formatted as "[Differential] [Changed Policy] D{revision number}: {first line}." and a body with a text "phab-bot changed the visibility from "Administrators" to "Public (No Login Required)"."


=== Signing up is successful ===
----
 
=== T3 - Updating a revision with an amended commit is successful ===


====Test Plan====
====Test Plan====
* Create a new BMO account.
 
* Make sure to include an irc nick in the Real Name field.
# <code>hg update</code> to a commit which you previously submitted with moz-phab
  - E.g. "John Doe [:jdoe]"
# Make a change and run <code>hg commit --amend</code>
* Go to Phabricator and login as the new user.
# Run <code>moz-phab</code>
* Finish account creation.


====Results====
====Results====
* On the Phabricator Create a New Account page
# moz-phab should automatically detect a current revision and update it.
  - Username should be prefilled with the irc nick.
# The revision is updated with the new diff on Phabricator:
  - Real Name is correct and does not contain []
## The History tab should have two entries, Diff 1 and Diff 2.
* Clicking register approval completes account creation without error.
## The Commits tab should have a single entry.
  - On local test instances you might have to login as the Phabricator admin
# The bug id and other information remains unchanged.
    and approve the account (see the end of this doc for how).
 
* The account works as expected.
----


[EDGE CASE] Currently when you revoke the "MozPhab" API key on BMO, there
=== T4 - Creating a secure revision is successful ===
is no way to create a new one for Phabricator to use.


=== Creating a revision is successful ===
Your Bugzilla user must belong to a security group, e.g. core-security.


====Test Plan====
====Test Plan====
* Make sure you have arc properly setup on your machine and have run
# Go to bugzilla and create a security bug:
  `arc install-certificate` using the Phabricator user you wish to test with.
# Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
* Go to BMO and create a new bug as the Bugzilla user that the Phabricator
# Run <code>hg commit -A -m 'Bug <bugid>: Private changes'</code>
  account is connected to. (Or use an existing public bug).
# Run <code>moz-phab</code>.
  - To create bugs directly and bypass triaging, go to:
    http://bmo.test/enter_bug.cgi?product=Firefox&format=__default__
* Create a new hg repo (see instructions at the bottom).
* Using the repo listed in the `Getting Started` section that matches the environment you are testing, make some change to a file.
* Run `hg commit -A -m 'commit1: New changes`
* Run `arc diff .^`
* Input something for the title, summary, test plan, and the correct bug id.
* Save and exit the file.


====Results====
====Results====
* arc diff only submitted the 1 newly created commit.
# The diff and information of the revision are as expected.
* Visit Phabricator and there should be a new revision with the title.
# The revision has a "Custom Policy" attached to it.
* The revision should contain the correct diff of the changes that were made
# Click "Edit Revision" and then click on the "Visible To" drop down, and select the "Custom Policy" choice.
* The "Bugzilla Bug ID" is correct.
# It should read "Allow members of projects", followed by the names of projects corresponding to all Bugzilla groups the private bug is categorized under. For example, a bug private to core-security, should have the project name "bmo-core-security".
  - The Bug number is correct.
# The revision has a "secure-revision" project tag added.
  - The link is correct based on the enviroment (bugzilla.mozilla.org in production,
# The revision has a warning titled "This is a secure revision.".
    bmo.test in local testing, etc).
# The revision added the creator as a subscriber.
  - Note: If the bug id is short (like 3, 92, etc, which is common on local
# The revision is visible to the user who made it.
    test environments) the link will not work but that is fine because it only
# The revision is visible to users belonging to the security groups of the bug.
    works on very long bug ids which match what new bugs on production bmo
# Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section with summary as '(secure)'.
    will be using.
# The revision is NOT visible to the public without logging in.
* Visiting the bug on bugzilla shows an x-phabricator-request attachment.
# The revision is NOT visible to logged in members without the correct permission.
 
----
 
=== T5 - Adding a secure bug to an existing revision locks it down ===


=== Updating a revision is successful ===
Your Bugzilla user must belong to a security group, e.g. core-security.  You will also need a second, unprivileged user.


====Test Plan====
====Test Plan====
* `hg update` to a commit which you previously submitted with arc
# Go to bugzilla and create a public bug:
* Make a change and `hg commit`
# Run <code>hg commit -A -m 'Bug <bugid>: Public changes'</code>
  - If you make a new commit run `arc diff .^^`
# Run <code>moz-phab</code>.
  - If you amend the existing commit run `arc diff .^`
# Check if revision is available for public.
# Go to bugzilla and create a security bug:
# Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
# Edit the revision created above, and set the Bugzilla Bug ID field to the ID of the newly created private bug.
# Add the second, unprivileged Bugzilla user to the bug's CC list.


====Results====
====Results====
* arc should automatically detect a revision and ask you if you want to update it.
# The revision has a "Custom Policy" attached to it.
* The revision is updated with the new diff on Phabricator.
# Click "Edit Revision" and then click on the "Visible To" drop down, and select the "Custom Policy" choice.
* The bug id and other information remains unchanged.
# It should read "Allow members of projects", followed by the names of projects corresponding to all Bugzilla groups the private bug is categorized under. For example, a bug private to core-security, should have the project name "bmo-core-security".
# The revision has a "secure-revision" project tag added.
# The revision has the creator and the second Bugzilla user as subscribers.
# The revision is visible to the user who made it.
# The revision is visible to users belonging to the security groups of the bug.
# The revision is NOT visible to the public without logging in.
# The revision is NOT visible to logged in members without the correct permission.
# The revision IS visible to the second Bugzilla user.
# Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section.
# The reviewer received an email from the author with a text "The content for this message can only be transmitted over a secure channel." and a link to Phabricator.


----


=== Creating a secure revision is successful ===
=== T6 - Creating a revision checks the bug id ===


====Test Plan====
====Test Plan====
* Go to bugzilla and create a security bug.
# Enter the bug id as specified for each expected result below.
* Create a new hg commit.
# Run <code>hg commit -A -m 'Bug <bugid>: Public changes'</code>
* Run `arc diff .^`.
# Run <code>moz-phab</code>.
* Enter the title, summary, test plan, and the bug id of the security bug.
* Submit the revision.


====Results====
====Results====
* The diff and information of the revision are as expected.
# Entering an invalid bug id, e.g "abcd efg" or "$1000", fails.
* The revision has a "Custom Policy" attached to it.
# Entering the id of a bug that does not exist fails.
* The revision added the creator as a subscriber.
# Entering the id of a bug of a secure revision that the user does not have access to fails.
* The revision is visible to the user who made it.
# Entering a valid bug id is successful.
* The revision is visible to users belonging to the security groups of the bug.
 
* The revision is NOT visible to the public without logging in.
----
* The revision is NOT visible to logged in members without the correct permission.
* There is an x-phabricator-request attachment on the bug in Bugzilla.


=== Creating a revision checks the bug id ===
=== T7 - Creating multiple revisions with the same bug id is successful ===


====Test Plan====
====Test Plan====
* Create a new hg commit.
# Run <code>hg commit -A -m 'Bug <bugid>: Public changes'</code>
* Run `arc diff .^`
# Run <code>moz-phab</code>.
* Enter information for the title, summary, and test plan.
# Create a different comment using same bug id but different title.
* Enter the bug id, repeat for each expected result.


**Result**
====Result====
* Entering no bug id fails.
# Both revisions are created successfully.
* Entering an invalid bug id like "abcd efg", or "$1000", fails.
# Visiting the bug on Bugzilla shows 2 corresponding entries for the revisions in the Phabricator Revisions section.
* Entering the id of a bug that does not exist fails.
* Entering the id of a bug of a secure revision that the user does not have
  access to fails.
* Entering a valid bug id is successful.


=== Creating multiple revisions with the same bug id is successful ===
----
 
=== T8 - Requesting and leaving a review on a revision is successful ===


====Test Plan====
====Test Plan====
* Create a new hg commit.
# Ensure that you have 2 Phabricator accounts that log in via Bugzilla ready to go.
* Run `arc diff .^`
# Create a commit with other account as reviewer using <code>hg commit -m 'Bug <bugid>: New changes r?<reviewer>'</code>.
* Enter information for the title, summary, and test plan.
# Run <code>moz-phab</code>.
* Enter the bug id.
# Log into Phabricator as the reviewer account.
* Repeat and create another revision with the same bug id.
# Add the "Accept Revision" action at the bottom. Submit.
# Add the "Request Changes" action at the bottom. Submit.


**Result**
====Results====
* Both revisions are created successfully.
# The Phabricator revision is visible in the Bugzilla bug.
* There are 2 corresponding x-phabricator-request attachments on the bug in bugzilla.- Entering no bug id fails.
# Reviewer received an email from author with a text "{author} added a reviewer: {reviewer}"
# Author received an email from reviewer with a text "{reviewer} accepted this revision."
# Author received an email from reviewer with a text "{reviewer} requested changes to this revision."


=== Requesting a reviewer on a revision is successful ===
----
 
=== T9 - Abandoning a revision obsoletes the attachment ===
 
'''NOTE:''' Selenium test?


====Test Plan====
====Test Plan====
* Ensure that you have 2 phabricator accounts that login via BMO ready to go.
# On a previously created revision, perform the "Abandon Revision" action from the "Add Action" dropdown.
  - If not, create a new bugzilla user and the phabricator account for it.
* Create a commit, run arc diff.
* Input the title, summary, test plan, and bug id of a public bug.
* For the reviewers field enter the Phabricator user name of the other account.


====Results====
====Results====
* The revision is created as normal.
# The bug shows the revision as 'Abandoned' in the Phabricator Revisions list of the bug.
* The phabricator attachment on bugzilla is present.
# The bug history shows the attachment is being set to obsolete.
* Phabricator shows the reviewer on the Revision.


----


=== Review Status is propagated to Bugzilla ===
=== T10 - Reclaiming a revision unobsoletes the attachment ===


This test depends on unfinished changes to BMO.
'''NOTE:''' Selenium test?


====Test Plan====
====Test Plan====
* Login to Phabricator as the Reviewer on a Revision
# In the revision used as part of the "Abandoning a revision obsoletes the attachment" test, perform the "Reclaim revision" action.
* Accept the Revision


====Results====
====Results====
* The attachment on the bug in Bugzilla should have
# The bug's Phabricator attachment is unobsoleted and the revision is not abandoned any longer in the Phabricator revisions list.


## How to setup a local test environment
----
* Install arcanist on your machine: https://secure.phabricator.com/book/phabricator/article/arcanist/#installing-arcanist
* Delete all docker containers and images from a previous instance of this test
  environment. Or delete EVERYTHING with:
  - `docker rm $(docker ps -a -q)`
  - `docker rmi $(docker images -q)`
  - `docker volume rm $(docker volume ls)`
* Clone the following repos.
  - https://github.com/mozilla-services/phabricator-extensions
  - https://github.com/mozilla-conduit/bmo-extensions
  - https://github.com/mozilla-conduit/docker-bmo
    - We are making a local clone of docker-bmo because it doesn't update the
      image on DockerHub unless someone commits something on the master branch.
      This could cause situations where changes merged in upstream BMO aren't
      reflected in the local image. We are going to build the image ourselves
      locally.
* In second to last line (i.e. ~63) of the docker-bmo Dockerfile add:
* `RUN chown -R $BUGZILLA_USER.$BUGZILLA_USER /var/www/html/bmo`
* In the docker-compose file in bmo-extensions replace the bmo.test build:
  ```yml
  build:
    context: ../docker-bmo
    dockerfile: ./Dockerfile
  ```
* Follow the instructions at https://github.com/mozilla-conduit/bmo-extensions/blob/master/HACKING.md
  - **\*WHILE DOING SO KEEP IN MIND:\***
  - Make sure to put an empty {} in the `phabext.json` when you make it.
  - If there are any custom changes you want to test in the phabricator-extensions
    repo, create a new git branch and merge the changes.
  - If there are any custom changes you want to test in for the bmo extensions,
    follow the instructions until you get to the point where you can enter inside
    the bmo container. At that point, modify the files directly. wget is inside
    the container to easily download patch files.
      - BMO files are at `/var/www/html/bmo/*`, or something close to that.
      - You will need to stop the container and run `docker-compose up` again
        to restart it with the new changes.
  - You do not need to add the test repo if you use the recommendations below.
  - The instructions to "proxy your port to 1090" mean to add a proxy config
    in the Firefox browser you are using to test with. Options -> Network Proxy
    -> Enter localhost (or ip of the thing running docker), port 1090.
  - You might have to run `cd phabricator && ./bin/storage upgrade` inside the
    phabricator container after the very first time you start it.
  - See the login for Phabricator below for when you have to edit the configuration.
    - Don't forget to change the bmo url to `http://bmo.test`
    - For the bmo api key you will have to generate one by logging into bmo.test
      as the phab-bot@bmo.tld user (one should already be made though).
  - Once you've been able to login through bmo auth (preferably with the new
    unprevileged bmo account you created [details below]), you will have to
    "Approve" it. Login as the Phabricator admin again and go to
    http://phabricator.test/people/query/approval/ and approve the new user.
* **[Recommended]** Create a dummy hg repo on bitbucket.org to use for testing.
* **[Recommended]** Setup Phabricator to use that repository. Create a new one
at http://phabricator.test/diffusion/edit/form/default/. Set repo URL to
observe mode.
* **[Recommended]** Add `apk add openssh` in the Phabricator Dockerfile, rebuld.
Then inside the container create a new ssh key, add it to your bitbucket account,
and run hg clone <repo>. Also run `hg config --edit`.
* **[Recommended]** Inside the Phabricator container alias arc with
`alias arc='/app/arcanist/bin/arc'`.
* **[Recommended]**: Login as admin@mozilla.bugs and create a new unprivileged
user at http://bmo.test/editusers.cgi?action=add. Then test with that user.
(Then login to phabricator.test with the new user and re-run
`arc install-certificate` so that arc uses the new user's credentials).
* **[TIP]** Logins that come preinstalled:
  - Bugzilla
    - User: admin@mozilla.bugs, Password: password
    - User: phab-bot@bmo.tld, Password: password
  - Phabricator:
    - Append a `?admin` to the login URL to show the hidden admin login form.
    - User: admin, Password: admin


=== T12 - Patching Diff created from git repository ===
====Test Plan====
# Using a commit created above run <code>moz-phab HEAD~</code>.
# Fill the ccommit message and confirm.
# Change directory to <code>phabricator-qa-dev</code>.
# Run <code>moz-phab patch D{number of the revision created above}</code>.
====Results====
# Code is sucessfully patched using the Diff.
----
=== T13 - Verify the private revisions deliver emails that does not contain any sensitive content ===
'''NOTE:''' Selenium test?
Your Bugzilla user must belong to a security group, e.g. core-security.
====Test Plan====
# Login to Phabricator (after creating account in Bugzilla) using an account that can have email delivered to it, such as your own email address.
# At the top right of Phabricator, click on your initial or gravatar image to open the drop down menu and select "Settings".
# Click on "Email Delivery".
# Select "Enable Self Action Mail" for the "Self Action" drop down.
# Click "Save Changes".
# Go to Bugzilla and create a security bug:
#* Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
# Create a new hg commit.
# Run <code>moz-phab</code>.
====Results====
# The diff and information of the revision are as expected.
# The revision has a "Custom Policy" attached to it.
# The revision has a "secure-revision" project tag added.
# The revision has a warning titled "This is a secure revision".
# Check to see if you received an email about the new object (Revision) that was just created.
# The email should not contain any information about the revision other than a link to Phabricator.
# Clicking on the link in the email should take you to the Phabricator page that displays the full unfiltered email contents.
# The email contents should contain the title, summary, test plan, reviewers, etc. of the new revision.
# Submitting a public revision should instead show the full contents in the email similar to what was displayed on the Phabricator mail page.
=== T14 - Verify that a reverted commit will reopen the associated revision ===
====Test Plan====
# Clone the following repositories to the same directory on your machine: <code>hg clone https://hg.mozilla.org/conduit-testing/vct vct</code>
# Configure your <code>.ssh/config</code> to contain the following: <code>Host hg.mozilla.org\n  User dlawrence@mozilla.com </code>
# Copy your SSH keys to the .ssh directory and set the appropriate permissions.
# Change into the new repository <code>vct</code>.
# Update `.hg/hgrc` to add the following line to the `[paths]` section: `default:pushurl = ssh://hg.mozilla.org/conduit-testing/vct`
# Make sure you have moz-phab properly setup on your machine and have run <code>moz-phab install-certificate</code> using the Phabricator user you wish to test with as documented above.
# Go to BMO and create a new bug as the Bugzilla user that the Phabricator account is connected to. (Or use an existing public bug).
# Make some change to a file.
# Run <code>hg commit -A -m 'Bug <bugid>: New changes'</code>
# Run <code>moz-phab</code> to create a new revision.
# As the review user, accept the changes in the new revision.
# As the patch author run <code>hg push</code> to push the changes and auto-close the revision.
# To backout the most recent commit, run <code>hg backout .</code> and accept the default commit message.
# Push the new backed out commit by running <code>hg push</code>.
====Results====
# The diff and information of the revision are as expected.
# When <code>hg push</code> is executed, after a period of time, the revision should automatically transition to closed.
# When <code>hg backout</code> commit is pushed, after a period of time, the revision should automatically reopen.
=== T15 - Verify that the Phabricator Email API endpoint is producing correct output ===
To verify that the <code>feed.for_email.query</code> API endpoint is still stable, we can invoke it to get the email events for
a full patch workflow. If the resulting payload hasn't changed, then we know that there hasn't been a regression.
The two patches that we are using are:
* https://phabricator-dev.allizom.org/D2942
* https://phabricator-dev.allizom.org/D2943 (secure bug)
======Note======
The events we are expecting are going to be slightly different than the "real" events that would be generated in
real-time. This is because the state of the revision (such as current reviewers, current bug, etc) are resolved
based on its status at API-call time - '''not''' its status when the event was triggered.
To avoid this inaccuracy, testing the API endpoint would require manually performing all the actions and calling
the endpoint immediately after each one, which would be very tedious.
====Test Plan====
# If you don't already have one, get an API Token for email-bot: https://phabricator-dev.allizom.org/settings/user/email-bot/page/apitokens/.
# If not already available, install [https://stedolan.github.io/jq/ jq].
# Clone the Arcanist code to your current directory: `git clone https://github.com/mozilla-conduit/arcanist.git arcanist`
# From the command-line, invoke:
<syntaxhighlight lang="bash">
$ echo '{
  "storyLimit": 39,
  "after": 6853094612582369220
}' | arcanist/bin/arc call-conduit --conduit-uri https://phabricator-dev.allizom.org/ --conduit-token <your-token> feed.for_email.query -- \
  | jq -r '.response' | jq . > output.txt
</syntaxhighlight>
====Results====
# Copy the [[Phabricator/TestPlan/ExpectationT15|expected payload]] and put it into a file, such as <code>expected.txt</code>
# Check that the file files are identical:


<syntaxhighlight lang="bash">
$ diff <(jq -S . expected.txt) <(jq -S . output.txt)
</syntaxhighlight>


or on Windows, if "jq" is installed:


Please contact a developer within the #conduit IRC channel with further questions.
<syntaxhighlight>
$ jq -S . output.txt > output-sorted.txt
$ jq -S . expected.txt > expected-sorted.txt
$ fc output-sorted.txt expected-sorted.txt
</syntaxhighlight>

Latest revision as of 23:21, 9 March 2022

Getting Started

NOTE: We are using the dev server for QA test runs.

The following manual steps are required to get QA up and running for Phabricator testing on Mozilla's staging server.

Alternatively, you can try out the a preset environment using Docker from this Github repo. Once checked out run:

   docker-compose build
   docker-compose run qa su - phab

You will still need to perform step 8 using your own Conduit API keys.

Manual Setup

1. Install git-cinnabar:

   git clone https://github.com/glandium/git-cinnabar.git --branch master --single-branch
   export PATH=$PATH:`pwd`/git-cinnabar
   cd git-cinnabar && git cinnabar download

2. Install the moz-phab arcanist wrapper used for submitting stacked revisions to Phabricator. You can see instructions on how to install from the [1]. Usually it's enough to just pip3 install MozPhab.

6. Reload your .bash_profile:

   source $HOME/.bash_profile

7. Clone the repo(s) you plan to test on:

8. In the local phabricator-qa-dev repository checkout, run:

   moz-phab install-certificate 

Follow the instructions presented in the command line to associate your local machine with the Phabricator instance via an API key.

9. Test away! You can create branches within your local phabricator-qa-dev repository checkout, add commits, and send them to Phabricator via mozphab. See the Mozilla Phabricator User Documentation for more.

This should be all you need to get going with moz-phab, arc, and our staging and dev servers!

Test Plan

These tests will help ensure that our extensions continue to work as expected when Phabricator is upgraded. They are important as Phacility make no guarantees that internal modules/objects/APIs won't change. See the upgrade process for more.

Please update this doc with new tests as features are added/changed and as holes in the plan are discovered.


T1 - Signing up is successful

NOTE: Selenium test?

Test Plan

  1. Create a new BMO account.
  2. Make sure to include an irc nick in the Real Name field.
    • E.g. "John Doe [:jdoe]"
  3. Go to Phabricator and login as the new user.
  4. Finish account creation.

Results

  1. After logging into Phabricator, on the "Create a New Account" page,
    1. Username should be prefilled with the irc nick,
    2. Real Name is correct and does not contain [] or any other extraneous characters.
  2. Clicking register approval completes account creation without error.
  3. The account works as expected.

T2 - Creating a revision is successful

Test Plan

  1. Make sure you have moz-phab properly setup on your machine and have run moz-phab install-certificate using the Phabricator user you wish to test with as documented above.
  2. Go to BMO and create a new bug as the Bugzilla user that the Phabricator account is connected to. (Or use an existing public bug).
  3. Using the repo listed in the "Getting Started" section above that matches the environment you are testing, make some change to a file.
  4. Run hg commit -A -m 'Bug <bugid>: New changes'
  5. Run moz-phab

Results

  1. moz-phab only submitted the 1 newly created commit.
  2. Visit Phabricator and there should be a new revision with the title.
  3. The revision should contain the correct diff of the changes that were made.
  4. The "Bugzilla Bug ID" is correct.
    1. The Bug number is correct.
    2. The link is correct based on the environment (bugzilla.allizom.org for staging, bugzilla-dev.allizom.org for dev).
    3. If the bug in Bugzilla is a public bug, the revision should also be public.
  5. Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section.
  6. Author received an email from mozphab-dev@mozilla.com. It has a title formatted as "[Differential] [Changed Policy] D{revision number}: {first line}." and a body with a text "phab-bot changed the visibility from "Administrators" to "Public (No Login Required)"."

T3 - Updating a revision with an amended commit is successful

Test Plan

  1. hg update to a commit which you previously submitted with moz-phab
  2. Make a change and run hg commit --amend
  3. Run moz-phab

Results

  1. moz-phab should automatically detect a current revision and update it.
  2. The revision is updated with the new diff on Phabricator:
    1. The History tab should have two entries, Diff 1 and Diff 2.
    2. The Commits tab should have a single entry.
  3. The bug id and other information remains unchanged.

T4 - Creating a secure revision is successful

Your Bugzilla user must belong to a security group, e.g. core-security.

Test Plan

  1. Go to bugzilla and create a security bug:
  2. Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
  3. Run hg commit -A -m 'Bug <bugid>: Private changes'
  4. Run moz-phab.

Results

  1. The diff and information of the revision are as expected.
  2. The revision has a "Custom Policy" attached to it.
  3. Click "Edit Revision" and then click on the "Visible To" drop down, and select the "Custom Policy" choice.
  4. It should read "Allow members of projects", followed by the names of projects corresponding to all Bugzilla groups the private bug is categorized under. For example, a bug private to core-security, should have the project name "bmo-core-security".
  5. The revision has a "secure-revision" project tag added.
  6. The revision has a warning titled "This is a secure revision.".
  7. The revision added the creator as a subscriber.
  8. The revision is visible to the user who made it.
  9. The revision is visible to users belonging to the security groups of the bug.
  10. Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section with summary as '(secure)'.
  11. The revision is NOT visible to the public without logging in.
  12. The revision is NOT visible to logged in members without the correct permission.

T5 - Adding a secure bug to an existing revision locks it down

Your Bugzilla user must belong to a security group, e.g. core-security. You will also need a second, unprivileged user.

Test Plan

  1. Go to bugzilla and create a public bug:
  2. Run hg commit -A -m 'Bug <bugid>: Public changes'
  3. Run moz-phab.
  4. Check if revision is available for public.
  5. Go to bugzilla and create a security bug:
  6. Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
  7. Edit the revision created above, and set the Bugzilla Bug ID field to the ID of the newly created private bug.
  8. Add the second, unprivileged Bugzilla user to the bug's CC list.

Results

  1. The revision has a "Custom Policy" attached to it.
  2. Click "Edit Revision" and then click on the "Visible To" drop down, and select the "Custom Policy" choice.
  3. It should read "Allow members of projects", followed by the names of projects corresponding to all Bugzilla groups the private bug is categorized under. For example, a bug private to core-security, should have the project name "bmo-core-security".
  4. The revision has a "secure-revision" project tag added.
  5. The revision has the creator and the second Bugzilla user as subscribers.
  6. The revision is visible to the user who made it.
  7. The revision is visible to users belonging to the security groups of the bug.
  8. The revision is NOT visible to the public without logging in.
  9. The revision is NOT visible to logged in members without the correct permission.
  10. The revision IS visible to the second Bugzilla user.
  11. Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section.
  12. The reviewer received an email from the author with a text "The content for this message can only be transmitted over a secure channel." and a link to Phabricator.

T6 - Creating a revision checks the bug id

Test Plan

  1. Enter the bug id as specified for each expected result below.
  2. Run hg commit -A -m 'Bug <bugid>: Public changes'
  3. Run moz-phab.

Results

  1. Entering an invalid bug id, e.g "abcd efg" or "$1000", fails.
  2. Entering the id of a bug that does not exist fails.
  3. Entering the id of a bug of a secure revision that the user does not have access to fails.
  4. Entering a valid bug id is successful.

T7 - Creating multiple revisions with the same bug id is successful

Test Plan

  1. Run hg commit -A -m 'Bug <bugid>: Public changes'
  2. Run moz-phab.
  3. Create a different comment using same bug id but different title.

Result

  1. Both revisions are created successfully.
  2. Visiting the bug on Bugzilla shows 2 corresponding entries for the revisions in the Phabricator Revisions section.

T8 - Requesting and leaving a review on a revision is successful

Test Plan

  1. Ensure that you have 2 Phabricator accounts that log in via Bugzilla ready to go.
  2. Create a commit with other account as reviewer using hg commit -m 'Bug <bugid>: New changes r?<reviewer>'.
  3. Run moz-phab.
  4. Log into Phabricator as the reviewer account.
  5. Add the "Accept Revision" action at the bottom. Submit.
  6. Add the "Request Changes" action at the bottom. Submit.

Results

  1. The Phabricator revision is visible in the Bugzilla bug.
  2. Reviewer received an email from author with a text "{author} added a reviewer: {reviewer}"
  3. Author received an email from reviewer with a text "{reviewer} accepted this revision."
  4. Author received an email from reviewer with a text "{reviewer} requested changes to this revision."

T9 - Abandoning a revision obsoletes the attachment

NOTE: Selenium test?

Test Plan

  1. On a previously created revision, perform the "Abandon Revision" action from the "Add Action" dropdown.

Results

  1. The bug shows the revision as 'Abandoned' in the Phabricator Revisions list of the bug.
  2. The bug history shows the attachment is being set to obsolete.

T10 - Reclaiming a revision unobsoletes the attachment

NOTE: Selenium test?

Test Plan

  1. In the revision used as part of the "Abandoning a revision obsoletes the attachment" test, perform the "Reclaim revision" action.

Results

  1. The bug's Phabricator attachment is unobsoleted and the revision is not abandoned any longer in the Phabricator revisions list.

T12 - Patching Diff created from git repository

Test Plan

  1. Using a commit created above run moz-phab HEAD~.
  2. Fill the ccommit message and confirm.
  3. Change directory to phabricator-qa-dev.
  4. Run moz-phab patch D{number of the revision created above}.

Results

  1. Code is sucessfully patched using the Diff.

T13 - Verify the private revisions deliver emails that does not contain any sensitive content

NOTE: Selenium test?

Your Bugzilla user must belong to a security group, e.g. core-security.

Test Plan

  1. Login to Phabricator (after creating account in Bugzilla) using an account that can have email delivered to it, such as your own email address.
  2. At the top right of Phabricator, click on your initial or gravatar image to open the drop down menu and select "Settings".
  3. Click on "Email Delivery".
  4. Select "Enable Self Action Mail" for the "Self Action" drop down.
  5. Click "Save Changes".
  6. Go to Bugzilla and create a security bug:
    • Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
  7. Create a new hg commit.
  8. Run moz-phab.

Results

  1. The diff and information of the revision are as expected.
  2. The revision has a "Custom Policy" attached to it.
  3. The revision has a "secure-revision" project tag added.
  4. The revision has a warning titled "This is a secure revision".
  5. Check to see if you received an email about the new object (Revision) that was just created.
  6. The email should not contain any information about the revision other than a link to Phabricator.
  7. Clicking on the link in the email should take you to the Phabricator page that displays the full unfiltered email contents.
  8. The email contents should contain the title, summary, test plan, reviewers, etc. of the new revision.
  9. Submitting a public revision should instead show the full contents in the email similar to what was displayed on the Phabricator mail page.

T14 - Verify that a reverted commit will reopen the associated revision

Test Plan

  1. Clone the following repositories to the same directory on your machine: hg clone https://hg.mozilla.org/conduit-testing/vct vct
  2. Configure your .ssh/config to contain the following: Host hg.mozilla.org\n User dlawrence@mozilla.com
  3. Copy your SSH keys to the .ssh directory and set the appropriate permissions.
  4. Change into the new repository vct.
  5. Update `.hg/hgrc` to add the following line to the `[paths]` section: `default:pushurl = ssh://hg.mozilla.org/conduit-testing/vct`
  6. Make sure you have moz-phab properly setup on your machine and have run moz-phab install-certificate using the Phabricator user you wish to test with as documented above.
  7. Go to BMO and create a new bug as the Bugzilla user that the Phabricator account is connected to. (Or use an existing public bug).
  8. Make some change to a file.
  9. Run hg commit -A -m 'Bug <bugid>: New changes'
  10. Run moz-phab to create a new revision.
  11. As the review user, accept the changes in the new revision.
  12. As the patch author run hg push to push the changes and auto-close the revision.
  13. To backout the most recent commit, run hg backout . and accept the default commit message.
  14. Push the new backed out commit by running hg push.

Results

  1. The diff and information of the revision are as expected.
  2. When hg push is executed, after a period of time, the revision should automatically transition to closed.
  3. When hg backout commit is pushed, after a period of time, the revision should automatically reopen.

T15 - Verify that the Phabricator Email API endpoint is producing correct output

To verify that the feed.for_email.query API endpoint is still stable, we can invoke it to get the email events for a full patch workflow. If the resulting payload hasn't changed, then we know that there hasn't been a regression. The two patches that we are using are:

Note

The events we are expecting are going to be slightly different than the "real" events that would be generated in real-time. This is because the state of the revision (such as current reviewers, current bug, etc) are resolved based on its status at API-call time - not its status when the event was triggered.

To avoid this inaccuracy, testing the API endpoint would require manually performing all the actions and calling the endpoint immediately after each one, which would be very tedious.

Test Plan

  1. If you don't already have one, get an API Token for email-bot: https://phabricator-dev.allizom.org/settings/user/email-bot/page/apitokens/.
  2. If not already available, install jq.
  3. Clone the Arcanist code to your current directory: `git clone https://github.com/mozilla-conduit/arcanist.git arcanist`
  4. From the command-line, invoke:
$ echo '{
  "storyLimit": 39,
  "after": 6853094612582369220
}' | arcanist/bin/arc call-conduit --conduit-uri https://phabricator-dev.allizom.org/ --conduit-token <your-token> feed.for_email.query -- \
   | jq -r '.response' | jq . > output.txt

Results

  1. Copy the expected payload and put it into a file, such as expected.txt
  2. Check that the file files are identical:
$ diff <(jq -S . expected.txt) <(jq -S . output.txt)

or on Windows, if "jq" is installed:

$ jq -S . output.txt > output-sorted.txt
$ jq -S . expected.txt > expected-sorted.txt
$ fc output-sorted.txt expected-sorted.txt