持续集成 - 运行需要xvfb的并行测试套件

时间:2022-10-15 23:30:54

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.

我遇到了需要xvfb服务器的并行构建运行问题。我之前使用的是无头红宝石宝石,但是当需要capybara-webkit和xvfb服务器的某些测试套件并行运行时,偶尔会出现故障。

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.

我的猜测是他们都试图使用相同的DISPLAY,所以我试图设置不同的DISPLAY值然后并行运行它们,但仍然有失败。

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.

然后我尝试删除无头gem并运行我的测试套件:DISPLAY = localhost:$ display_num.0 xvfb-run bundle exec rake其中$ display_num是先前设置的bash变量,两个测试套件之间不同。

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

然后我得到错误:xvfb-run:错误:Xvfb在并行运行时无法启动。

Any assistance on deciphering this would be great!

任何解密这个的帮助都会很棒!

1 个解决方案

#1


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:

这是通过gist中引用的features / support / javascript.rb文件有效完成的,相关部分是:

# 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

#1


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:

这是通过gist中引用的features / support / javascript.rb文件有效完成的,相关部分是:

# 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