QA/Execution/Web Testing/Automation/Selenium Grid: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 133: Line 133:
# Stop the Selenium hub by running <code>sudo initctl stop selenium</code>
# Stop the Selenium hub by running <code>sudo initctl stop selenium</code>
# Download the new Selenium server by running the following, replacing the version numbers as appropriate:
# Download the new Selenium server by running the following, replacing the version numbers as appropriate:
#* <code>sudo wget -P /opt/selenium <nowiki>http://selenium-release.storage.googleapis.com/2.52/selenium-server-standalone-2.52.0.jar</nowiki></code>
#* <code>sudo wget -P /opt/selenium <nowiki>http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar</nowiki></code>
# Update the Selenium version in <code>/etc/init/selenium.conf</code>
# Update the Selenium version in <code>/etc/init/selenium.conf</code>
# Start the Selenium hub by running <code>sudo initctl start selenium</code>
# Start the Selenium hub by running <code>sudo initctl start selenium</code>

Revision as of 21:57, 5 July 2016

moz-grid-config

moz-grid-config is a project for managing our Selenium infrastructure. It includes the latest version of Selenium that we're using, and a mechanism for starting the hub/nodes. You can find documentation on moz-grid-config at the GitHub project page.

Selenium Grid Hub

The Selenium Grid hub is running on a VM in our data-center. For setup and administration see our internal documentation. We also have a staging instance documented here.

Selenium Grid Nodes

Mac OS X Nodes

The following Mac Minis are running on our data-center. For setup and administration see our internal documentation.

  • selenium-mac1.qa.scl3.mozilla.com
  • selenium-mac2.qa.scl3.mozilla.com
  • selenium-mac3.qa.scl3.mozilla.com (staging)

Windows Nodes

The following Windows VMs are running on our data-center:

  • selenium1.qa.scl3.mozilla.com (10.22.73.149)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk
  • selenium2.qa.scl3.mozilla.com (10.22.73.150)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk
  • selenium3.qa.scl3.mozilla.com (10.22.73.151)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk
  • selenium4.qa.scl3.mozilla.com (10.22.73.152)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk
  • selenium5.qa.scl3.mozilla.com (10.22.73.153)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk
  • selenium6.qa.scl3.mozilla.com (10.22.73.154)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk
  • selenium-staging1.qa.scl3.mozilla.com (10.22.73.138)
    • Windows 7, 8 GB RAM, 2 cores, 150GB disk

Starting Mac OS X Nodes

Connect to the appropriate machine, and execute the following from a terminal (you can use SSH or VNC):

   cd ~/moz-grid-config
   ant -Denv=production

The -Denv value can be either production or staging, and controls which Selenium hub the node connects to. Omitting this, or any other value will assume the hub is running on localhost.

Starting Windows Nodes

We use the msysgit tool on Windows. Connect to the appropriate machine using Remote Desktop, start the MsysGit tool on the desktop, and run the following commands:

   cd ~/moz-grid-config
   ant -autoproxy -Denv=production

We need the -autoproxy helper because the these nodes run through a proxy.

The -Denv value can be either production or staging, and controls which Selenium hub the node connects to. Omitting this, or any other value will assume the hub is running on localhost.

Stopping Nodes

Terminate the process using Ctrl+C.

Adding a Browser

Configuration

You will need to fork and clone from the moz-grid-config github repository and work on a new branch.

  1. Add the browser, alias, and path to grid_configuration.yml.
  2. Add the browser, binary and details to the JSON configuration files.
  3. Submit a pull request to the main GitHub repository from your branch.

Hub/Nodes

  1. Prepare Jenkins for shutdown - this will allow all currently running jobs to finish, but will not start any new jobs.
  2. Once no jobs are running, stop the Selenium Grid hub
  3. Pull in the latest changes from moz-grid-config
  4. Start the Selenium Grid hub
  5. For each node:
    1. Stop the Selenium server
    2. Pull in the latest changes from moz-grid-config
    3. Install the appropriate browser
    4. Start the Selenium server

Installing Firefox

  • All new browsers should be installed with the version number in the path so that moz-grid-config can always find them.
  • Install mozdownload and mozinstall using pip to download and install the Firefox binaries.
    • Use --help for both mozdownload and mozinstall to see all available options
    • To download the latest release using mozdownload you can simply use: mozdownload -v latest
    • To download the latest Firefox Nightly build using mozdownload you can use: mozdownload -t daily --branch=mozilla-central
    • To download the latest Firefox Aurora build using mozdownload you can use: mozdownload -t daily --branch=mozilla-aurora
    • Releases are also available to download manually here

Mac OS X

From a terminal:

   mozdownload -v 46.0 -d firefox.dmg
   mozinstall -d /tmp firefox.dmg
   mv /tmp/Firefox.app/ "/Applications/Firefox 46.app/"
   rm firefox.dmg

Windows

From a command prompt:

   mozdownload -v 46.0 -p win32 -d firefox.exe
   mozinstall -d %TMP% firefox.exe
   move %TMP%\firefox\core "\Program Files (x86)\Mozilla Firefox 46"
   del firefox.exe

Setting hostname on Mac OS X

If you are running a version of OSX prior to 10.5, then look in /etc/hostconfig for the HOSTNAME= parameter and set it to be the FQDN (Fully Qualified Domain Name) that you want to use. So, for host foo located in the domain bar.com, the entry would be as follows:

   HOSTNAME=foo.bar.com

For OSX 10.5, /etc/hostconfig is being deprecated. There are a couple of preferred methods to do this in 10.5:

   sudo hostname -s foo.bar.com

or:

   sudo scutil –set HostName foo.bar.com

You can verify the change by issuing the following command:

   hostname

The output will display the FQDN of the computer.

Updating Selenium

Follow these steps to upgrade the version of Selenium.

Update staging instance

  1. If you're not on a Mozilla office network, connect to the Mozilla VPN
  2. Login to Jenkins
  3. Prepare Jenkins for shutdown
  4. Wait until no jobs are running
  5. Connect to selenium-staging1.qa.scl3.mozilla.com using RDP
  6. Stop the Selenium node by hitting Ctrl+C in the terminal window
  7. Update the Selenium major and minor versions in C:\Users\mozauto\moz-grid-config\default.properties
  8. Start the Selenium server by running ant -autoproxy -Denv=staging -Dnode.host=IP
  9. Connect to selenium-mac3.qa.scl3.mozilla.com using VNC
  10. Stop the Selenium node by hitting Ctrl+C in the terminal window
  11. Update the Selenium version in /Users/webqa/moz-grid-config/default.properties
  12. Start the Selenium server by running ant -Denv=staging
  13. Connect to selenium-hub-staging1.qa.scl3.mozilla.com using SSH
  14. Stop the Selenium hub by running sudo initctl stop selenium
  15. Download the new Selenium server by running the following, replacing the version numbers as appropriate:
    • sudo wget -P /opt/selenium http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
  16. Update the Selenium version in /etc/init/selenium.conf
  17. Start the Selenium hub by running sudo initctl start selenium
  18. Cancel the Jenkins shutdown
  19. Verify the hub and node versions on the Selenium hub console

Test staging instance

Run tests against the staging instance. You can do this locally by pointing your tests at host selenium-hub1.qa.scl3.mozilla.com and port 4444, or you can run tests via the staging Jenkins instance. For convenience, there is a job named grid.sanity that will run a variety of tests against both the Windows and OS X platforms.

Update moz-grid-config

Once testing is finished and we're satisfied that there are no regressions, submit a pull request for moz-grid-config that changes the version number in default.properties. This will need a review from a team member before it gets merged.

Update production instance

  1. Login to Jenkins
  2. Prepare Jenkins for shutdown
  3. Wait until no jobs are running
  4. Connect to selenium1.qa.scl3.mozilla.com using RDP
  5. Stop the Selenium node by hitting Ctrl+C in the terminal window
  6. Pull down the latest moz-grid-config changes by running git pull
  7. Start the Selenium server by running ant -autoproxy -Denv=production
  8. Repeat steps 4-7 on selenium2, selenium3, selenium4, selenium5, and selenium6
  9. Connect to selenium-mac1.qa.scl3.mozilla.com using VNC
  10. Stop the Selenium node by hitting Ctrl+C in the terminal window
  11. Pull down the latest moz-grid-config changes by running git pull
  12. Start the Selenium server by running ant -Denv=production
  13. Repeat steps 9-12 on selenium-mac2
  14. Connect to selenium-hub1.qa.scl3.mozilla.com using SSH
  15. Stop the Selenium hub by running sudo initctl stop selenium
  16. Download the new Selenium server by running the following, replacing the version numbers as appropriate:
    • sudo wget -P /opt/selenium http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar
  17. Update the Selenium version in /etc/init/selenium.conf
  18. Start the Selenium hub by running sudo initctl start selenium
  19. Verify the hub and node versions on the Selenium hub console
  20. Cancel the Jenkins shutdown

Housekeeping

  1. Reset moz-grid-config on the staging nodes by running git reset --hard HEAD
  2. Pull in the official changes by running git pull

Updating Firefox

Follow these steps to upgrade the version of Firefox used by Selenium.

Update staging instance

  1. If you're not on a Mozilla office network, connect to the Mozilla VPN
  2. Login to Jenkins
  3. Prepare Jenkins for shutdown
  4. Wait until no jobs are running
  5. Connect to selenium-staging1.qa.scl3.mozilla.com using RDP
  6. Stop the Selenium node by hitting Ctrl+C in the terminal window
  7. Install the new version of Firefox (see previous section above)
  8. Update the Firefox versions in C:\Users\mozauto\moz-grid-config\win7.json
  9. Start the Selenium server by running ant -autoproxy -Denv=staging -Dnode.host=IP
  10. Connect to selenium-mac3.qa.scl3.mozilla.com using VNC
  11. Stop the Selenium node by hitting Ctrl+C in the terminal window
  12. Install the new version of Firefox (see previous section above)
  13. Update the Firefox versions in /Users/webqa/moz-grid-config/mac.json
  14. Start the Selenium server by running ant -Denv=staging
  15. Cancel the Jenkins shutdown

Test staging instance

Run tests against the staging instance. You can do this locally by pointing your tests at host selenium-hub1.qa.scl3.mozilla.com and port 4444, or you can run tests via the staging Jenkins instance. For convenience, there is a job named grid.sanity that will run a variety of tests against both the Windows and OS X platforms. Be sure to override the Firefox version to match the version you've just installed.

Update moz-grid-config

Once testing is finished and we're satisfied that there are no regressions, submit a pull request for moz-grid-config that changes the Firefox versions. This will need a review from a team member before it gets merged.

Update production instance

  1. Login to Jenkins
  2. Prepare Jenkins for shutdown
  3. Wait until no jobs are running
  4. Connect to selenium1.qa.scl3.mozilla.com using RDP
  5. Stop the Selenium node by hitting Ctrl+C in the terminal window
  6. Install the new version of Firefox (see previous section above)
  7. Pull down the latest moz-grid-config changes by running git pull
  8. Start the Selenium server by running ant -autoproxy -Denv=production
  9. Repeat steps 4-8 on selenium2, selenium3, selenium4, selenium5, and selenium6
  10. Connect to selenium-mac1.qa.scl3.mozilla.com using VNC
  11. Stop the Selenium node by hitting Ctrl+C in the terminal window
  12. Install the new version of Firefox (see previous section above)
  13. Pull down the latest moz-grid-config changes by running git pull
  14. Start the Selenium server by running ant -Denv=production
  15. Repeat steps 10-14 on selenium-mac2
  16. Cancel the Jenkins shutdown
  17. Update the DEFAULT_FIREFOX_VERSION environment variable in the Jenkins configuration

Housekeeping

  1. Reset moz-grid-config on the staging nodes by running git reset --hard HEAD
  2. Pull in the official changes by running git pull
  3. Update the DEFAULT_BROWSER_VERSION environment variable in the staging Jenkins configuration