linux - Jenkins job failed due to tests failed. Source code for tests include AWT GUI tests, how to use Xvfb plugin -
- environment - linux. << log on machine me (c123456) , "sudo su - jenkins"
- language - java
project structure
src/java -- java source codetest/java -- junit unit tests
src/java-test -- integration tests
build system - gradle
build.gradle sourcesets definitions:
sourcesets { main { java { srcdir 'src/java' } } test { java { srcdir 'test/java' } } integrationtest { java { srcdir 'src/java-test' } } }
- lets checked out source code project "projectabc" somewhere.
when run "gradle clean build", runs fine on local machine (windows win7 desktop) using cygwin session. java compile , test run successful.
when run "gradle clean build" on linux terminal i.e. using putty session, fails during test task java compile part successful.
when run "gralde clean build -x test", works (as excluding test task call).
im getting following error message when use "gradle clean build" on putty session:
:compiletestjava download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.pom download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.jar download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar /production/jenkinsaks/jobs/projectabcutilities/workspace/test/java/com/tr/ids/util/test/tree/testmultiparenttree.java:5: warning: unmappable character encoding utf8 * copyright � 2005 thomson micromedex. rights reserved. ^ /production/jenkinsaks/jobs/projectabcutilities/workspace/test/java/com/tr/ids/util/test/tree/testsingleparenttree.java:5: warning: unmappable character encoding utf8 * copyright � 2005 thomson micromedex. rights reserved. ^ note: input files use unchecked or unsafe operations. note: recompile -xlint:unchecked details. :processtestresources up-to-date :testclasses :test download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.pom download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.build/0.6.2.201302030002/org.jacoco.build-0.6.2.201302030002.pom download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.jar xlib: connection "localhost:12.0" refused server xlib: putty x11 proxy: wrong authorisation protocol attempted com.tr.ids.util.test.chart.testchartutilities > getpiechart failed java.lang.internalerror @ testchartutilities.java:89 com.tr.ids.util.test.chart.testchartutilities > getlegend failed java.lang.noclassdeffounderror @ testchartutilities.java:103 com.tr.ids.util.test.chart.testchartutilities > usestring failed java.lang.noclassdeffounderror @ testchartutilities.java:143 140 tests completed, 3 failed :test failed failure: build failed exception.
as see above, ":test" task called @ last. project projectabc has test case test source code has .java file includes following code:
i.e. under /test/java/com/tr/ids/util/test/...*.java, *.html
the file giving problem is: testchartutilities.java
test source code - java file code snapshot is:. see lines/line# 89, 103 , 143 line contains: "result = chartutil." keyword
package com.tr.ids.util.test.chart; import java.awt.color; import java.io.unsupportedencodingexception; import junit.framework.test; import junit.framework.testsuite; import junit.textui.testrunner; import com.tr.ids.util.api.chart.chartdata; import com.tr.ids.util.api.chart.chartutil; import com.tr.ids.util.test.basetestcase; .. .... ......more code here ... .... ... // ############################################################################# // test. // ############################################################################# /** * test simple string ampersand character. */ public void getpiechart() { chartdata chartdata = new chartdata(); try { chartdata.addchartitem(25, new color(255,255,0)); chartdata.addchartitem(25, new color(255,0,255)); chartdata.addchartitem(25, new color(0,255,255)); } catch (exception e) { fail("exception occured while building chartdata object (probably 0 amount)"); } byte[] result = null; try { result = chartutil.drawpiechart(chartdata, 300); // <--- line# 89 failing. } catch (exception e) { fail("exception occured trying drawpiechart."); } assertnotnull("no pie chart returned", result); } .. .... ......more code here ... .... ... /** * test simple string apostrophe , quote characters. */ public void getlegend() { byte[] result = null; try { result = chartutil.drawlegend("ff0000", 40); // <--- line# 103 } catch (exception e) { fail("exception occured while drawing legend box"); } assertnotnull("no legend image returned", result); } /** * test simple string less , greater characters. */ public void usestring() { chartdata chartdata = new chartdata(); try { chartdata.addchartitem(25, new color(255,255,0)); chartdata.addchartitem(25, new color(255,0,255)); chartdata.addchartitem(25, new color(0,255,255)); } catch (exception e) { fail("exception occured while building chartdata object (probably 0 amount)"); } string graphdesc = null; try { graphdesc = chartdata.generatestringrepresentaion(false); } catch (unsupportedencodingexception e1) { fail("exception occured while building chartdata object (probably 0 amount)"); } chartdata chartdata2 = new chartdata(); try { chartdata2.loadfromstring(graphdesc); } catch (numberformatexception e) { fail("numberformatexception thrown loading string"); } catch (exception e) { e.printstacktrace(); fail("exception thrown"); } byte[] result = null; try { result = chartutil.drawpiechart(chartdata2, 300); // <--- line# 143 } catch (exception e) { fail("exception occured trying drawpiechart."); } assertnotnull("no pie chart returned chart loaded string", result); }
now, mentioned earlier, in cygwin (windows local machine), works may have graphical/awt settings/tools available on local machine via cygwin.
now, missing???
as getting same error (when running via putty session) in jenkins job well, thought installing / using jenkins "xvfb plugin" says:
lets control xvfb virtual frame buffer x11 server each build. starts xvfb before build starts, , stops build. useful if build requires x11 access, instance runs tests require gui.
i configured plugin according instructions: https://wiki.jenkins-ci.org/display/jenkins/xvfb+plugin
but, it's still giving me error.
jenkins logs (when i'm not using jenkins xvfb plugin) showing same error i'm getting in putty session.
similarly, when "gradle clean build -x test" called, jenkins job successful have run "gradle clean build" (which fails).
now, when enabling jenkins "xvfb" plugin in jenkins global configuration (under manager jenkins > configure system) , @ job's configuration level, i'm getting following error in jenkins log during execution:
.. .... 15:30:11 xvfb starting$ xvfb :2 -screen 0 1024x768x24 -fbdir /production/jenkinsaks/2013-08-23_15-30-072456509552045645846xvfb .. ... ... :compiletestjava download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.pom download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/junit/junit/4.11/junit-4.11.jar download http://artifactory_server2:8081/artifactory/libs-thirdparty-local/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar /production/jenkinsaks/jobs/projectabcutilities/workspace/test/java/com/tr/ids/util/test/tree/testmultiparenttree.java:5: warning: unmappable character encoding utf8 * copyright � 2005 thomson micromedex. rights reserved. ^ /production/jenkinsaks/jobs/projectabcutilities/workspace/test/java/com/tr/ids/util/test/tree/testsingleparenttree.java:5: warning: unmappable character encoding utf8 * copyright � 2005 thomson micromedex. rights reserved. ^ note: input files use unchecked or unsafe operations. note: recompile -xlint:unchecked details. :processtestresources up-to-date :testclasses :test download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.pom download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.build/0.6.2.201302030002/org.jacoco.build-0.6.2.201302030002.pom download http://artifactory_server2:8081/artifactory/jcenter-cache/org/jacoco/org.jacoco.agent/0.6.2.201302030002/org.jacoco.agent-0.6.2.201302030002.jar 15:30:51 xlib: connection "localhost:16.0" refused server 15:30:51 xlib: putty x11 proxy: wrong authorisation protocol attempted 15:30:52 com.tr.ids.util.test.chart.testchartutilities > getpiechart failed java.lang.internalerror @ testchartutilities.java:89 com.tr.ids.util.test.chart.testchartutilities > getlegend failed java.lang.noclassdeffounderror @ testchartutilities.java:103 com.tr.ids.util.test.chart.testchartutilities > usestring failed java.lang.noclassdeffounderror @ testchartutilities.java:143 140 tests completed, 3 failed :test failed failure: build failed exception.
as notice, time i'm getting lines.
15:30:51 xlib: connection "localhost:16.0" refused server 15:30:51 xlib: putty x11 proxy: wrong authorisation protocol attempted 15:30:52
when @ job level configuration xvfb's advance configurtion, mentioned value in box "xvfb specific display name" 13 or 16 (as per plugin), see same errors tests part (as got earlier), x11 related error time, comes as:
15:31:42 xvfb starting$ xvfb :16 -screen 0 1024x768x24 -fbdir /production/jenkinsaks/2013-08-23_15-31-388454769980302593302xvfb 15:31:42 _xservtranssocketinetcreatelistener: ...socketcreatelistener() failed 15:31:42 _xservtransmakeallcotsserverlisteners: server running 15:31:42 15:31:42 fatal server error: 15:31:42 cannot establish listening sockets - make sure x server isn't running 15:31:42 unlink: no such file or directory 15:31:42 unlink failed, errno 2 15:31:44 error: xvfb failed start, consult lines above errors
ps -eaf|grep -i xvfb - doesn't show running on linux server.
when jenkins job runs using xvfb plugin, initiates call start / stop x display during it's execution automatically (as per xvfb plugin's features on jenkins xvfb page).
i found x11 forwarding enabled on linux machine:
# grep x11f /etc/ssh/sshd_config x11forwarding yes #
one thing notice is, user use run jenkins is: "jenkins" , once log linux machine me (c123456 id) , "sudo su - jenkins", then, there's no .xauthority file.
doing: ... show exists: ls -ltra ~c123456
-rw------- 1 c123456 devgroup 406 aug 23 13:07 .xauthority
but, same doesn't exist user jenkins i.e. ls -ltra ~jenkins (doesn't have .xauthority file).
linux $display variable set "xclock" doesn't work. have x11 setting enabled/checked x11 forwarding (at client side i.e. on windows local machine putty setting target linux machine session).
[c1234563@devserver1 ~]$ echo $display localhost:15.0 [c1234563@devserver1 ~]$ xclock x connection localhost:15.0 broken (explicit kill or server shutdown). [c1234563@devserver1 ~]$
i tried link still not able resolve issue, following says resolve it.
what missing @ point can me:
1) resolve tests fail issue using putty session or through jenkins job way.
2) i'm wondering if xvfb plugin doing x display using memory frame buffers, should not install x display server/client on local windows machine / target linux machine xming, xvnc/tightvnc etc.
a putty session , jenkins job have 2 different run environments. because of way configured, putty wants use remote x server, while jenkins headless , requires xfvb or similar environment.
for tentative trough putty work, might want add "forwardx11trusted yes
" in /etc/ssh/sshd_config
on server, or use xauth. make gui appear on windows client. not want: don't want have export display remote server run automated build.
to fix jenkins, not 100% sure yet. xfvb plugin fails because have server running on port tries use. may want check netstat -ln , search ports (potentially around 6000+). let's start that.
Comments
Post a Comment