TestEngineering/Performance/Raptor/Mitmproxy: Difference between revisions

m
Line 18: Line 18:
     /home/cltbld/tasks/task_1541153570/testing/raptor/mitmdump -k -q -s /home/cltbld/tasks/task_1541153570/build/tests/raptor/raptor/playback/alternate-server-replay.py /home/cltbld/tasks/task_1541153570/testing/raptor/facebook.mp
     /home/cltbld/tasks/task_1541153570/testing/raptor/mitmdump -k -q -s /home/cltbld/tasks/task_1541153570/build/tests/raptor/raptor/playback/alternate-server-replay.py /home/cltbld/tasks/task_1541153570/testing/raptor/facebook.mp


== Recording a Mitmproxy Test Page ==
== How to Record a Mitmproxy Test Page ==
Test pages used for Raptor pageload tests (i.e. raptor-tp6, raptor-gdocs) are mitmproxy recordings that are played back during the test (and ultimately loaded in Firefox via the local proxy). Each test page is a separate mitmproxy recording (*.mp) file, and all the page recordings for each suite are contained in a single zip for that suite (i.e. mitmproxy-recordings-raptor-tp6.zip) on tooltool.
Test pages used for Raptor pageload tests (i.e. raptor-tp6, raptor-gdocs) are mitmproxy recordings that are played back during the test (and ultimately loaded in Firefox via the local proxy). Each test page is a separate mitmproxy recording (*.mp) file, and all the page recordings for each suite are contained in a single zip for that suite (i.e. mitmproxy-recordings-raptor-tp6.zip) on tooltool.


Line 25: Line 25:
The following process was used to record the mitmproxy page archives (on OSX):
The following process was used to record the mitmproxy page archives (on OSX):


1. Install Mitmproxy 2.X following the mitmproxy [http://docs.mitmproxy.org/en/stable/install.html installation instructions]
1. Install Mitmproxy 2.X following the mitmproxy [http://docs.mitmproxy.org/en/stable/install.html installation instructions]. We use version 2.0.2 in production (and that was the version used to record the current pagesets). Note that we are unable to upgrade to a newer Mitmproxy because of some non-backwards compatible changes they made, see [https://bugzilla.mozilla.org/show_bug.cgi?id=1457274 Bug 1457274]).


2. Setup a local proxy in Firefox:
2. Setup a local proxy in Firefox:
Line 47: Line 47:
* Clear the browser history/cache
* Clear the browser history/cache
* In a terminal window start the mitmdump recording tool:
* In a terminal window start the mitmdump recording tool:
   mitmdump -w /path/to/save/recording.mp
   mitmdump -w /path/to/recording.mp
* Inside Firefox browse to the URL that you want to record (i.e. www.spacex.com)
* Inside Firefox browse to the URL that you want to record (i.e. www.spacex.com)
* Wait for the page to be fully loaded and displayed
* Wait for the page to be fully loaded and displayed
Line 53: Line 53:


5. To test playing back your recorded page:
5. To test playing back your recorded page:
* Be sure you have the [https://searchfox.org/mozilla-central/rev/39cb1e96cf97713c444c5a0404d4f84627aee85d/testing/raptor/raptor/playback/alternate-server-replay.py custom playback script] available
* Start Firefox with the proxy still enabled
* Start Firefox with the proxy still enabled
* With Mitmproxy NOT running, browse to your recorded URL (i.e. www.spacex.com); you'll just get an error saying that the proxy server is refusing connections
* With Mitmproxy NOT running, browse to your recorded URL (i.e. www.spacex.com); you'll just get an error saying that the proxy server is refusing connections
* In a terminal window, start Mitmproxy playback:
* In a terminal window, start Mitmproxy playback, using the custom playback script:
   mitmdump -k /path/to/save/recording.mp
   mitmdump -k -s /path/to/alternate-server-replay.py /path/to/recording.mp
 
For example:
  mozilla-unified/obj-x86_64-apple-darwin17.7.0/testing/raptor $ ./mitmdump -k -s "/Users/rwood/mozilla-unified/testing/raptor/raptor/playback/alternate-server-replay.py /Users/rwood/Desktop/new_recordings/no_hero/google-search-no-hero.mp"
 
NOTE: On some platforms you will need quotes around the args as used above.
 
* In Firefox browse to the URL that you recorded already (i.e. www.spacex.com). This time the page will load successfully; it is actually loading the page from the local mitmdump archive file (*.mp) and not the external site
* In Firefox browse to the URL that you recorded already (i.e. www.spacex.com). This time the page will load successfully; it is actually loading the page from the local mitmdump archive file (*.mp) and not the external site
* You can actually turn off your local WiFi connection if you want and verify the page still loads
* In the terminal window press "ctrl + c" to stop the playback
* In the terminal window press "ctrl + c" to stop the playback


Confirmed users
372

edits