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).
Using the Xvfb plugin
The configuration is as below.
The plugin assigns the same display port to 2 concurrent job instances, and then one fails.
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?
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?
Command line (not using Xvfb plugin)
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 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
It appears the tests are still trying to use display 0:0.
Any help to fix this problem is greatly appreciated.
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
Related
I have a test suite that uses the Webdriver Sampler plugin (https://jmeter-plugins.org/wiki/WebDriverSampler/) configured with Chromedriver. If I run my tests in "regular" non-gui mode the plugin works, i.e. starts the chromedriver and performs the test script.
When I try to run the test in distributed mode, the chromedriver doesn't seem to start, and no errors are found in logs.
I've tried to run the tests from my master node targeting the slave node, as well as running them from the slave node itself (targeting the running jmeter-server that is running on the slave).
Running tests without the above plugin works (e.g. running a HTTP-request based test suite from master targeting the slave)
Do I have to configure the plugin for jmeter-server too somehow?
You need to:
Install WebDriver Sampler plugin to all slave machines (jmeter-servers) using JMeter Plugins Manager
Install chromedriver binary to all slave machines at the same place
Make sure that Chrome browser is installed at all slaves and it's in operating system PATH
When you run JMeter test in distributed mode the master machine transfers only .jmx test script to slaves and collects results from them, any other extra files like:
plugins
CSV files used for parameterization
properties files
etc.
should be copied over from the master machine manually or using a script
It turns out that the plugin actually worked, but in order for chromedriver to run properly a display variable has to be set on each slave node.
Install xvfb
run commands:
Xvfb :1 -screen 5 1024x768x8 &
export DISPLAY=:1.5
As described in: Running Chrome WebDriver on a linux server with no display
I'm using vmrun.exe from VMware Workstation to start an Ubuntu 16 desktop VM and launch a Java selenium Firefox process in it. I can start and launch the script however I would like the selenium process to be visible in case a user would like to monitor it. It gives the following error when trying to launch firefox with a visible GUI.
org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/home/vmdops/firefox/firefox) on port 7055; process output follows:
Error: GDK_BACKEND does not match available displays
The following bash script is used to launch the process
java -jar seleniumProcess.jar
I can execute the process headless with XVFB and run the selenium process in memory however then I cannot view the process running visually.
/usr/bin/Xvfb :1 & export DISPLAY=:1
java -jar seleniumProcess.jar
What is the proper terminology to explain why the firefox browser cannot be displayed?
Is there anyway to launch the selenium process from VMRUN that allows the firefox browser to display normally?
Thanks
Conteh
I was able to resolve the issue adding -interactive to the end of the command
vmrun -T player -gu vmdops -gp xxxx runScriptInGuest "C:\VMDOPS2\VMDOPS2.vmx" /bin/bash "sh /home/vmdops/autovpn/runProfiler.sh" -interactive
This works when the use is already logged in interactively. When I launch too quickly after starting the vm I get the following error.
Error: The specified guest user must be logged in interactively to perform this operation
So one must wait a while after booting.
Can't get my protractor running on remote server on headless mode. I'll be glad if anyone could help
This is my qa server setting:
Under /etc/init.d/xvfb script to stat Xvfb :99
export DISPLAY=:99 set in bash_profile ( echo $DISPLAY returns :99)
firefox and protractor installed.
My project pom.xml:
I'm using maven-wagon-plugin to execute
The script starting xvfb on display:99 on my qa server
Run protractor protractorTest/conf.js on my qa server
When running the job from jenkins
=> I'm getting error E/launcher - Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Firefox console output: Error: no display specified
Checked if the xvfb is running:
ps -ef | grep Xvfb on QA server shows the Xvfb process running, but
Please let me know if something is wrong or missing?
The xvfb need to start in the same script that is running protractor. So Maven wagon plugin can be used to execute the command that starts the xvfb + runs protractor tests.
Source: #sou comment.
Background
I am running a set of selenium tests using a Maven and Jenkins with Testng. I had them working fine headlessly up until a week ago. Jenkins sits on the server accessible with port 8080. The tests also run fine through eclipse.
Software Versions
I have read lots about Firefox being incomparable with selenium so here is a list of software and versions that I am using.
Firefox: 39
Maven: 3.3.3
Java: 1.7.0_79
Selenium: 2.46 & 2.47(currently 2.47)
Jenkins: 1.622
Xvnc: 1.3.9
ubuntu 14
Error
After I run the tests and the fail I check the console through Jenkins. The error I am getting makes me think it's a problem with Xvnc and firefox but I can't pin point it. I get a NotConnectedException. The firefox console error has changed a few times here is a list of different errors the console has shown me.
Error: cannot open display: :87
firefox: Fatal IO error 11 (Resource temporarily unavailable) on X server :46.
firefox: Fatal IO error 2 (No such file or directory) on X server :78.
Research
I've been on bugzilla but cant find a conclusive answer to the problem.
I've also looked around SO but found no fixes.
Conclution
From what I have gathered it is something to do with Xvnc, Could running
sudo apt-get update
make changes to how Xvnc operates? I have updated the packages some time last week but our testers didn't check Jenkins properly when adding new tests and as such I've wasted and entire day trying to pin point when and what the problem is.
Question
What would cause Jenkins to return errors like this, how can I fix them and how can I prevent something doing this again?
EDIT 1
The display variable seems to be the issue, upon typing the command
echo $DISPLAY
There is no response just an empty line.
EDIT 2
running the command
export DISPLAY=:0.10
no gives the result
:0.10
when I echo $DISPLAY
I think the DISPLAY varibale is not functioning as expected and hence firefox is unable to connect to it. To know more about the $DISPLAY refer this link https://askubuntu.com/questions/432255/what-is-display-environment-variable
Try to run this command on the slave node where the job runs, this should give you the required setting for the tests to connect and run.
nohup /usr/bin/Xvfb :2 –screen 0 1024x768x24 > /dev/null 2>&1 &
I have a WebDriver test using the FirefoxDriver that I am attempting to run as a Jenkins job.
It works fine in Windows, it also works from the command line in Linux, where my Jenkins server lives.
Unfortunately, I got the following error during executing as a Jenkins job:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms
The Jenkins job consists of 2 steps: a shell step that executes:
Xvfb :1 -screen 0 1024x768x24 &
export DISPLAY=:1
And then a maven package to run the test class.
Why can't I get the Jenkins job to execute Firefox?
What finally ended up working was to create the entire Jenkins job as one step that ran shell commands:
Xvfb :1 -screen 0 1024x768x24 &
export DISPLAY=:1
mvn package
and that worked. No more NotConnectedException.
I had originally had the Jenkins job as 2 steps, shell to create virtual frame buffer and maven goal.
When you run the job from jenkins, it runs the same test as "Jenkins" user. You need to add one more line in etc/hosts file for jenkins user like
your.ip.address.value jenkins