Xvfb插件可在Jenkins上同时运行多个作业实例 [英] Xvfb plugin to run multiple job instances concurrently on Jenkins

查看:322
本文介绍了Xvfb插件可在Jenkins上同时运行多个作业实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jenkins有一份工作,它运行用Selenium编写的UI测试.该作业可以同时运行它的多个实例.我在尝试使用Xvfb时遇到问题( Xvfb插件或其他方式.

I have a job in Jenkins that runs UI tests written in Selenium. The job can run multiple instances of it concurrently. I am running into a problem while trying to use Xvfb (the Xvfb plugin or otherwise).

使用Xvfb插件

配置如下. 该插件将相同的显示端口分配给2个并发作业实例,然后一个失败.

The configuration is as below. The plugin assigns the same display port to 2 concurrent job instances, and then one fails.

在Xvfb日志中(请注意,两种情况下displayfd均为2,屏幕均为0):

From the Xvfb log (note displayfd is 2 and screen is 0 in both cases):

Xvfb starting$ /usr/bin/Xvfb -displayfd 2 -screen 0 1024x758x16 -fbdir /srv/jenkins/xvfb-86-2156913754362856583.fbdir
Xvfb starting$ /usr/bin/Xvfb -displayfd 2 -screen 0 1024x758x16 -fbdir /srv/jenkins/xvfb-87-5845090375656014678.fbdir

以上两个作业实例之一失败.失败消息是这样的:

One of the above 2 job instances fails. The failure message is this:

02:11:51 _XSERVTransSocketINETCreateListener: ...SocketCreateListener() failed
02:11:51 _XSERVTransMakeAllCOTSServerListeners: server already running

如何解决此错误,以便并发实例运行没有任何问题?

How can this error be fixed so that the concurrent instances run without any issue?

此外,我想知道Xvfb插件如何将显示与正在运行的浏览器实例(在本例中为Firefox)关联.它是否在内部执行export DISPLAY=:xx,其中xx =插件计算出的显示端口?

Further, I wonder how Xvfb plugin does the association of the display to the running browser instances (Firefox in this case). Does it do export DISPLAY=:xx internally, where xx = the display port as computed by the plugin?

命令行(不使用Xvfb插件)

我尝试的第二种方法是不使用插件,而直接使用CLI运行Xvfb.我使用Jenkins env变量BUILD_NUMBER来确保与作业实例的唯一显示关联.

The second way I tried is not to use the plugin and run Xvfb directly using the CLI. I used the Jenkins env variable BUILD_NUMBER to ensure unique display association to the job instance.

export DISPLAY=:${BUILD_NUMBER}
Xvfb :${BUILD_NUMBER} -screen 0 1024x768x24 &

在两个作业实例中Xvfb都可以正常启动,但是测试失败了.

Xvfb starts up fine in both job instances, but the tests fail with this.

Failed to connect to binary FirefoxBinary(/usr/local/bin/firefox) on port 7055; process output follows: 
Error: cannot open display: 0:0

看来测试仍在尝试使用显示0:0.

It appears the tests are still trying to use display 0:0.

非常感谢您提供解决此问题的帮助.

Any help to fix this problem is greatly appreciated.

推荐答案

您是否尝试过在Jenkins中使用Display环境变量,而Xvbf是从此开始的?就我而言,它起作用了,我按照本文中的说明进行操作,无头Jenkins中执行硒测试

Have you tried to use Display environment variable in Jenkins, the same Xvbf has started with? In my case it worked and I followed the instructions, described in this article headless execution selenium tests in Jenkins

这篇关于Xvfb插件可在Jenkins上同时运行多个作业实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆