Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In continuous integration (headless env -> mac os X server), use a tool/lib which needs access to GUI, xvfb/display emulator/X11 forwarding

We have a Mac os x server (10.10.3) we use to run functional tests with Jenkins.

We would like to use (in our tests) a tool/lib (sikulix for information) which uses under the hood java.awt.Robot class -java.awt.GraphicsEnvironment-. The problem is : we can't use this java class in headless env, because it needs to have access to a GUI.

So I would like to know if there was a solution/hack to make this tool works with jenkins.

Considering we have an USB-HDMI simulator (mac headless accelerator) which simulates a display attached.

We have also Xquartz, X11, xauth installed so I thought it would have bypassed this java headless restriction, by forcing the java.awt.headless property to false, and by using an X window, but it's not the case.

Correct me if I'm wrong : we don't need to have a real screen to do that, it's the goal of a display emulator/simulator; isn't it?

What I've tried successfully to use this lib in our tests:

  • use it on desktop (with monitor, ofc it works)

  • use screen sharing between remote mac server machine A and local mac desktop machine B (by executing the script in terminal of this screen sharing) vnc?

  • with ssh -Y on my linux computer(client) which was also the server of a X Window System (X11) app : it has worked doing a X11 forwarding without any ssh config changes (-Y flag). java.awt.headless=false was useful here

But I can't really tell if this last solution was useful. Though I've executed the script via ssh, I had a screen connected : it might have influence something .

(Keep in mind the final goal is to execute the tests with jenkins).

It led me to this try : execute the script via ssh with -Y flag or by modifying ssh_config/sshd_config files (access to the mac -remote server-) with screen sharing active, but it doesn't automatically recognized X-window :(

Here my questions :

  • Would the xvfb plug-in (jenkins) be sufficient to do what we want? I don't know how to configure it yet.

  • Could it be possible to do a X11forwarding from mac server (script executed with jenkins as daemon/agent; including maybe a ssh -Y connexion, I don't know yet how to make it to work) to the screen shared ?-which is also the server.... don't know why it can't recognize it- .

Yeah I know, this question is strange but my brain is burning and I'm getting confused...

By the way I would prefer to do everything really headless, but if it's not possible and I have to use the screen sharing, I'm fine.

Currently I'm really wondering if it is possible to launch a GUI application which needs X11 -on mac- in an headless environment... I thought the answer was yes with the correct installations, but apparently it's not that simple... or I must don't understand something correctly.

For X11 forwarding, I have the $DISPLAY var set, but I still get

Error: Can't open display 'address'

Even if I set the display to local, remote, or address, I'm still blocked by the lib with GUI access.

Another solution could be to attach terminal sessions (screen sharing terminal/terminal launching the script), I will try tomorrow with tmux. I still find strange that the server can't detect its shared session (I wanted to say it another time !).... There is an opened screen dude :s

With xvfb :

export DISPLAY=:1
Xvfb :1 &

Then mvn command but it still doesn't work.

like image 947
Fanch Avatar asked May 06 '15 18:05

Fanch


1 Answers

Well, one solution is to launch jenkins (war) in screen sharing terminal (or just open the jenkins session). That way when you launch a job it uses the screen sharing display.

[In fact it's not true, the problem is just about accessing GUI, screen attached or no. So if you have the appropriate applications installed on server(X11, Xfvb, XQuartz for mac, etc...), it will work. edit : still not sure about it]

My problem here was : first I had the java headless restriction, second I had also the -java GUI-/-mac ssh- restriction, which isn't present on Linux.

See atomicpirate's answer : How to run a java GUI on mac osx after ssh

So to summarize, by default it uses java headless libs via ssh on mac, force it to use GUI libs with :

java.awt.headless = false

Plus (for mac)

export AWT_TOOLKIT=CToolkit

If you launch your tests via Jenkins, you might also look at this -if you can't access to WindowServer- : Build Unity project with Jenkins failed

Edit : Though it didn't work for me, even via Agent, it was anyway necessary to open the session with jenkins user (VNC).

like image 150
Fanch Avatar answered Nov 15 '22 21:11

Fanch