0

I'm having issues with parallel builds running that require an xvfb server. I was previously using the headless ruby gem, but had sporadic failures when certain test suites that both require capybara-webkit and an xvfb server are running in parallel.

My guess was that they were both trying to use the same DISPLAY, so I attempted to set different DISPLAY values and then run them in parallel, but there was still a failure.

I then tried removing the headless gem and running my test suite with: DISPLAY=localhost:$display_num.0 xvfb-run bundle exec rake where $display_num is a previously set bash variable that is different between the two test suites.

I then get the error: xvfb-run: error: Xvfb failed to start when they were run in parallel.

Any assistance on deciphering this would be great!

MAckerman
  • 408
  • 1
  • 6
  • 15

1 Answers1

0

Here is the gist, but ultimately you need to start one headless per process.

This is effectively done with the features/support/javascript.rb file referenced in the gist, the relevant section being:

# Unnecessary on mac
if (!OS.mac? && !$headless_started)

    require 'headless'
    # allow display autopick (by default)
    # allow each headless to destroy_at_exit (by default)
    # allow each process to have their own headless by setting reuse: false
    headless_server = Headless.new(:reuse => false)
    headless_server.start

    $headless_started = true
    puts "Process[#{Process.pid}] started headless server display: #{headless_server.display}"
end
kross
  • 3,627
  • 2
  • 32
  • 60