12

All automated test runs successfully. but xvfb issue causes the build failure in Jenkins.

I have used below commnad in ExecuteShell option available under Jenkins to run my test cases on headless browser

/usr/bin/xvfb-run /usr/local/apache-maven-3.3.1/bin/mvn clean test -Dbrowser=firefox 

Getting the below output:

Results :

Tests run: 22, Failures: 0, Errors: 0, Skipped: 0


[INFO] BUILD SUCCESS

[INFO] Total time: 10:19 min

[INFO] Final Memory: 20M/47M


/usr/bin/xvfb-run: line 171: kill: (25939) - No such process

Build step 'Execute shell' marked build as failure

As we can see in the output [INFO] BUILD SUCCESS. But /usr/bin/xvfb-run: line 171: kill: (25939) - No such process causes the builld failure.

Could anybody please provide some workaround for this?

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
vish
  • 901
  • 1
  • 7
  • 20
  • What is line 171 of `xvfb-run`? Is the script online somewhere it can be seen? – Etan Reisner May 28 '15 at 13:00
  • xvfb-run is running a bunch of code. Dont know which line it taking as 171. – vish May 29 '15 at 11:09
  • Does it look roughly like [this](https://git.centos.org/blob/rpms!xorg-x11-server/70130e98ab8c06ce3f7e7d65a80e71aa5f09f614/SOURCES!xvfb-run.sh;jsessionid=o6zzn1bogxm4iee8l4ugs6q1)? The problem is that, for some reason, Xvfb has already died by the time the script tries to kill it and so `kill` fails. I don't know why that would be. You could modify the script to handle that case but it clearly doesn't think that's something that should generally happen. – Etan Reisner May 29 '15 at 11:20
  • 1
    Add "-e /tmp/xvfb.log" to get a log from xvfb. This might help isolate the problem. – P.T. Jun 24 '15 at 05:23
  • 3
    I have this same issue interacting with wkhtmltopdf – wnasich Jul 16 '15 at 20:02
  • I have the same problem with bamboo and slimerjs – Christian Haller Feb 09 '16 at 10:34

2 Answers2

14

I had this same problem when trying to run wkhtmltopdf thru xvfb-run.

In my PHP script, I executed /usr/bin/xvfb-run /usr/bin/wkhtmltopdf ... several times in the same script. The first one always worked, but the second one failed consistently with the same error you posted about.

Adding -e /tmp/xvfb.log to the second command revealed this in the log:

Fatal server error: (EE) Server is already active for display 99 If this server is no longer running, remove /tmp/.X99-lock and start again.

The solution in my case was to add the -a flag to the command:

/usr/bin/xvfb-run -a /usr/bin/wkhtmltopdf ...

Which will tell xvfb-run to "try to get a free server number, starting at --server-num".

Brian
  • 7,204
  • 12
  • 51
  • 84
-3

I could skip the same error using a little trick:

sleep(10);

on my code... after ends a task and slept my PHP code I could run another task without any errors... following my PHP script...

hope it helps

danglingpointer
  • 4,708
  • 3
  • 24
  • 42
Herzer
  • 1