Last modified: 2014-11-13 14:47:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T73602, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 71602 - mediawiki_selenium always use the same default xvfb display 99
mediawiki_selenium always use the same default xvfb display 99
Status: NEW
Product: Wikimedia
Classification: Unclassified
Quality Assurance (Other open bugs)
wmf-deployment
All All
: High normal (vote)
: ---
Assigned To: Dan Duvall
:
Depends on:
Blocks: 66449
  Show dependency treegraph
 
Reported: 2014-10-03 09:38 UTC by Antoine "hashar" Musso (WMF)
Modified: 2014-11-13 14:47 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Antoine "hashar" Musso (WMF) 2014-10-03 09:38:44 UTC
Our firefox browser tests running on local instances kept complaining of losing connection to the firefox web driver after 45 seconds.   We never really managed to figure out the issue and went with throttling the browsertests to ensure that only one run per instance ( https://gerrit.wikimedia.org/r/#/c/155337/ ).

Timo proposed a patch to add chromium and a xvfb server on the contint slaves which propose to maintain an xvfb service on display port 99.  That is what triggered the race condition warning to me.


In mediawiki_selenium we use ruby gems headless defaults:

  require "headless"
  headless = Headless.new
  headless.start

Then destroy it:

  at_exit do
    headless.destroy
  end

Looking at headless code ( https://github.com/leonid-shevtsov/headless/blob/master/lib/headless.rb ) the default are:

* display port 99
* auto picking disabled (since display port is set)
* reuses display

When the first test start, that boot an xvfb on display port 99.  A second test starting in parallel will end up reusing the same display.  Imho that would cause a bunch of race conditions between the two browsers being run.


mediawiki_selenium should probably be invoked with:

 Headless.new(autopick: true, reuse: false)

We could have that tweakable via env variable such as HEADLESS_DISPLAY, HEADLESS_AUTOPICK and HEADLESS_REUSE.
Comment 1 Dan Duvall 2014-10-03 23:10:08 UTC
I can repro the reported behavior consistently in MWV using the following feature/steps.

  Feature: Parallel Tests
  
    Scenario: Process 1
      When I wait 10 seconds
      Then the browser connection should still be alive
  
    Scenario: Process 2
      When I wait 2 seconds
      Then the browser connection should still be alive
  
  
  Given(/^I wait (\d+) seconds$/) do |seconds|
    sleep seconds.to_i
  end
  
  Then(/^the browser connection should still be alive$/) do
    expect(@browser.execute_script("return true")).to be(true)
  end

And by executing the scenarios in parallel.

  shell 1$ HEADLESS=true bundle exec cucumber features/test.feature:3
  shell 2$ HEADLESS=true bundle exec cucumber features/test.feature:7
Comment 2 Gerrit Notification Bot 2014-10-03 23:50:59 UTC
Change 164704 had a related patch set uploaded by Dduvall:
Additional headless environment variables

https://gerrit.wikimedia.org/r/164704
Comment 3 Dan Duvall 2014-10-03 23:58:29 UTC
I've submitted a patch that will allow you to provide additional environment variables.

Note that simply telling Headless to keep the xvfb process running (destroy_at_exit: false) was enough for my tests to pass. In other words, it appears that the race condition at fault is xvfb shutdown, not a conflict of the display port. However, in case you run into issues screenshot-ing, etc. when using the same display port for multiple test runners, I've also provided an environment variable binding for that.
Comment 4 Krinkle 2014-10-07 08:09:09 UTC
(In reply to Antoine "hashar" Musso from comment #0)
> Timo proposed a patch to add chromium and a xvfb server on the contint
> slaves which propose to maintain an xvfb service on display port 99.  That
> is what triggered the race condition warning to me.
> 
> 

For the record, my patch uses Xvdb server number 94, not 99. This suspicious may have helped tracked it down, but my deployment did not affect browser tests.
Comment 5 Gerrit Notification Bot 2014-10-07 10:34:46 UTC
Change 164704 merged by jenkins-bot:
Additional headless environment variables

https://gerrit.wikimedia.org/r/164704
Comment 6 Antoine "hashar" Musso (WMF) 2014-11-13 13:11:21 UTC
The patch has been merged and is included in mediawiki_selenium 0.4.1.

We have to adjust all repositories to require 0.4.1 and update the Jenkins jobs to set the proper variables.  Most probably:

 export HEADLESS=true
 export HEADLESS_DESTROY_AT_EXIT=false
 bundle exec cucumber

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links