Phabricator/TestPlan: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
 
(64 intermediate revisions by 7 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.


'''NOTE:''' At this time we are using the dev server for QA test runs rather than staging, as the latter is on the VPN, which has been causing some difficulties.
The following manual steps are required to get QA up and running for Phabricator testing on Mozilla's staging server.


1. Clone the following repositories to the same directory on your machine:
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/libphutil
* https://github.com/phacility/arcanist


2. Add <code>arc</code> to your path.  On OS X and Linux (and the Windows 10 Linux Subsystem), you can add the following to your `~/.bash_profile` (modifying the path appropriately):
    docker-compose build
     alias arc='/Users/youruser/path/to/arcanist/bin/arc'
     docker-compose run qa su - phab


Doing so will allow you to use the <code>arc</code> command from anywhere on your machine.
You will still need to perform step 8 using your own Conduit API keys.


3. Clone the repo(s) you plan to test on:
'''Manual Setup'''


*  Staging:  https://hg.mozilla.org/automation/phabricator-qa-stage/
1. Install git-cinnabar:
*  Dev: https://hg.mozilla.org/automation/phabricator-qa-dev/


4. In the local repository checkout, run:  
    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


     arc install-certificate  
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>.
 
6. Reload your .bash_profile:
 
     source $HOME/.bash_profile
 
7. Clone the repo(s) you plan to test on:
 
*  <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.
Follow the instructions presented in the command line to associate your local machine with the Phabricator instance via an API key.


5. Test away!  You can create branches within your local repository checkout, add commits, and send them to Phabricator via <code>arc diff .^</code>.  See the [http://moz-conduit.readthedocs.io/en/latest/phabricator-user.html Mozilla Phabricator User Documentation] for more.   
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 arc and our staging and dev servers!  
This should be all you need to get going with moz-phab, arc, and our staging and dev servers!


== Test Plan ==
== Test Plan ==
Line 36: Line 48:
Please update this doc with new tests as features are added/changed and as holes in the plan are discovered.
Please update this doc with new tests as features are added/changed and as holes in the plan are discovered.


=== Signing up is successful ===
----
 
=== T1 - Signing up is successful ===
 
'''NOTE:''' Selenium test?


====Test Plan====
====Test Plan====
Line 52: Line 68:
# The account works as expected.
# The account works as expected.


=== Creating a revision is successful ===
----
 
=== T2 - Creating a revision is successful ===


====Test Plan====
====Test Plan====
# Make sure you have arc properly setup on your machine and have run <code>arc install-certificate</code> using the Phabricator user you wish to test with as documented above.
# 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).
# 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)
#* 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.
# 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 'commit1: New changes</code>
# Run <code>hg commit -A -m 'Bug <bugid>: New changes'</code>
# Run <code>arc diff .^</code>
# Run <code>moz-phab</code>
# Input something for the title, summary, test plan, and the correct bug id.
# Save and exit the file.


====Results====
====Results====
# <code>arc diff</code> only submitted the 1 newly created commit.
# <code>moz-phab</code> only submitted the 1 newly created commit.
# Visit Phabricator and there should be a new revision with the title.
# 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 revision should contain the correct diff of the changes that were made.
Line 71: Line 87:
## The Bug number 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).
## The link is correct based on the environment (bugzilla.allizom.org for staging, bugzilla-dev.allizom.org for dev).
#* Note: If the bug id is short (like 3, 92, etc, which is common on local test environments) the link will not work but that is fine because it only works on very long bug ids which match what new bugs on production bmo will be using.
## If the bug in Bugzilla is a public bug, the revision should also be public.
# Visiting the bug on bugzilla shows an <code>x-phabricator-request</code> attachment.
# 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)"."


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


====Test Plan====
====Test Plan====
# <code>hg update</code> to a commit which you previously submitted with arc
 
# <code>hg update</code> to a commit which you previously submitted with moz-phab
# Make a change and run <code>hg commit --amend</code>
# Make a change and run <code>hg commit --amend</code>
# Run <code>arc diff .^</code>
# Run <code>moz-phab</code>


====Results====
====Results====
# arc should automatically detect a revision and ask you if you want to update it.
# moz-phab should automatically detect a current revision and update it.
# The revision is updated with the new diff on Phabricator:
# The revision is updated with the new diff on Phabricator:
## The History tab should have two entries, Diff 1 and Diff 2.
## The History tab should have two entries, Diff 1 and Diff 2.
Line 88: Line 108:
# The bug id and other information remains unchanged.
# The bug id and other information remains unchanged.


=== Creating a secure revision is successful ===
----
 
=== T4 - Creating a secure revision is successful ===


Your Bugzilla user must belong to a security group, e.g. core-security.
Your Bugzilla user must belong to a security group, e.g. core-security.
Line 94: Line 116:
====Test Plan====
====Test Plan====
# Go to bugzilla and create a security bug:
# 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".
# 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>hg commit -A -m 'Bug <bugid>: Private changes'</code>
# Run <code>arc diff .^</code>.
# 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.
# The diff and information of the revision are as expected.
# The revision has a "Custom Policy" attached to it.
# The revision has a "Custom Policy" attached to it.
# Click "Edit Revision" and then click on the "Visible To" drop down, and select the "Custom Policy" choice.
# 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 a warning titled "This is a secure revision.".
# The revision added the creator as a subscriber.
# The revision added the creator as a subscriber.
# The revision is visible to the user who made it.
# The revision is visible to users belonging to the security groups of the bug.
# Visiting the bug on Bugzilla shows an entry for the new revision in the Phabricator Revisions section with summary as '(secure)'.
# The revision is NOT visible to the public without logging in.
# 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====
# Go to bugzilla and create a public bug:
# Run <code>hg commit -A -m 'Bug <bugid>: Public changes'</code>
# Run <code>moz-phab</code>.
# 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====
# The revision has a "Custom Policy" attached to it.
# Click "Edit Revision" and then click on the "Visible To" drop down, and select the "Custom Policy" choice.
# 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 the user who made it.
# The revision is visible to users belonging to the security groups of the bug.
# 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 the public without logging in.
# The revision is NOT visible to logged in members without the correct permission.
# The revision is NOT visible to logged in members without the correct permission.
# There is an <code>x-phabricator-request</code> attachment on the bug in Bugzilla.
# 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 revision checks the bug id ===
=== T6 - Creating a revision checks the bug id ===


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


====Results====
====Results====
# Entering no bug id fails with a helpful message.
# Entering an invalid bug id, e.g "abcd efg" or "$1000", fails.
# Entering an invalid bug id, e.g "abcd efg" or "$1000", fails.
# Entering the id of a bug that does not exist fails.
# Entering the id of a bug that does not exist fails.
Line 125: Line 179:
# Entering a valid bug id is successful.
# Entering a valid bug id is successful.


=== Creating multiple revisions with the same bug id is successful ===
----
 
=== 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 <code>arc diff .^</code>
# 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 and create another revision with the same bug id.


====Result====
====Result====
# Both revisions are created successfully.
# Both revisions are created successfully.
# There are 2 corresponding <code>x-phabricator-request</code> attachments on the bug in Bugzilla.
# Visiting the bug on Bugzilla shows 2 corresponding entries for the revisions in the Phabricator Revisions section.
 
----


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


====Test Plan====
====Test Plan====
# Ensure that you have 2 Phabricator accounts that log in via Bugzilla ready to go.
# Ensure that you have 2 Phabricator accounts that log in via Bugzilla ready to go.
# Create a commit, run <code>arc diff .^</code>.
# Create a commit with other account as reviewer using <code>hg commit -m 'Bug <bugid>: New changes r?<reviewer>'</code>.
# Input the title, summary, test plan, and bug id of a public bug.
# Run <code>moz-phab</code>.
# For the "Reviewers" field enter the Phabricator user name of the other account.
# Log into Phabricator as the reviewer account.
# Log into Phabricator as the reviewer account.
# Add the "Accept Revision" action at the bottom.
# Add the "Accept Revision" action at the bottom. Submit.
# Add the "Request Changes" action at the bottom.
# Add the "Request Changes" action at the bottom. Submit.
 
====Results====
# The Phabricator revision is visible in the Bugzilla bug.
# 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."
 
----
 
=== T9 - Abandoning a revision obsoletes the attachment ===
 
'''NOTE:''' Selenium test?
 
====Test Plan====
# On a previously created revision, perform the "Abandon Revision" action from the "Add Action" dropdown.


====Results====
====Results====
# The Phabricator attachment on Bugzilla is present.
# The bug shows the revision as 'Abandoned' in the Phabricator Revisions list of the bug.
# The Phabricator attachment on the bug should have no r+ flags.
# The bug history shows the attachment is being set to obsolete.


=== Resigning as a reviewer removes r+ ===
----
 
=== T10 - Reclaiming a revision unobsoletes the attachment ===
 
'''NOTE:''' Selenium test?


====Test Plan====
====Test Plan====
# Ensure that you have 2 Phabricator accounts that log in via Bugzilla ready to go.
# In the revision used as part of the "Abandoning a revision obsoletes the attachment" test, perform the "Reclaim revision" action.
# Create a commit, run <code>arc diff .^</code>.
 
# Input the title, summary, test plan, and bug id of a public bug.
====Results====
# For the "Reviewers" field enter the Phabricator user name of the other account.
# The bug's Phabricator attachment is unobsoleted and the revision is not abandoned any longer in the Phabricator revisions list.
# Log into Phabricator as the reviewer account.
 
# Add the "Accept Revision" action at the bottom.
----
# Add the "Resign as Reviewer" action at the bottom.
 
=== 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====
====Results====
# The Phabricator attachment on Bugzilla is present.
# Code is sucessfully patched using the Diff.
# The Phabricator attachment on the bug should have no r+ flags.
 
----
 
=== T13 - Verify the private revisions deliver emails that does not contain any sensitive content ===
 
'''NOTE:''' Selenium test?


=== Plan Changes clears r+s ===
Your Bugzilla user must belong to a security group, e.g. core-security.


====Test Plan====
====Test Plan====
# Ensure that you have 2 Phabricator accounts that log in via Bugzilla ready to go.
# Login to Phabricator (after creating account in Bugzilla) using an account that can have email delivered to it, such as your own email address.
# Create a commit, run <code>arc diff .^</code>.
# At the top right of Phabricator, click on your initial or gravatar image to open the drop down menu and select "Settings".
# Input the title, summary, test plan, and bug id of a public bug.
# Click on "Email Delivery".
# For the "Reviewers" field enter the Phabricator user name of the other account.
# Select "Enable Self Action Mail" for the "Self Action" drop down.
# Log into Phabricator as the reviewer account.
# Click "Save Changes".
# Add the "Accept Revision" action at the bottom.
# Go to Bugzilla and create a security bug:
# Log into Phabricator as the revision author account.
#* Click "Edit Bug", open the "Security" panel, and check one of the security-sensitive boxes, e.g. "Security-Sensitive Core Bug".
# Add the "Plan Changes" action at the bottom.
# Create a new hg commit.
# Run <code>moz-phab</code>.


====Results====
====Results====
# The Phabricator attachment on Bugzilla is present.
# The diff and information of the revision are as expected.
# The Phabricator attachment in Bugzilla does not have any r+ flags.
# 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.


=== Abandoning a revision obsoletes the attachment ===
=== T14 - Verify that a reverted commit will reopen the associated revision ===


====Test Plan====
====Test Plan====
# Create a new bug.
# Clone the following repositories to the same directory on your machine: <code>hg clone https://hg.mozilla.org/conduit-testing/vct vct</code>
# Create a commit and run <code>arc diff .^</code>.
# Configure your <code>.ssh/config</code> to contain the following: <code>Host hg.mozilla.org\n  User dlawrence@mozilla.com </code>
# Input the title, summary, test plan, and bug id of the newly created bug.
# Copy your SSH keys to the .ssh directory and set the appropriate permissions.
# Go to the newly created revision and perform the "Abandon Revision" action from the "Add Action" dropdown.
# 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====
====Results====
# The bug has no active attachments listed.
# The diff and information of the revision are as expected.
# The bug has one obsolete attachment listed, linking to the created revision.
# 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.


=== Reclaiming a revision unobsoletes the attachment ===
=== 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====
====Test Plan====
# In the revision created as part of the "Abandoning a revision obsoletes the attachment" test, perform the "Reclaim revision" action.
# 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====
====Results====
# The bug's Phabricator attachment is unobsoleted.
# 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:
 
<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