running GWTTestCases without X

28 views
Skip to first unread message

Arthur Kalmenson

unread,
Oct 17, 2008, 11:33:37 AM10/17/08
to Google-We...@googlegroups.com
Hello everyone,

I'm trying to run some GWTTestCases on our Continuous Integration server but it fails because the server is in run level 3, i.e. X isn't running. When I ssh into the box with X forwarding, the test cases pass, but without X forwarding they fail with error messages. Here's the script that's run by Hudson:

#!/bin/bash

export CLASSPATH="/home/sysadm/.m2/repository/com/google/gwt/gwt-user/1.5.2/gwt-user-1.5.2.jar":"/home/sysadm/.m2/repository/com/google/gwt/gwt-dev/1.5.2/gwt-dev-1.5.2-linux.jar":"/home/sysadm/credentialing-msh/src/main/java":"/home/sysadm/credentialing-msh/src/main/resources":"/home/sysadm/credentialing-msh/classes":"/home/sysadm/credentialing-msh/target/test-classes":"/home/sysadm/credentialing-msh/target/classes":"/home/sysadm/.m2/repository/com/google/gwt/gwt-servlet/1.5.2/gwt-servlet-1.5.2.jar":"/home/sysadm/.m2/repository/junit/junit/4.1/junit-4.1.jar":"/home/sysadm/credentialing-msh/src/test/java":"/home/sysadm/credentialing-msh/src/test/resources":"/home/sysadm/credentialing-msh/target/test-classes":"/home/sysadm/credentialing-msh/target/classes":"/home/sysadm/.m2/repository/com/google/gwt/gwt-servlet/1.5.2/gwt-servlet-1.5.2.jar":"/home/sysadm/.m2/repository/com/google/gwt/gwt-user/1.5.2/gwt-user-1.5.2.jar":"/home/sysadm/.m2/repository/com/google/gwt/gwt-dev/1.5.2/gwt-dev-1.5.2-linux.jar":"/home/sysadm/.m2/repository/junit/junit/4.1/junit-4.1.jar":

"/usr/lib/jvm/java-6-sun-1.6.0.07/jre/bin/java"  -Xmx512m -Djava.awt.headless=true  -cp $CLASSPATH junit.textui.TestRunner com.sinai.credentialing.client.GwtTestExampleA


And here's the error message that I get:

sysadm@mshlindev:~/credentialing-msh$ ./target/gwtTest/gwtTest-com.sinai.credentialing.client.GwtTestExampleA.sh
.E
Time: 0.145
There was 1 error:
1) testSomething(com.sinai.credentialing.client.GwtTestExampleA)org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed]
        at org.eclipse.swt.SWT.error(SWT.java:3400)
        at org.eclipse.swt.widgets.Display.createDisplay(Display.java:793)
        at org.eclipse.swt.widgets.Display.create(Display.java:781)
        at org.eclipse.swt.graphics.Device.<init>(Device.java:145)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:452)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:443)
        at org.eclipse.swt.widgets.Display.getDefault(Display.java:1522)
        at com.google.gwt.dev.GWTShell.<init>(GWTShell.java:366)
        at com.google.gwt.junit.JUnitShell.<init>(JUnitShell.java:287)
        at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:204)
        at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:150)
        at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:219)
        at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:132)

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1


As you can see from the script, it does include the "-Djava.awt.headless=true" JVM option, so I'm not really sure why it requires X still. I have a feeling it's the invisible hosted mode. Is there any way around this? For the moment, I'm going to install a light window manager like XFCE and run in run level 5, but I would prefer to be in run level 3. Thank you in advance.

Regards,
--
Arthur Kalmenson

Manuel Carrasco

unread,
Oct 17, 2008, 12:59:03 PM10/17/08
to Google-We...@googlegroups.com
Install Xvfb and start it before runing your tests.

Xvfb  is an X server that can run on machines with no display hardware and no physical input devices.  It emulates a dumb framebuffer using virtual memory.

So you can do this from a shell script

# Start the xserver
Xvfb :5 >/dev/null 2>&1 &
proc=$!
# Run your tests
ant run-test 
# Kill the xserver
kill -TERM $proc

Arthur Kalmenson

unread,
Oct 17, 2008, 1:52:38 PM10/17/08
to Google-We...@googlegroups.com
Thanks for the reply. I installed xvfb and did the following:

sysadm@mshlindev:~/credentialing-msh/target/gwtTest$ Xvfb :5 >/dev/null 2>&1 &
[1] 5726
sysadm@mshlindev:~/credentialing-msh/target/gwtTest$ proc=$!
sysadm@mshlindev:~/credentialing-msh/target/gwtTest$ ./gwtTest-com.sinai.credentialing.client.GwtTestExampleA.sh


However, the same error occurred. Xvfb is running:

sysadm@mshlindev:~/credentialing-msh$ ps aux | grep -i xvfb
sysadm    5726  0.1  0.4   9400  4432 pts/0    S    13:48   0:00 Xvfb :5


I've also tried the installing XFCE4 and booting into run level 5 but to no avail. I'm not sure what else to do....

Regards,
--
Arthur Kalmenson

j...@google.com

unread,
Oct 17, 2008, 7:16:45 PM10/17/08
to Google Web Toolkit
On Oct 17, 1:52 pm, "Arthur Kalmenson" <arthur.k...@gmail.com> wrote:
> Thanks for the reply. I installed xvfb and did the following:
>
> sysadm@mshlindev:~/credentialing-msh/target/gwtTest$ Xvfb :5 >/dev/null 2>&1
> &
> [1] 5726
> sysadm@mshlindev:~/credentialing-msh/target/gwtTest$ proc=$!
> sysadm@mshlindev:~/credentialing-msh/target/gwtTest$ ./
> gwtTest-com.sinai.credentialing.client.GwtTestExampleA.sh
>
> However, the same error occurred. Xvfb is running:

You also need to set your DISPLAY environment variable to point to the
Xvfb instance:

DISPLAY=:5 ant run-tests

--
John A. Tamplin, Software Engineer (GWT), Google

Sumit Chandel

unread,
Oct 17, 2008, 7:24:33 PM10/17/08
to Google-We...@googlegroups.com
Hi Arthur,

You're correct in assuming that there is an invisible instance of hosted mode running when running GWTTestCase on a continuous build system.

The solution is indeed to run the process with an Xvfb instance, as Manuel suggested.

It's possible that the reason you're setup still isn't working is because of some missing configurations for the Xvfb instance to be able to run the tests properly. For example, you may want to double check that the DISPLAY environment variable has been set to 0:0, and if not, export it so that it is set appropriately on the next run of unit tests.

Hope that helps,
-Sumit Chandel

Sumit Chandel

unread,
Oct 17, 2008, 7:30:07 PM10/17/08
to Google-We...@googlegroups.com
Hi Arthur,

The advice John gave just above is actually correct. I'm working on getting myself an espresso so as not to give inaccurate information :-)

Cheers,
-Sumit Chandel

Arthur Kalmenson

unread,
Oct 20, 2008, 8:32:30 AM10/20/08
to Google-We...@googlegroups.com
Thank you John! That worked! Now I just need to figure out how to add that to either Hudson or the Maven build...

--
Arthur Kalmenson

Arthur Kalmenson

unread,
Oct 21, 2008, 9:56:38 AM10/21/08
to Google-We...@googlegroups.com
For anyone that has a similar problem, you just need to follow
Manuel's and John's suggestions. Launch Xvfb as follows:

Xvfb :5 >/dev/null 2>&1 &

proc=$!

Then create a DISPLAY variable:

export DISPLAY=:5

Now Xvfb will continue running so just restart Tomcat and Hudson
should now build the project correctly.

Regards,
--
Arthur Kalmenson

Chris Chen

unread,
Oct 21, 2008, 1:40:45 PM10/21/08
to Google-We...@googlegroups.com
Have you tried just setting the java system property to disable the X
requirement? Java 5+ all includes the system property
"java.awt.headless" to allow you to disable the required use of a
window system for graphics.

For example,

java -Djava.awt.headless RunTests

There is no need to do any DISPLAY or xvfb settings and such.

-Chris

Chris Chen

unread,
Oct 21, 2008, 1:45:39 PM10/21/08
to Google-We...@googlegroups.com
I forgot one thing. The example should be:

java -Djava.awt.headless=true RunTests

-Chris

Arthur Kalmenson

unread,
Oct 22, 2008, 9:52:20 AM10/22/08
to Google-We...@googlegroups.com
Yes, I've tried running in headless as you can see in the JVM
arguments in the first thread, it didn't work for some reason. But
keeping Xvfb running all the time works perfectly.

--
Arthur Kalmenson

Reply all
Reply to author
Forward
0 new messages